diff options
Diffstat (limited to 'Source/WebCore')
3 files changed, 32 insertions, 29 deletions
diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index 5fe9a1f..3cbf43e 100644 --- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -41,6 +41,7 @@ #include "Length.h" #include "MediaLayer.h" #include "PictureLayerContent.h" +#include "PicturePileLayerContent.h" #include "PlatformBridge.h" #include "PlatformGraphicsContextSkia.h" #include "RenderLayerBacking.h" @@ -351,6 +352,7 @@ void GraphicsLayerAndroid::setSize(const FloatSize& size) } m_contentLayer->setSize(size.width(), size.height()); + m_contentLayer->setContent(0); setNeedsDisplay(); askForSync(); } @@ -828,22 +830,9 @@ bool GraphicsLayerAndroid::repaint() return false; } -SkPicture* GraphicsLayerAndroid::paintPicture(const IntRect& rect) +void GraphicsLayerAndroid::paintContents(GraphicsContext* gc, IntRect& dirty) { - SkPicture* picture = new SkPicture(); - SkCanvas* canvas = picture->beginRecording(rect.width(), rect.height(), 0); - if (!canvas) { - picture->endRecording(); - SkSafeUnref(picture); - return 0; - } - - PlatformGraphicsContextSkia platformContext(canvas); - GraphicsContext graphicsContext(&platformContext); - - paintGraphicsLayerContents(graphicsContext, rect); - - return picture; + paintGraphicsLayerContents(*gc, dirty); } bool GraphicsLayerAndroid::paintContext(LayerAndroid* layer, @@ -854,19 +843,26 @@ bool GraphicsLayerAndroid::paintContext(LayerAndroid* layer, return false; TRACE_METHOD(); - SkPicture* picture = paintPicture(rect); - if (!picture) - return false; - picture->endRecording(); - PictureLayerContent* layerContent = new PictureLayerContent(picture); - if (checkOptimisations) - layerContent->checkForOptimisations(); - else - layerContent->setCheckForOptimisations(false); - layer->setContent(layerContent); - SkSafeUnref(layerContent); - SkSafeUnref(picture); + if (!layer->content()) { + WebCore::PicturePile picture; + picture.setSize(IntSize(m_size.width(), m_size.height())); + PicturePileLayerContent* content = new PicturePileLayerContent(picture); + layer->setContent(content); + SkSafeUnref(content); + } + + PicturePileLayerContent* pcontent = static_cast<PicturePileLayerContent*>(layer->content()); + WebCore::PicturePile* layerContent = pcontent->picturePile(); + + // TODO: we might be able to reuse an existing picture instead of resetting it. + // we can't do that because of transparency -- for now, we just invalidate everything. + layerContent->reset(); + layerContent->setSize(IntSize(m_size.width(), m_size.height())); + + // TODO: add content checks (text, opacity, etc.) + layerContent->updatePicturesIfNeeded(this); + return true; } diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h index 460e00f..b40459d 100644 --- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h @@ -24,6 +24,7 @@ #include "GraphicsLayer.h" #include "GraphicsLayerClient.h" #include "LayerContent.h" +#include "PicturePile.h" #include "RefPtr.h" #include "ScrollableLayerAndroid.h" #include "SkBitmapRef.h" @@ -40,12 +41,18 @@ class LayerAndroid; class FixedBackgroundImageLayerAndroid; class ScrollableLayerAndroid; -class GraphicsLayerAndroid : public GraphicsLayer { +class GraphicsLayerAndroid : public GraphicsLayer, PicturePainter { public: GraphicsLayerAndroid(GraphicsLayerClient*); virtual ~GraphicsLayerAndroid(); + // PicturePainter + + virtual void paintContents(GraphicsContext* gc, IntRect& dirty); + + ///// + virtual void setName(const String&); // for hosting this GraphicsLayer in a native layer hierarchy @@ -147,7 +154,6 @@ private: bool repaint(); void needsNotifyClient(); - SkPicture* paintPicture(const IntRect& rect); bool paintContext(LayerAndroid* layer, const IntRect& rect, bool checkOptimisations = true); diff --git a/Source/WebCore/platform/graphics/android/layers/PicturePileLayerContent.h b/Source/WebCore/platform/graphics/android/layers/PicturePileLayerContent.h index 4fc123e..f2b7c61 100644 --- a/Source/WebCore/platform/graphics/android/layers/PicturePileLayerContent.h +++ b/Source/WebCore/platform/graphics/android/layers/PicturePileLayerContent.h @@ -44,6 +44,7 @@ public: virtual void serialize(SkWStream* stream); virtual PrerenderedInval* prerenderForRect(const IntRect& dirty); virtual void clearPrerenders(); + PicturePile* picturePile() { return &m_picturePile; } private: PicturePile m_picturePile; |