diff options
author | Nicolas Roard <nicolasroard@google.com> | 2012-03-09 15:48:14 -0800 |
---|---|---|
committer | Nicolas Roard <nicolasroard@google.com> | 2012-03-09 17:25:29 -0800 |
commit | b3f4d3af0b06dc168453641e249d0cb9eec9b570 (patch) | |
tree | 860279e3446097a24a3b606ff491300134685afe /Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp | |
parent | 296d05c7bd54360261dedc8d387a7bf9f52ca41b (diff) | |
download | external_webkit-b3f4d3af0b06dc168453641e249d0cb9eec9b570.zip external_webkit-b3f4d3af0b06dc168453641e249d0cb9eec9b570.tar.gz external_webkit-b3f4d3af0b06dc168453641e249d0cb9eec9b570.tar.bz2 |
Introduce a LayerContent interface
Layers can now use a LayerContent object to draw their content.
We currently have two subclasses, one using an SkPicture (currently
used for composited layers), the other using a PictureSet (that we
use for the base layer). First step toward unification...
Change-Id: I5e7fd06a653f02f8721613fd3a39d36fb64a8614
Diffstat (limited to 'Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp')
-rw-r--r-- | Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index c6a69b7..6bc2dc7 100644 --- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -31,6 +31,7 @@ #include "Layer.h" #include "Length.h" #include "MediaLayer.h" +#include "PictureLayerContent.h" #include "PlatformBridge.h" #include "PlatformGraphicsContext.h" #include "RenderLayerBacking.h" @@ -603,9 +604,8 @@ bool GraphicsLayerAndroid::repaint() PaintingPhase phase(this); // Paint the background into a separate context. phase.set(GraphicsLayerPaintBackground); - if (!paintContext(m_contentLayer->recordContext(), layerBounds)) + if (!paintContext(m_contentLayer, layerBounds)) return false; - m_contentLayer->checkForPictureOptimizations(); // Construct the foreground layer and draw. RenderBox* box = layer->renderBox(); @@ -625,8 +625,7 @@ bool GraphicsLayerAndroid::repaint() IntSize scroll = layer->scrolledContentOffset(); layer->scrollToOffset(0, 0); // At this point, it doesn't matter if painting failed. - (void) paintContext(m_foregroundLayer->recordContext(), contentsRect); - m_foregroundLayer->checkForPictureOptimizations(); + (void) paintContext(m_foregroundLayer, contentsRect); layer->scrollToOffset(scroll.width(), scroll.height()); // Construct the clip layer for masking the contents. @@ -661,11 +660,9 @@ bool GraphicsLayerAndroid::repaint() } else { // If there is no contents clip, we can draw everything into one // picture. - bool painting = paintContext(m_contentLayer->recordContext(), layerBounds); + bool painting = paintContext(m_contentLayer, layerBounds); if (!painting) return false; - // We painted new content - m_contentLayer->checkForPictureOptimizations(); // Check for a scrollable iframe and report the scrolling // limits based on the view size. if (m_contentLayer->isIFrameContent()) { @@ -703,19 +700,32 @@ bool GraphicsLayerAndroid::repaint() return false; } -bool GraphicsLayerAndroid::paintContext(SkPicture* context, +bool GraphicsLayerAndroid::paintContext(LayerAndroid* layer, const IntRect& rect) { - SkAutoPictureRecord arp(context, rect.width(), rect.height()); - SkCanvas* canvas = arp.getRecordingCanvas(); + if (!layer) + return false; - if (!canvas) + SkPicture* picture = new SkPicture(); + SkCanvas* canvas = picture->beginRecording(rect.width(), rect.height(), 0); + if (!canvas) { + picture->endRecording(); + SkSafeUnref(picture); return false; + } PlatformGraphicsContext platformContext(canvas); GraphicsContext graphicsContext(&platformContext); paintGraphicsLayerContents(graphicsContext, rect); + + picture->endRecording(); + + PictureLayerContent* layerContent = new PictureLayerContent(picture); + layerContent->checkForOptimisations(); + layer->setContent(layerContent); + SkSafeUnref(layerContent); + SkSafeUnref(picture); return true; } |