1 /* 2 * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 #include "config.h" 27 28 #include <wtf/text/WTFString.h> 29 30 #include "ImageObserver.h" 31 #include "BufferImageJava.h" 32 #include "PlatformContextJava.h" 33 34 #include "com_sun_webkit_graphics_GraphicsDecoder.h" 35 36 namespace WebCore { 37 38 BufferImage::BufferImage(RefPtr<RQRef> rqoImage, RefPtr<RenderingQueue> rq, int w, int h) 39 : Image(), 40 m_width(w), 41 m_height(h), 42 m_rq(rq), 43 m_rqoImage(rqoImage) 44 {} 45 46 NativeImagePtr BufferImage::nativeImageForCurrentFrame(const GraphicsContext*) 47 { 48 m_rq->flushBuffer(); 49 return m_rqoImage; 50 } 51 52 void BufferImage::flushImageRQ(GraphicsContext& gc) 53 { 54 if (gc.paintingDisabled()) { 55 return; 56 } 57 58 RenderingQueue &rqScreen = gc.platformContext()->rq(); 59 60 if (!m_rq->isEmpty()) { 61 // 1. Drawing is flushed to the buffered image's RenderQueue. 62 m_rq->flushBuffer(); 63 64 // 2. The buffered image's RenderQueue is to be decoded. 65 rqScreen.freeSpace(8) 66 << (jint)com_sun_webkit_graphics_GraphicsDecoder_DECODERQ 67 << m_rq->getRQRenderingQueue(); 68 } 69 } 70 71 ImageDrawResult BufferImage::draw(GraphicsContext& gc, const FloatRect& dstRect, 72 const FloatRect& srcRect, CompositeOperator co, BlendMode bm, DecodingMode, ImageOrientationDescription) 73 { 74 flushImageRQ(gc); 75 Image::drawImage(gc, dstRect, srcRect, co, bm); 76 return ImageDrawResult::DidDraw; 77 } 78 79 void BufferImage::drawPattern(GraphicsContext& gc, const FloatRect& dstRect, const FloatRect& srcRect, const AffineTransform& patternTransform, 80 const FloatPoint& phase, const FloatSize& spacing, CompositeOperator co, BlendMode bm) 81 { 82 flushImageRQ(gc); 83 Image::drawPattern(gc, dstRect, srcRect, patternTransform, 84 phase, spacing, co, bm); 85 } 86 87 88 } // namespace WebCore