diff options
author | Nicolas Roard <nicolasroard@google.com> | 2012-03-07 16:13:39 -0800 |
---|---|---|
committer | Nicolas Roard <nicolasroard@google.com> | 2012-03-08 11:41:31 -0800 |
commit | ce76304e955cb279f6f237a84c0ba4fd40a2b2ba (patch) | |
tree | aa30a37cb34c8096ae33dd512c2da9fac86cb06d /Source | |
parent | 47b8a953ab1b71113b605fd84489f63938bd7dd7 (diff) | |
download | external_webkit-ce76304e955cb279f6f237a84c0ba4fd40a2b2ba.zip external_webkit-ce76304e955cb279f6f237a84c0ba4fd40a2b2ba.tar.gz external_webkit-ce76304e955cb279f6f237a84c0ba4fd40a2b2ba.tar.bz2 |
Change the way we apply fixed position to layers
With the latest refactoring we lost the possibility of having a layer
other than LayerAndroid be fixed positioned. This CL remove the
FixedLayerAndroid class (rename it into FixedPositioning) of the
hierarchy, and use delegation to apply fixed position.
Change-Id: Ib291fcaefe6a4431849ccfe2cf458fac6cac58aa
Diffstat (limited to 'Source')
-rw-r--r-- | Source/WebCore/Android.mk | 2 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/FixedPositioning.cpp (renamed from Source/WebCore/platform/graphics/android/FixedLayerAndroid.cpp) | 61 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/FixedPositioning.h (renamed from Source/WebCore/platform/graphics/android/FixedLayerAndroid.h) | 74 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp | 28 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/Layer.h | 2 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/LayerAndroid.cpp | 26 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/LayerAndroid.h | 14 | ||||
-rw-r--r-- | Source/WebKit/android/jni/ViewStateSerializer.cpp | 58 |
8 files changed, 147 insertions, 118 deletions
diff --git a/Source/WebCore/Android.mk b/Source/WebCore/Android.mk index 74017f0..4884e5b 100644 --- a/Source/WebCore/Android.mk +++ b/Source/WebCore/Android.mk @@ -641,7 +641,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ platform/graphics/android/BitmapAllocatorAndroid.cpp \ platform/graphics/android/ClassTracker.cpp \ platform/graphics/android/DumpLayer.cpp \ - platform/graphics/android/FixedLayerAndroid.cpp \ + platform/graphics/android/FixedPositioning.cpp \ platform/graphics/android/FontAndroid.cpp \ platform/graphics/android/FontCacheAndroid.cpp \ platform/graphics/android/FontCustomPlatformData.cpp \ diff --git a/Source/WebCore/platform/graphics/android/FixedLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/FixedPositioning.cpp index ebadeaf..140411a 100644 --- a/Source/WebCore/platform/graphics/android/FixedLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/FixedPositioning.cpp @@ -1,46 +1,46 @@ #include "config.h" -#include "FixedLayerAndroid.h" +#include "FixedPositioning.h" + #include "DumpLayer.h" +#include "IFrameLayerAndroid.h" #include "TilesManager.h" -#include "GLWebViewState.h" - #if USE(ACCELERATED_COMPOSITING) -#include <wtf/CurrentTime.h> #include <cutils/log.h> +#include <wtf/CurrentTime.h> #include <wtf/text/CString.h> -#define XLOGC(...) android_printLog(ANDROID_LOG_DEBUG, "FixedLayerAndroid", __VA_ARGS__) +#define XLOGC(...) android_printLog(ANDROID_LOG_DEBUG, "FixedPositioning", __VA_ARGS__) namespace WebCore { -FixedLayerAndroid::FixedLayerAndroid(const FixedLayerAndroid& layer) - : LayerAndroid(layer) - , m_fixedLeft(layer.m_fixedLeft) - , m_fixedTop(layer.m_fixedTop) - , m_fixedRight(layer.m_fixedRight) - , m_fixedBottom(layer.m_fixedBottom) - , m_fixedMarginLeft(layer.m_fixedMarginLeft) - , m_fixedMarginTop(layer.m_fixedMarginTop) - , m_fixedMarginRight(layer.m_fixedMarginRight) - , m_fixedMarginBottom(layer.m_fixedMarginBottom) - , m_fixedRect(layer.m_fixedRect) - , m_renderLayerPos(layer.m_renderLayerPos) +// Called when copying the layer tree to the UI +FixedPositioning::FixedPositioning(LayerAndroid* layer, const FixedPositioning& position) + : m_layer(layer) + , m_fixedLeft(position.m_fixedLeft) + , m_fixedTop(position.m_fixedTop) + , m_fixedRight(position.m_fixedRight) + , m_fixedBottom(position.m_fixedBottom) + , m_fixedMarginLeft(position.m_fixedMarginLeft) + , m_fixedMarginTop(position.m_fixedMarginTop) + , m_fixedMarginRight(position.m_fixedMarginRight) + , m_fixedMarginBottom(position.m_fixedMarginBottom) + , m_fixedRect(position.m_fixedRect) + , m_renderLayerPos(position.m_renderLayerPos) { } -IFrameLayerAndroid* FixedLayerAndroid::updatePosition(SkRect viewport, - IFrameLayerAndroid* parentIframeLayer) +// Executed on the UI +IFrameLayerAndroid* FixedPositioning::updatePosition(SkRect viewport, + IFrameLayerAndroid* parentIframeLayer) { - IFrameLayerAndroid* iframeLayer = LayerAndroid::updatePosition(viewport, parentIframeLayer); - // So if this is a fixed layer inside a iframe, use the iframe offset // and the iframe's size as the viewport and pass to the children - if (iframeLayer) { - viewport = SkRect::MakeXYWH(iframeLayer->iframeOffset().x(), - iframeLayer->iframeOffset().y(), - iframeLayer->getSize().width(), - iframeLayer->getSize().height()); + if (parentIframeLayer) { + viewport = SkRect::MakeXYWH(parentIframeLayer->iframeOffset().x(), + parentIframeLayer->iframeOffset().y(), + parentIframeLayer->getSize().width(), + parentIframeLayer->getSize().height()); } float w = viewport.width(); float h = viewport.height(); @@ -66,14 +66,13 @@ IFrameLayerAndroid* FixedLayerAndroid::updatePosition(SkRect viewport, else y += h - m_fixedMarginBottom.calcFloatValue(h) - m_fixedBottom.calcFloatValue(h) - m_fixedRect.fBottom; - this->setPosition(x, y); + m_layer->setPosition(x, y); - return iframeLayer; + return parentIframeLayer; } -void FixedLayerAndroid::contentDraw(SkCanvas* canvas, PaintStyle style) +void FixedPositioning::contentDraw(SkCanvas* canvas, Layer::PaintStyle style) { - LayerAndroid::contentDraw(canvas, style); if (TilesManager::instance()->getShowVisualIndicator()) { SkPaint paint; paint.setARGB(80, 255, 0, 0); @@ -89,7 +88,7 @@ void writeLength(FILE* file, int indentLevel, const char* str, SkLength length) fprintf(file, "%s = { type = %d; value = %.2f; };\n", str, length.type, length.value); } -void FixedLayerAndroid::dumpLayer(FILE* file, int indentLevel) const +void FixedPositioning::dumpLayer(FILE* file, int indentLevel) const { writeLength(file, indentLevel + 1, "fixedLeft", m_fixedLeft); writeLength(file, indentLevel + 1, "fixedTop", m_fixedTop); diff --git a/Source/WebCore/platform/graphics/android/FixedLayerAndroid.h b/Source/WebCore/platform/graphics/android/FixedPositioning.h index 6870c1d..973113b 100644 --- a/Source/WebCore/platform/graphics/android/FixedLayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/FixedPositioning.h @@ -1,29 +1,39 @@ /* - * Copyright (C) 2012 The Android Open Source Project + * Copyright 2012, The Android Open Source Project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FixedLayerAndroid_h -#define FixedLayerAndroid_h +#ifndef FixedPositioning_h +#define FixedPositioning_h #if USE(ACCELERATED_COMPOSITING) #include "LayerAndroid.h" -#include "IFrameLayerAndroid.h" namespace WebCore { +class IFrameLayerAndroid; + struct SkLength { enum SkLengthType { Undefined, Auto, Relative, Percent, Fixed, Static, Intrinsic, MinIntrinsic }; @@ -53,23 +63,12 @@ struct SkLength { } }; -class FixedLayerAndroid : public LayerAndroid { +class FixedPositioning { public: - FixedLayerAndroid(RenderLayer* owner) - : LayerAndroid(owner) {} - FixedLayerAndroid(const LayerAndroid& layer) - : LayerAndroid(layer) {} - FixedLayerAndroid(const FixedLayerAndroid& layer); - virtual ~FixedLayerAndroid() {}; - - virtual LayerAndroid* copy() const { return new FixedLayerAndroid(*this); } - virtual SubclassType subclassType() { return LayerAndroid::FixedLayer; } - - friend void android::serializeLayer(LayerAndroid* layer, SkWStream* stream); - friend LayerAndroid* android::deserializeLayer(int version, SkStream* stream); - - virtual bool isFixed() const { return true; } + FixedPositioning(LayerAndroid* layer = 0) : m_layer(layer) {} + FixedPositioning(LayerAndroid* layer, const FixedPositioning& position); + virtual ~FixedPositioning() {}; void setFixedPosition(SkLength left, // CSS left property SkLength top, // CSS top property @@ -91,17 +90,22 @@ public: m_fixedMarginBottom = marginBottom; m_fixedRect = viewRect; m_renderLayerPos = renderLayerPos; - setShouldInheritFromRootTransform(true); } - virtual IFrameLayerAndroid* updatePosition(SkRect viewPort, - IFrameLayerAndroid* parentIframeLayer); + IFrameLayerAndroid* updatePosition(SkRect viewPort, + IFrameLayerAndroid* parentIframeLayer); - virtual void contentDraw(SkCanvas* canvas, PaintStyle style); + void contentDraw(SkCanvas* canvas, Layer::PaintStyle style); - virtual void dumpLayer(FILE*, int indentLevel) const; + void dumpLayer(FILE*, int indentLevel) const; + + // ViewStateSerializer friends + friend void android::serializeLayer(LayerAndroid* layer, SkWStream* stream); + friend LayerAndroid* android::deserializeLayer(int version, SkStream* stream); private: + LayerAndroid* m_layer; + SkLength m_fixedLeft; SkLength m_fixedTop; SkLength m_fixedRight; @@ -121,4 +125,4 @@ private: #endif // USE(ACCELERATED_COMPOSITING) -#endif // FixedLayerAndroid_h +#endif // FixedPositioning_h diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index 447ab28..1ac90e9 100644 --- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -22,7 +22,7 @@ #include "AndroidAnimation.h" #include "Animation.h" #include "FloatRect.h" -#include "FixedLayerAndroid.h" +#include "FixedPositioning.h" #include "GraphicsContext.h" #include "IFrameContentLayerAndroid.h" #include "IFrameLayerAndroid.h" @@ -272,23 +272,19 @@ void GraphicsLayerAndroid::updateFixedPosition() viewRect.set(paintingOffsetX, paintingOffsetY, paintingOffsetX + w, paintingOffsetY + h); IntPoint renderLayerPos(renderLayer->x(), renderLayer->y()); - if (!m_contentLayer->isFixed()) { - FixedLayerAndroid* layer = new FixedLayerAndroid(*m_contentLayer); - m_contentLayer->unref(); - m_contentLayer = layer; + FixedPositioning* fixedPosition = m_contentLayer->fixedPosition(); + if (!fixedPosition) { + fixedPosition = new FixedPositioning(); + m_contentLayer->setFixedPosition(fixedPosition); } - FixedLayerAndroid* layer = static_cast<FixedLayerAndroid*>(m_contentLayer); - layer->setFixedPosition(left, top, right, bottom, - marginLeft, marginTop, - marginRight, marginBottom, - renderLayerPos, - viewRect); - } else if (m_contentLayer->isFixed()) { - LayerAndroid* layer = new LayerAndroid(*m_contentLayer); - m_contentLayer->unref(); - m_contentLayer = layer; - } + fixedPosition->setFixedPosition(left, top, right, bottom, + marginLeft, marginTop, + marginRight, marginBottom, + renderLayerPos, + viewRect); + } else if (m_contentLayer->isFixed()) + m_contentLayer->setFixedPosition(0); } void GraphicsLayerAndroid::setPosition(const FloatPoint& point) diff --git a/Source/WebCore/platform/graphics/android/Layer.h b/Source/WebCore/platform/graphics/android/Layer.h index b45f70d..e872278 100644 --- a/Source/WebCore/platform/graphics/android/Layer.h +++ b/Source/WebCore/platform/graphics/android/Layer.h @@ -151,7 +151,7 @@ public: virtual bool contentIsScrollable() const { return false; } - enum PaintStyle { MergedLayers, UnmergedLayers, FlattenedLayers }; + typedef enum { MergedLayers, UnmergedLayers, FlattenedLayers } PaintStyle; protected: virtual void onDraw(SkCanvas*, SkScalar opacity, android::DrawExtra* extra, PaintStyle style) {} diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp index c78540c..f101208 100644 --- a/Source/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -7,6 +7,7 @@ #include "ClassTracker.h" #include "DrawExtra.h" #include "DumpLayer.h" +#include "FixedPositioning.h" #include "GLUtils.h" #include "ImagesManager.h" #include "InspectorCanvas.h" @@ -70,6 +71,7 @@ LayerAndroid::LayerAndroid(RenderLayer* owner) : Layer(), m_visible(true), m_preserves3D(false), m_anchorPointZ(0), + m_fixedPosition(0), m_recordingPicture(0), m_zValue(0), m_uniqueId(++gUniqueId), @@ -95,6 +97,7 @@ LayerAndroid::LayerAndroid(RenderLayer* owner) : Layer(), LayerAndroid::LayerAndroid(const LayerAndroid& layer) : Layer(layer), m_haveClip(layer.m_haveClip), + m_fixedPosition(0), m_zValue(layer.m_zValue), m_uniqueId(layer.m_uniqueId), m_owningLayer(layer.m_owningLayer), @@ -118,6 +121,12 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : Layer(layer), m_preserves3D = layer.m_preserves3D; m_anchorPointZ = layer.m_anchorPointZ; + + if (layer.m_fixedPosition) { + m_fixedPosition = new FixedPositioning(this, *layer.m_fixedPosition); + Layer::setShouldInheritFromRootTransform(true); + } + m_drawTransform = layer.m_drawTransform; m_childrenTransform = layer.m_childrenTransform; m_pictureUsed = layer.m_pictureUsed; @@ -164,6 +173,7 @@ void LayerAndroid::checkForPictureOptimizations() LayerAndroid::LayerAndroid(SkPicture* picture) : Layer(), m_haveClip(false), + m_fixedPosition(0), m_recordingPicture(picture), m_zValue(0), m_uniqueId(++gUniqueId), @@ -189,6 +199,8 @@ LayerAndroid::~LayerAndroid() { if (m_imageCRC) ImagesManager::instance()->releaseImage(m_imageCRC); + if (m_fixedPosition) + delete m_fixedPosition; SkSafeUnref(m_recordingPicture); // Don't unref m_layerGroup, owned by BaseLayerAndroid @@ -381,6 +393,8 @@ IFrameLayerAndroid* LayerAndroid::updatePosition(SkRect viewport, IFrameLayerAndroid* parentIframeLayer) { // subclasses can implement this virtual function to modify their position + if (m_fixedPosition) + return m_fixedPosition->updatePosition(viewport, parentIframeLayer); return parentIframeLayer; } @@ -904,6 +918,9 @@ void LayerAndroid::contentDraw(SkCanvas* canvas, PaintStyle style) canvas->drawLine(w, h, w, 0, paint); canvas->drawLine(w, 0, 0, 0, paint); } + + if (m_fixedPosition) + return m_fixedPosition->contentDraw(canvas, style); } void LayerAndroid::onDraw(SkCanvas* canvas, SkScalar opacity, @@ -964,6 +981,12 @@ bool LayerAndroid::prepareContext(bool force) return m_recordingPicture; } +void LayerAndroid::setFixedPosition(FixedPositioning* position) { + if (m_fixedPosition && m_fixedPosition != position) + delete m_fixedPosition; + m_fixedPosition = position; +} + SkRect LayerAndroid::subtractLayers(const SkRect& visibleRect) const { SkRect result; @@ -1021,6 +1044,9 @@ void LayerAndroid::dumpLayer(FILE* file, int indentLevel) const writeIntVal(file, indentLevel + 1, "m_recordingPicture.width", m_recordingPicture->width()); writeIntVal(file, indentLevel + 1, "m_recordingPicture.height", m_recordingPicture->height()); } + + if (m_fixedPosition) + return m_fixedPosition->dumpLayer(file, indentLevel); } void LayerAndroid::dumpLayers(FILE* file, int indentLevel) const diff --git a/Source/WebCore/platform/graphics/android/LayerAndroid.h b/Source/WebCore/platform/graphics/android/LayerAndroid.h index 86c2851..7f5d5e2 100644 --- a/Source/WebCore/platform/graphics/android/LayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/LayerAndroid.h @@ -65,9 +65,10 @@ namespace WebCore { class AndroidAnimation; class BaseTileTexture; +class FixedPositioning; class GLWebViewState; -class LayerMergeState; class IFrameLayerAndroid; +class LayerMergeState; class RenderLayer; class TiledPage; class PaintedSurface; @@ -90,7 +91,7 @@ public: class TEST_EXPORT LayerAndroid : public Layer { public: typedef enum { UndefinedLayer, WebCoreLayer, UILayer, NavCacheLayer } LayerType; - typedef enum { StandardLayer, FixedLayer, ScrollableLayer, + typedef enum { StandardLayer, ScrollableLayer, IFrameLayer, IFrameContentLayer } SubclassType; String subclassName() @@ -98,8 +99,6 @@ public: switch (subclassType()) { case LayerAndroid::StandardLayer: return "StandardLayer"; - case LayerAndroid::FixedLayer: - return "FixedLayer"; case LayerAndroid::ScrollableLayer: return "ScrollableLayer"; case LayerAndroid::IFrameLayer: @@ -245,10 +244,13 @@ public: virtual bool isMedia() const { return false; } virtual bool isVideo() const { return false; } - virtual bool isFixed() const { return false; } + bool isFixed() const { return m_fixedPosition; } virtual bool isIFrame() const { return false; } virtual bool isIFrameContent() const { return false; } + void setFixedPosition(FixedPositioning* position); + FixedPositioning* fixedPosition() { return m_fixedPosition; } + RenderLayer* owningLayer() const { return m_owningLayer; } float zValue() const { return m_zValue; } @@ -312,6 +314,8 @@ private: float m_anchorPointZ; float m_drawOpacity; + FixedPositioning* m_fixedPosition; + // Note that m_recordingPicture and m_imageRef are mutually exclusive; // m_recordingPicture is used when WebKit is asked to paint the layer's // content, while m_imageRef contains an image that we directly diff --git a/Source/WebKit/android/jni/ViewStateSerializer.cpp b/Source/WebKit/android/jni/ViewStateSerializer.cpp index d2fe900..a96b6b4 100644 --- a/Source/WebKit/android/jni/ViewStateSerializer.cpp +++ b/Source/WebKit/android/jni/ViewStateSerializer.cpp @@ -27,7 +27,7 @@ #include "BaseLayerAndroid.h" #include "CreateJavaOutputStreamAdaptor.h" -#include "FixedLayerAndroid.h" +#include "FixedPositioning.h" #include "ImagesManager.h" #include "IFrameContentLayerAndroid.h" #include "IFrameLayerAndroid.h" @@ -287,19 +287,19 @@ void serializeLayer(LayerAndroid* layer, SkWStream* stream) // those fields anymore. Let's keep the current serialization format for // now and output blank fields... not great, but probably better than // dealing with multiple versions. - if (layer->isFixed()) { - FixedLayerAndroid* fixedLayer = static_cast<FixedLayerAndroid*>(layer); - writeSkLength(stream, fixedLayer->m_fixedLeft); - writeSkLength(stream, fixedLayer->m_fixedTop); - writeSkLength(stream, fixedLayer->m_fixedRight); - writeSkLength(stream, fixedLayer->m_fixedBottom); - writeSkLength(stream, fixedLayer->m_fixedMarginLeft); - writeSkLength(stream, fixedLayer->m_fixedMarginTop); - writeSkLength(stream, fixedLayer->m_fixedMarginRight); - writeSkLength(stream, fixedLayer->m_fixedMarginBottom); - writeSkRect(stream, fixedLayer->m_fixedRect); - stream->write32(fixedLayer->m_renderLayerPos.x()); - stream->write32(fixedLayer->m_renderLayerPos.y()); + if (layer->fixedPosition()) { + FixedPositioning* fixedPosition = layer->fixedPosition(); + writeSkLength(stream, fixedPosition->m_fixedLeft); + writeSkLength(stream, fixedPosition->m_fixedTop); + writeSkLength(stream, fixedPosition->m_fixedRight); + writeSkLength(stream, fixedPosition->m_fixedBottom); + writeSkLength(stream, fixedPosition->m_fixedMarginLeft); + writeSkLength(stream, fixedPosition->m_fixedMarginTop); + writeSkLength(stream, fixedPosition->m_fixedMarginRight); + writeSkLength(stream, fixedPosition->m_fixedMarginBottom); + writeSkRect(stream, fixedPosition->m_fixedRect); + stream->write32(fixedPosition->m_renderLayerPos.x()); + stream->write32(fixedPosition->m_renderLayerPos.y()); } else { SkLength length; SkRect rect; @@ -403,21 +403,21 @@ LayerAndroid* deserializeLayer(int version, SkStream* stream) } if (isFixed) { - FixedLayerAndroid* fixedLayer = new FixedLayerAndroid(*layer); - layer->unref(); - layer = fixedLayer; - - fixedLayer->m_fixedLeft = readSkLength(stream); - fixedLayer->m_fixedTop = readSkLength(stream); - fixedLayer->m_fixedRight = readSkLength(stream); - fixedLayer->m_fixedBottom = readSkLength(stream); - fixedLayer->m_fixedMarginLeft = readSkLength(stream); - fixedLayer->m_fixedMarginTop = readSkLength(stream); - fixedLayer->m_fixedMarginRight = readSkLength(stream); - fixedLayer->m_fixedMarginBottom = readSkLength(stream); - fixedLayer->m_fixedRect = readSkRect(stream); - fixedLayer->m_renderLayerPos.setX(stream->readS32()); - fixedLayer->m_renderLayerPos.setY(stream->readS32()); + FixedPositioning* fixedPosition = new FixedPositioning(layer); + + fixedPosition->m_fixedLeft = readSkLength(stream); + fixedPosition->m_fixedTop = readSkLength(stream); + fixedPosition->m_fixedRight = readSkLength(stream); + fixedPosition->m_fixedBottom = readSkLength(stream); + fixedPosition->m_fixedMarginLeft = readSkLength(stream); + fixedPosition->m_fixedMarginTop = readSkLength(stream); + fixedPosition->m_fixedMarginRight = readSkLength(stream); + fixedPosition->m_fixedMarginBottom = readSkLength(stream); + fixedPosition->m_fixedRect = readSkRect(stream); + fixedPosition->m_renderLayerPos.setX(stream->readS32()); + fixedPosition->m_renderLayerPos.setY(stream->readS32()); + + layer->setFixedPosition(fixedPosition); } else { // Not a fixed element, bypass the values in the stream readSkLength(stream); // fixedLeft |