From 576098317db607e1d3b32a0e53d2551ea0e7ef21 Mon Sep 17 00:00:00 2001 From: Nicolas Roard Date: Fri, 4 May 2012 16:06:30 -0700 Subject: Complete implementation fixed background - extract image for body background (a lot more memory-friendly) - implement tiling / repeat - handles background color bug:1352305 Change-Id: I0efa27e09416e3c3848a4a53ced650cbb3d9f7ce --- .../graphics/android/GraphicsLayerAndroid.cpp | 61 ++------- .../graphics/android/GraphicsLayerAndroid.h | 3 +- .../graphics/android/layers/BaseLayerAndroid.cpp | 138 +++++++++++++++++---- .../graphics/android/layers/BaseLayerAndroid.h | 14 ++- .../graphics/android/layers/FixedPositioning.cpp | 65 ++++++++-- .../graphics/android/layers/FixedPositioning.h | 72 ++++++++++- .../graphics/android/layers/LayerAndroid.cpp | 4 +- .../graphics/android/layers/LayerAndroid.h | 17 ++- .../graphics/android/rendering/ImageTexture.cpp | 8 +- .../graphics/android/rendering/ImageTexture.h | 2 +- .../graphics/android/rendering/Surface.cpp | 2 +- 11 files changed, 287 insertions(+), 99 deletions(-) (limited to 'Source/WebCore/platform/graphics') diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp index 8b30d9d..06bb767 100644 --- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp @@ -25,6 +25,7 @@ #include "AndroidAnimation.h" #include "AndroidLog.h" #include "Animation.h" +#include "BaseLayerAndroid.h" #include "CachedImage.h" #include "CanvasLayer.h" #include "FixedBackgroundLayerAndroid.h" @@ -90,22 +91,6 @@ PassOwnPtr GraphicsLayer::create(GraphicsLayerClient* client) return new GraphicsLayerAndroid(client); } -SkLength convertLength(Length len) -{ - SkLength length; - length.type = SkLength::Undefined; - length.value = 0; - if (len.type() == WebCore::Percent) { - length.type = SkLength::Percent; - length.value = len.percent(); - } - if (len.type() == WebCore::Fixed) { - length.type = SkLength::Fixed; - length.value = len.value(); - } - return length; -} - static RenderLayer* renderLayerFromClient(GraphicsLayerClient* client) { return client ? client->owningLayer() : 0; @@ -248,17 +233,17 @@ void GraphicsLayerAndroid::updatePositionedLayers() m_contentLayer->setAbsolutePosition(false); // We need to get the passed CSS properties for the element SkLength left, top, right, bottom; - left = convertLength(view->style()->left()); - top = convertLength(view->style()->top()); - right = convertLength(view->style()->right()); - bottom = convertLength(view->style()->bottom()); + left = SkLength::convertLength(view->style()->left()); + top = SkLength::convertLength(view->style()->top()); + right = SkLength::convertLength(view->style()->right()); + bottom = SkLength::convertLength(view->style()->bottom()); // We also need to get the margin... SkLength marginLeft, marginTop, marginRight, marginBottom; - marginLeft = convertLength(view->style()->marginLeft()); - marginTop = convertLength(view->style()->marginTop()); - marginRight = convertLength(view->style()->marginRight()); - marginBottom = convertLength(view->style()->marginBottom()); + marginLeft = SkLength::convertLength(view->style()->marginLeft()); + marginTop = SkLength::convertLength(view->style()->marginTop()); + marginRight = SkLength::convertLength(view->style()->marginRight()); + marginBottom = SkLength::convertLength(view->style()->marginBottom()); // In order to compute the fixed element's position, we need the width // and height of the element when bottom or right is defined. @@ -603,29 +588,15 @@ void GraphicsLayerAndroid::updateFixedBackgroundLayers() { // Grab the background image and create a layer for it // the layer will be fixed positioned. - // TODO: if there's a background color, we don't honor it. FillLayer* layers = view->style()->accessBackgroundLayers(); StyleImage* styleImage = layers->image(); if (styleImage->isCachedImage()) { CachedImage* cachedImage = static_cast(styleImage)->cachedImage(); Image* image = cachedImage->image(); if (image) { - m_fixedBackgroundLayer = new LayerAndroid(renderLayer); - m_fixedBackgroundLayer->setContentsImage(image->nativeImageForCurrentFrame()); - m_fixedBackgroundLayer->setSize(image->width(), image->height()); - - FixedPositioning* fixedPosition = new FixedPositioning(m_fixedBackgroundLayer); - SkRect viewRect; - SkLength left, top, right, bottom; - left = convertLength(view->style()->backgroundXPosition()); - top = convertLength(view->style()->backgroundYPosition()); - right.setAuto(); - bottom.setAuto(); - SkLength marginLeft, marginTop, marginRight, marginBottom; - marginLeft.setAuto(); - marginTop.setAuto(); - marginRight.setAuto(); - marginBottom.setAuto(); + m_fixedBackgroundLayer = new FixedBackgroundImageLayerAndroid(view->style(), + view->width(), + view->height()); Color color = view->style()->visitedDependentColor(CSSPropertyBackgroundColor); SkColor skiaColor = SkColorSetARGB(color.alpha(), @@ -633,14 +604,6 @@ void GraphicsLayerAndroid::updateFixedBackgroundLayers() { color.green(), color.blue()); m_fixedBackgroundLayer->setBackgroundColor(skiaColor); - - viewRect.set(0, 0, view->width(), view->height()); - fixedPosition->setFixedPosition(left, top, right, bottom, - marginLeft, marginTop, - marginRight, marginBottom, - IntPoint(0, 0), viewRect); - - m_fixedBackgroundLayer->setFixedPosition(fixedPosition); } } diff --git a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h index a912f57..278bd7e 100644 --- a/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/GraphicsLayerAndroid.h @@ -37,6 +37,7 @@ class SkRegion; namespace WebCore { class LayerAndroid; +class FixedBackgroundImageLayerAndroid; class ScrollableLayerAndroid; class GraphicsLayerAndroid : public GraphicsLayer { @@ -160,7 +161,7 @@ private: SkRegion m_dirtyRegion; LayerAndroid* m_contentLayer; - LayerAndroid* m_fixedBackgroundLayer; + FixedBackgroundImageLayerAndroid* m_fixedBackgroundLayer; LayerAndroid* m_foregroundLayer; LayerAndroid* m_foregroundClipLayer; }; diff --git a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp index 4f89dc9..8abff96 100644 --- a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.cpp @@ -30,9 +30,15 @@ #include "BaseLayerAndroid.h" #include "AndroidLog.h" +#include "CachedImage.h" +#include "DrawQuadData.h" #include "FixedPositioning.h" #include "GLWebViewState.h" +#include "ImagesManager.h" #include "LayerContent.h" +#include "RenderStyle.h" +#include "StyleCachedImage.h" +#include "TilesManager.h" namespace WebCore { @@ -83,35 +89,117 @@ ForegroundBaseLayerAndroid::ForegroundBaseLayerAndroid(LayerContent* content) setIntrinsicallyComposited(true); } -FixedBackgroundBaseLayerAndroid::FixedBackgroundBaseLayerAndroid(LayerContent* content) +FixedBackgroundImageLayerAndroid::FixedBackgroundImageLayerAndroid(PassRefPtr aStyle, + int w, int h) : LayerAndroid((RenderLayer*)0) + , m_width(w) + , m_height(h) { - if (content) { - setContent(content); - setSize(content->width(), content->height()); - } + RefPtr style = aStyle; + FillLayer* layers = style->accessBackgroundLayers(); + StyleImage* styleImage = layers->image(); + CachedImage* cachedImage = static_cast(styleImage)->cachedImage(); + WebCore::Image* image = cachedImage->image(); + setContentsImage(image->nativeImageForCurrentFrame()); + setSize(image->width(), image->height()); + setIntrinsicallyComposited(true); - // TODO: add support for fixed positioning attributes - SkRect viewRect; - SkLength left, top, right, bottom; - left.setFixedValue(0); - top.setFixedValue(0); - right.setAuto(); - bottom.setAuto(); - SkLength marginLeft, marginTop, marginRight, marginBottom; - marginLeft.setAuto(); - marginTop.setAuto(); - marginRight.setAuto(); - marginBottom.setAuto(); - - viewRect.set(0, 0, content->width(), content->height()); - FixedPositioning* fixedPosition = new FixedPositioning(this); - setFixedPosition(fixedPosition); - fixedPosition->setFixedPosition(left, top, right, bottom, - marginLeft, marginTop, - marginRight, marginBottom, - IntPoint(0, 0), viewRect); + SkLength left, top; + left = SkLength::convertLength(style->backgroundXPosition()); + top = SkLength::convertLength(style->backgroundYPosition()); + + BackgroundImagePositioning* position = new BackgroundImagePositioning(this); + position->setRepeatX(style->backgroundRepeatX() != WebCore::NoRepeatFill); + position->setRepeatY(style->backgroundRepeatY() != WebCore::NoRepeatFill); + + setFixedPosition(position); + position->setPosition(left, top); +} + +FixedBackgroundImageLayerAndroid::FixedBackgroundImageLayerAndroid(const FixedBackgroundImageLayerAndroid& layer) + : LayerAndroid(layer) + , m_width(layer.m_width) + , m_height(layer.m_height) +{ +} + +static bool needToDisplayImage(bool repeatX, bool repeatY, float dx, float dy) +{ + // handles the repeat attribute for the background image + if (repeatX && repeatY) + return true; + if (repeatX && !repeatY && dy == 0) + return true; + if (!repeatX && repeatY && dx == 0) + return true; + if (dx == 0 && dy == 0) + return true; + + return false; +} + +bool FixedBackgroundImageLayerAndroid::drawGL(bool layerTilesDisabled) +{ + if (layerTilesDisabled) + return false; + if (!m_imageCRC) + return false; + + ImageTexture* imageTexture = ImagesManager::instance()->retainImage(m_imageCRC); + if (!imageTexture) { + ImagesManager::instance()->releaseImage(m_imageCRC); + return false; + } + + // We have a fixed background image, let's draw it + if (m_fixedPosition && m_fixedPosition->isBackgroundImagePositioning()) { + BackgroundImagePositioning* position = + static_cast(m_fixedPosition); + + int nbX = position->nbRepeatX(); + int nbY = position->nbRepeatY(); + float startX = position->offsetX() * getWidth(); + float startY = position->offsetY() * getHeight(); + + FloatPoint origin; + origin = drawTransform()->mapPoint(origin); + + Color backgroundColor = Color((int)SkColorGetR(m_backgroundColor), + (int)SkColorGetG(m_backgroundColor), + (int)SkColorGetB(m_backgroundColor), + (int)SkColorGetA(m_backgroundColor)); + + // Cover the entire background + for (int i = 0; i < nbY; i++) { + float dy = (i * getHeight()) - startY; + for (int j = 0; j < nbX; j++) { + float dx = (j * getWidth()) - startX; + if (needToDisplayImage(position->repeatX(), + position->repeatY(), + dx, dy)) { + FloatPoint p(dx, dy); + imageTexture->drawGL(this, getOpacity(), &p); + } else { + // If the image is not displayed, we still need to fill + // with the background color + SkRect rect; + rect.fLeft = origin.x() + dx; + rect.fTop = origin.y() + dy; + rect.fRight = rect.fLeft + getWidth(); + rect.fBottom = rect.fTop + getHeight(); + PureColorQuadData backgroundData(backgroundColor, BaseQuad, + 0, &rect, 1.0); + TilesManager::instance()->shader()->drawQuad(&backgroundData); + } + } + } + } else + imageTexture->drawGL(this, getOpacity()); + + ImagesManager::instance()->releaseImage(m_imageCRC); + + return false; } } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.h b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.h index 6275dfd..7c755ae 100644 --- a/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/layers/BaseLayerAndroid.h @@ -32,6 +32,7 @@ namespace WebCore { class RenderLayerCompositor; +class RenderStyle; class BaseLayerAndroid : public LayerAndroid { public: @@ -59,11 +60,18 @@ public: virtual bool needsTexture() { return false; } }; -class FixedBackgroundBaseLayerAndroid : public LayerAndroid { +class FixedBackgroundImageLayerAndroid : public LayerAndroid { public: - FixedBackgroundBaseLayerAndroid(LayerContent* content); + FixedBackgroundImageLayerAndroid(PassRefPtr style, int w, int h); + FixedBackgroundImageLayerAndroid(const FixedBackgroundImageLayerAndroid& layer); + virtual LayerAndroid* copy() const { return new FixedBackgroundImageLayerAndroid(*this); } virtual bool needsTexture() { return true; } - virtual SubclassType subclassType() { return LayerAndroid::FixedBackgroundBaseLayer; } + virtual SubclassType subclassType() { return LayerAndroid::FixedBackgroundImageLayer; } + virtual bool drawGL(bool layerTilesDisabled); + +private: + int m_width; + int m_height; }; } // namespace WebCore diff --git a/Source/WebCore/platform/graphics/android/layers/FixedPositioning.cpp b/Source/WebCore/platform/graphics/android/layers/FixedPositioning.cpp index c7909c4..3a04d28 100644 --- a/Source/WebCore/platform/graphics/android/layers/FixedPositioning.cpp +++ b/Source/WebCore/platform/graphics/android/layers/FixedPositioning.cpp @@ -30,18 +30,24 @@ FixedPositioning::FixedPositioning(LayerAndroid* layer, const FixedPositioning& { } -// Executed on the UI -IFrameLayerAndroid* FixedPositioning::updatePosition(SkRect viewport, - IFrameLayerAndroid* parentIframeLayer) +SkRect FixedPositioning::getViewport(SkRect aViewport, IFrameLayerAndroid* 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 (parentIframeLayer) { - viewport = SkRect::MakeXYWH(parentIframeLayer->iframeOffset().x(), - parentIframeLayer->iframeOffset().y(), - parentIframeLayer->getSize().width(), - parentIframeLayer->getSize().height()); - } + if (parentIframeLayer) + return SkRect::MakeXYWH(parentIframeLayer->iframeOffset().x(), + parentIframeLayer->iframeOffset().y(), + parentIframeLayer->getSize().width(), + parentIframeLayer->getSize().height()); + return aViewport; +} + +// Executed on the UI +IFrameLayerAndroid* FixedPositioning::updatePosition(SkRect aViewport, + IFrameLayerAndroid* parentIframeLayer) +{ + SkRect viewport = getViewport(aViewport, parentIframeLayer); + float w = viewport.width(); float h = viewport.height(); float dx = viewport.fLeft; @@ -101,6 +107,47 @@ void FixedPositioning::dumpLayer(FILE* file, int indentLevel) const writeRect(file, indentLevel + 1, "fixedRect", m_fixedRect); } +BackgroundImagePositioning::BackgroundImagePositioning(LayerAndroid* layer, const BackgroundImagePositioning& position) + : FixedPositioning(layer, position) + , m_repeatX(position.m_repeatX) + , m_repeatY(position.m_repeatY) + , m_nbRepeatX(position.m_nbRepeatX) + , m_nbRepeatY(position.m_nbRepeatY) + , m_offsetX(position.m_offsetX) + , m_offsetY(position.m_offsetY) +{ +} + +// Executed on the UI +IFrameLayerAndroid* BackgroundImagePositioning::updatePosition(SkRect aViewport, + IFrameLayerAndroid* parentIframeLayer) +{ + SkRect viewport = getViewport(aViewport, parentIframeLayer); + + float w = viewport.width() - m_layer->getWidth(); + float h = viewport.height() - m_layer->getHeight(); + float x = 0; + float y = 0; + + if (m_fixedLeft.defined()) + x += m_fixedLeft.calcFloatValue(w); + if (m_fixedTop.defined()) + y += m_fixedTop.calcFloatValue(h); + + m_nbRepeatX = ceilf((viewport.width() / m_layer->getWidth()) + 1); + m_offsetX = ceilf(x / m_layer->getWidth()); + + m_nbRepeatY = ceilf((viewport.height() / m_layer->getHeight()) + 1); + m_offsetY = ceilf(y / m_layer->getHeight()); + + x += viewport.fLeft; + y += viewport.fTop; + + m_layer->setPosition(x, y); + + return parentIframeLayer; +} + } // namespace WebCore #endif // USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebCore/platform/graphics/android/layers/FixedPositioning.h b/Source/WebCore/platform/graphics/android/layers/FixedPositioning.h index 2fa7ae9..e273a25 100644 --- a/Source/WebCore/platform/graphics/android/layers/FixedPositioning.h +++ b/Source/WebCore/platform/graphics/android/layers/FixedPositioning.h @@ -29,6 +29,7 @@ #if USE(ACCELERATED_COMPOSITING) #include "LayerAndroid.h" +#include "Length.h" namespace WebCore { @@ -70,6 +71,23 @@ struct SkLength { return value; } } + + static SkLength convertLength(Length len) + { + SkLength length; + length.type = SkLength::Undefined; + length.value = 0; + if (len.type() == WebCore::Percent) { + length.type = SkLength::Percent; + length.value = len.percent(); + } + if (len.type() == WebCore::Fixed) { + length.type = SkLength::Fixed; + length.value = len.value(); + } + return length; + } + }; class FixedPositioning { @@ -79,6 +97,11 @@ public: FixedPositioning(LayerAndroid* layer, const FixedPositioning& position); virtual ~FixedPositioning() {}; + virtual bool isBackgroundImagePositioning() { return true; } + virtual FixedPositioning* copy(LayerAndroid* layer) const { + return new FixedPositioning(layer, *this); + } + void setFixedPosition(SkLength left, // CSS left property SkLength top, // CSS top property SkLength right, // CSS right property @@ -101,8 +124,9 @@ public: m_renderLayerPos = renderLayerPos; } - IFrameLayerAndroid* updatePosition(SkRect viewPort, - IFrameLayerAndroid* parentIframeLayer); + SkRect getViewport(SkRect viewport, IFrameLayerAndroid* parentIframeLayer); + virtual IFrameLayerAndroid* updatePosition(SkRect viewPort, + IFrameLayerAndroid* parentIframeLayer); void contentDraw(SkCanvas* canvas, Layer::PaintStyle style); @@ -112,7 +136,7 @@ public: friend void android::serializeLayer(LayerAndroid* layer, SkWStream* stream); friend LayerAndroid* android::deserializeLayer(int version, SkStream* stream); -private: +protected: LayerAndroid* m_layer; SkLength m_fixedLeft; @@ -130,6 +154,48 @@ private: IntPoint m_renderLayerPos; }; +class BackgroundImagePositioning : public FixedPositioning { +public: + BackgroundImagePositioning(LayerAndroid* layer) + : FixedPositioning(layer) + , m_repeatX(false) + , m_repeatY(false) + , m_nbRepeatX(0) + , m_nbRepeatY(0) + , m_offsetX(0) + , m_offsetY(0) + {} + BackgroundImagePositioning(LayerAndroid* layer, const BackgroundImagePositioning& position); + virtual bool isBackgroundImagePositioning() { return true; } + virtual FixedPositioning* copy(LayerAndroid* layer) const { + return new BackgroundImagePositioning(layer, *this); + } + void setPosition(SkLength left, SkLength top) { + m_fixedLeft = left; + m_fixedTop = top; + } + virtual IFrameLayerAndroid* updatePosition(SkRect viewPort, + IFrameLayerAndroid* parentIframeLayer); + + // Measures the background image repetition + void setRepeatX(bool repeat) { m_repeatX = repeat; } + void setRepeatY(bool repeat) { m_repeatY = repeat; } + bool repeatX() { return m_repeatX; } + bool repeatY() { return m_repeatY; } + int nbRepeatX() { return m_nbRepeatX; } + int offsetX() { return m_offsetX; } + int nbRepeatY() { return m_nbRepeatY; } + int offsetY() { return m_offsetY; } + +private: + bool m_repeatX; + bool m_repeatY; + int m_nbRepeatX; + int m_nbRepeatY; + int m_offsetX; + int m_offsetY; +}; + } #endif // USE(ACCELERATED_COMPOSITING) diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp index aef53a2..2deeede 100644 --- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.cpp @@ -113,7 +113,7 @@ LayerAndroid::LayerAndroid(const LayerAndroid& layer) : Layer(layer), m_anchorPointZ = layer.m_anchorPointZ; if (layer.m_fixedPosition) { - m_fixedPosition = new FixedPositioning(this, *layer.m_fixedPosition); + m_fixedPosition = layer.m_fixedPosition->copy(this); Layer::setShouldInheritFromRootTransform(true); } @@ -775,7 +775,7 @@ IntRect LayerAndroid::fullContentArea() IntRect LayerAndroid::visibleContentArea(bool force3dContentVisible) { IntRect area = fullContentArea(); - if (subclassType() == LayerAndroid::FixedBackgroundBaseLayer) + if (subclassType() == LayerAndroid::FixedBackgroundImageLayer) return area; // If transform isn't limited to 2D space, return the entire content area. diff --git a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h index b6e5e5b..3bab5ab 100644 --- a/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h +++ b/Source/WebCore/platform/graphics/android/layers/LayerAndroid.h @@ -95,7 +95,7 @@ public: typedef enum { StandardLayer, ScrollableLayer, IFrameLayer, IFrameContentLayer, FixedBackgroundLayer, - FixedBackgroundBaseLayer, + FixedBackgroundImageLayer, ForegroundBaseLayer, CanvasLayer, BaseLayer } SubclassType; typedef enum { InvalidateNone = 0, InvalidateLayers } InvalidateFlags; @@ -113,8 +113,8 @@ public: return "IFrameContentLayer"; case LayerAndroid::FixedBackgroundLayer: return "FixedBackgroundLayer"; - case LayerAndroid::FixedBackgroundBaseLayer: - return "FixedBackgroundBaseLayer"; + case LayerAndroid::FixedBackgroundImageLayer: + return "FixedBackgroundImageLayer"; case LayerAndroid::ForegroundBaseLayer: return "ForegroundBaseLayer"; case LayerAndroid::CanvasLayer: @@ -315,15 +315,22 @@ private: bool m_backfaceVisibility; bool m_visible; +protected: SkColor m_backgroundColor; +private: + bool m_preserves3D; float m_anchorPointZ; float m_drawOpacity; bool m_isPositionAbsolute; + +protected: FixedPositioning* m_fixedPosition; +private: + typedef HashMap, RefPtr > KeyframesMap; KeyframesMap m_animations; @@ -345,8 +352,12 @@ private: // We do this as if the layer only contains an image, directly compositing // it is a much faster method than using m_content. LayerContent* m_content; + +protected: unsigned m_imageCRC; +private: + // used to signal the framework we need a repaint bool m_hasRunningAnimations; diff --git a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp index 2ec78d2..2819baa 100644 --- a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.cpp @@ -228,7 +228,8 @@ bool ImageTexture::paint(SkCanvas* canvas) return true; } -void ImageTexture::drawGL(LayerAndroid* layer, float opacity) +void ImageTexture::drawGL(LayerAndroid* layer, + float opacity, FloatPoint* offset) { if (!layer) return; @@ -241,7 +242,10 @@ void ImageTexture::drawGL(LayerAndroid* layer, float opacity) if (m_tileGrid) { bool force3dContentVisible = true; IntRect visibleContentArea = m_layer->visibleContentArea(force3dContentVisible); - m_tileGrid->drawGL(visibleContentArea, opacity, transform()); + const TransformationMatrix* transformation = transform(); + if (offset) + m_layerMatrix.translate(offset->x(), offset->y()); + m_tileGrid->drawGL(visibleContentArea, opacity, transformation); } m_layer = 0; } diff --git a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.h b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.h index fccbb78..0571b83 100644 --- a/Source/WebCore/platform/graphics/android/rendering/ImageTexture.h +++ b/Source/WebCore/platform/graphics/android/rendering/ImageTexture.h @@ -74,7 +74,7 @@ public: virtual ~ImageTexture(); bool prepareGL(GLWebViewState*); - void drawGL(LayerAndroid* layer, float opacity); + void drawGL(LayerAndroid* layer, float opacity, FloatPoint* offset = 0); void drawCanvas(SkCanvas*, SkRect&); bool hasContentToShow(); SkBitmap* bitmap() { return m_image; } diff --git a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp index 173b8af..7dd16dc 100644 --- a/Source/WebCore/platform/graphics/android/rendering/Surface.cpp +++ b/Source/WebCore/platform/graphics/android/rendering/Surface.cpp @@ -231,7 +231,7 @@ bool Surface::drawGL(bool layerTilesDisabled) return false; bool isBaseLayer = isBase() - || getFirstLayer()->subclassType() == LayerAndroid::FixedBackgroundBaseLayer + || getFirstLayer()->subclassType() == LayerAndroid::FixedBackgroundImageLayer || getFirstLayer()->subclassType() == LayerAndroid::ForegroundBaseLayer; if (!isBaseLayer) { -- cgit v1.1