diff options
author | Ben Murdoch <benm@google.com> | 2011-06-02 12:07:03 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-10 10:47:21 +0100 |
commit | 2daae5fd11344eaa88a0d92b0f6d65f8d2255c00 (patch) | |
tree | e4964fbd1cb70599f7718ff03e50ea1dab33890b /Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp | |
parent | 87bdf0060a247bfbe668342b87e0874182e0ffa9 (diff) | |
download | external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.zip external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.gz external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.bz2 |
Merge WebKit at r84325: Initial merge by git.
Change-Id: Ic1a909300ecc0a13ddc6b4e784371d2ac6e3d59b
Diffstat (limited to 'Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp')
-rw-r--r-- | Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp | 62 |
1 files changed, 45 insertions, 17 deletions
diff --git a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp index 60c1332..d72fb1e 100644 --- a/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp @@ -34,6 +34,7 @@ #include "ImageLayerChromium.h" +#include "cc/CCLayerImpl.h" #include "Image.h" #include "LayerRendererChromium.h" #include "LayerTexture.h" @@ -47,42 +48,69 @@ PassRefPtr<ImageLayerChromium> ImageLayerChromium::create(GraphicsLayerChromium* ImageLayerChromium::ImageLayerChromium(GraphicsLayerChromium* owner) : ContentLayerChromium(owner) + , m_imageForCurrentFrame(0) , m_contents(0) { } void ImageLayerChromium::setContents(Image* contents) { - // Check if the image has changed. - if (m_contents == contents) + // setContents() currently gets called whenever there is any + // style change that affects the layer even if that change doesn't + // affect the actual contents of the image (e.g. a CSS animation). + // With this check in place we avoid unecessary texture uploads. + if ((m_contents == contents) && (m_contents->nativeImageForCurrentFrame() == m_imageForCurrentFrame)) return; + m_contents = contents; + m_imageForCurrentFrame = m_contents->nativeImageForCurrentFrame(); + m_dirtyRect = IntRect(IntPoint(0, 0), bounds()); setNeedsDisplay(); } -void ImageLayerChromium::paintContentsIfDirty() +void ImageLayerChromium::paintContentsIfDirty(const IntRect&) { ASSERT(layerRenderer()); - // FIXME: Remove this test when tiled layers are implemented. - if (requiresClippedUpdateRect()) { - // Use the base version of updateContents which draws a subset of the - // image to a bitmap, as the pixel contents can't be uploaded directly. - ContentLayerChromium::paintContentsIfDirty(); - return; + if (!m_dirtyRect.isEmpty()) { + m_decodedImage.updateFromImage(m_contents->nativeImageForCurrentFrame()); } - - m_decodedImage.updateFromImage(m_contents->nativeImageForCurrentFrame()); } -void ImageLayerChromium::updateTextureIfNeeded() +void ImageLayerChromium::updateCompositorResources() { - // FIXME: Remove this test when tiled layers are implemented. - if (requiresClippedUpdateRect()) { - ContentLayerChromium::updateTextureIfNeeded(); - return; + updateLayerSize(m_decodedImage.size()); + + IntRect paintRect(IntPoint(0, 0), m_decodedImage.size()); + if (!m_dirtyRect.isEmpty()) { + m_tiler->invalidateRect(paintRect); + m_dirtyRect = IntRect(); } - updateTexture(m_decodedImage.pixels(), m_decodedImage.size()); + m_tiler->updateFromPixels(paintRect, m_decodedImage.pixels()); +} + +IntRect ImageLayerChromium::layerBounds() const +{ + return IntRect(IntPoint(0, 0), m_decodedImage.size()); +} + +TransformationMatrix ImageLayerChromium::tilingTransform() +{ + // Tiler draws from the upper left corner. The draw transform + // specifies the middle of the layer. + TransformationMatrix transform = ccLayerImpl()->drawTransform(); + const IntRect sourceRect = layerBounds(); + const IntSize destSize = bounds(); + + transform.translate(-destSize.width() / 2.0, -destSize.height() / 2.0); + + // Tiler also draws at the original content size, so rescale the original + // image dimensions to the bounds that it is meant to be drawn at. + float scaleX = destSize.width() / static_cast<float>(sourceRect.size().width()); + float scaleY = destSize.height() / static_cast<float>(sourceRect.size().height()); + transform.scale3d(scaleX, scaleY, 1.0f); + + return transform; } } |