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/WebKit | |
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/WebKit')
-rw-r--r-- | Source/WebKit/android/jni/ViewStateSerializer.cpp | 26 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.cpp | 6 | ||||
-rw-r--r-- | Source/WebKit/android/nav/WebView.cpp | 10 |
3 files changed, 26 insertions, 16 deletions
diff --git a/Source/WebKit/android/jni/ViewStateSerializer.cpp b/Source/WebKit/android/jni/ViewStateSerializer.cpp index dc9c72d..d3075a2 100644 --- a/Source/WebKit/android/jni/ViewStateSerializer.cpp +++ b/Source/WebKit/android/jni/ViewStateSerializer.cpp @@ -33,6 +33,8 @@ #include "IFrameLayerAndroid.h" #include "Layer.h" #include "LayerAndroid.h" +#include "LayerContent.h" +#include "PictureLayerContent.h" #include "PictureSet.h" #include "ScrollableLayerAndroid.h" #include "SkPicture.h" @@ -79,14 +81,12 @@ static bool nativeSerializeViewState(JNIEnv* env, jobject, jint jbaseLayer, #else stream->write32(0); #endif - SkPicture picture; - PictureSet* content = baseLayer->content(); - baseLayer->drawCanvas(picture.beginRecording(content->width(), content->height(), - SkPicture::kUsePathBoundsForClip_RecordingFlag)); - picture.endRecording(); if (!stream) return false; - picture.serialize(stream); + if (baseLayer->content()) + baseLayer->content()->serialize(stream); + else + return false; int childCount = baseLayer->countChildren(); XLOG("BaseLayer has %d child(ren)", childCount); stream->write32(childCount); @@ -110,7 +110,9 @@ static BaseLayerAndroid* nativeDeserializeViewState(JNIEnv* env, jobject, jint v layer->setBackgroundColor(color); #endif SkPicture* picture = new SkPicture(stream); - layer->setContent(picture); + PictureLayerContent* content = new PictureLayerContent(picture); + layer->setContent(content); + SkSafeUnref(content); SkSafeUnref(picture); int childCount = stream->readS32(); for (int i = 0; i < childCount; i++) { @@ -335,10 +337,10 @@ void serializeLayer(LayerAndroid* layer, SkWStream* stream) stream->write32(buffer.size()); buffer.writeToStream(stream); } - bool hasRecordingPicture = layer->m_recordingPicture != 0; + bool hasRecordingPicture = layer->m_content != 0 && !layer->m_content->isEmpty(); stream->writeBool(hasRecordingPicture); if (hasRecordingPicture) - layer->m_recordingPicture->serialize(stream); + layer->m_content->serialize(stream); // TODO: support m_animations (maybe?) stream->write32(0); // placeholder for m_animations.size(); writeTransformationMatrix(stream, layer->m_transform); @@ -453,7 +455,11 @@ LayerAndroid* deserializeLayer(int version, SkStream* stream) } bool hasRecordingPicture = stream->readBool(); if (hasRecordingPicture) { - layer->m_recordingPicture = new SkPicture(stream); + SkPicture* picture = new SkPicture(stream); + PictureLayerContent* content = new PictureLayerContent(picture); + layer->setContent(content); + SkSafeUnref(content); + SkSafeUnref(picture); } int animationCount = stream->readU32(); // TODO: Support (maybe?) readTransformationMatrix(stream, layer->m_transform); diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp index af25b3b..0589468 100644 --- a/Source/WebKit/android/jni/WebViewCore.cpp +++ b/Source/WebKit/android/jni/WebViewCore.cpp @@ -87,6 +87,7 @@ #include "NodeList.h" #include "Page.h" #include "PageGroup.h" +#include "PictureSetLayerContent.h" #include "PlatformKeyboardEvent.h" #include "PlatformString.h" #include "PluginWidgetAndroid.h" @@ -819,7 +820,10 @@ void WebViewCore::notifyAnimationStarted() BaseLayerAndroid* WebViewCore::createBaseLayer(SkRegion* region) { BaseLayerAndroid* base = new BaseLayerAndroid(); - base->setContent(m_content); + + PictureSetLayerContent* content = new PictureSetLayerContent(m_content); + base->setContent(content); + SkSafeUnref(content); m_skipContentDraw = true; bool layoutSucceeded = layoutIfNeededRecursive(m_mainFrame); diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index 5f5ff62..03dd866 100644 --- a/Source/WebKit/android/nav/WebView.cpp +++ b/Source/WebKit/android/nav/WebView.cpp @@ -294,14 +294,14 @@ PictureSet* draw(SkCanvas* canvas, SkColor bgColor, DrawExtras extras, bool spli } // draw the content of the base layer first - PictureSet* content = m_baseLayer->content(); + LayerContent* content = m_baseLayer->content(); + int sc = canvas->save(SkCanvas::kClip_SaveFlag); canvas->clipRect(SkRect::MakeLTRB(0, 0, content->width(), content->height()), SkRegion::kDifference_Op); canvas->drawColor(bgColor); canvas->restoreToCount(sc); - if (content->draw(canvas)) - ret = split ? new PictureSet(*content) : 0; + content->draw(canvas); DrawExtra* extra = getDrawExtra(extras); if (extra) @@ -559,7 +559,7 @@ void replaceBaseContent(PictureSet* set) { if (!m_baseLayer) return; - m_baseLayer->setContent(*set); + // TODO: remove the split picture codepath delete set; } @@ -567,7 +567,7 @@ void copyBaseContentToPicture(SkPicture* picture) { if (!m_baseLayer) return; - PictureSet* content = m_baseLayer->content(); + LayerContent* content = m_baseLayer->content(); m_baseLayer->drawCanvas(picture->beginRecording(content->width(), content->height(), SkPicture::kUsePathBoundsForClip_RecordingFlag)); picture->endRecording(); |