summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/graphics/chromium/ImageLayerChromium.cpp')
-rw-r--r--WebCore/platform/graphics/chromium/ImageLayerChromium.cpp45
1 files changed, 24 insertions, 21 deletions
diff --git a/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp b/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
index adcbb82..cd299c1 100644
--- a/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
+++ b/WebCore/platform/graphics/chromium/ImageLayerChromium.cpp
@@ -36,6 +36,7 @@
#include "Image.h"
#include "LayerRendererChromium.h"
+#include "LayerTexture.h"
#if PLATFORM(SKIA)
#include "NativeImageSkia.h"
@@ -71,7 +72,7 @@ void ImageLayerChromium::setContents(Image* contents)
setNeedsDisplay();
}
-void ImageLayerChromium::updateContents()
+void ImageLayerChromium::updateContentsIfDirty()
{
ASSERT(layerRenderer());
@@ -79,12 +80,11 @@ void ImageLayerChromium::updateContents()
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::updateContents();
+ ContentLayerChromium::updateContentsIfDirty();
return;
}
void* pixels = 0;
- IntSize requiredTextureSize;
IntSize bitmapSize;
NativeImagePtr nativeImage = m_contents->nativeImageForCurrentFrame();
@@ -93,22 +93,33 @@ void ImageLayerChromium::updateContents()
// The layer contains an Image.
NativeImageSkia* skiaImage = static_cast<NativeImageSkia*>(nativeImage);
const SkBitmap* skiaBitmap = skiaImage;
- requiredTextureSize = IntSize(skiaBitmap->width(), skiaBitmap->height());
+ bitmapSize = IntSize(skiaBitmap->width(), skiaBitmap->height());
ASSERT(skiaBitmap);
+#elif PLATFORM(CG)
+ // NativeImagePtr is a CGImageRef on Mac OS X.
+ int width = CGImageGetWidth(nativeImage);
+ int height = CGImageGetHeight(nativeImage);
+ bitmapSize = IntSize(width, height);
+#endif
+
+ // Clip the dirty rect to the bitmap dimensions.
+ IntRect dirtyRect(m_dirtyRect);
+ dirtyRect.intersect(IntRect(IntPoint(0, 0), bitmapSize));
+
+ if (!m_contentsTexture || !m_contentsTexture->isValid(bitmapSize, GraphicsContext3D::RGBA))
+ dirtyRect = IntRect(IntPoint(0, 0), bitmapSize);
+ else if (!m_contentsDirty) {
+ m_contentsTexture->reserve(bitmapSize, GraphicsContext3D::RGBA);
+ return;
+ }
+#if PLATFORM(SKIA)
SkAutoLockPixels lock(*skiaBitmap);
SkBitmap::Config skiaConfig = skiaBitmap->config();
// FIXME: do we need to support more image configurations?
- if (skiaConfig == SkBitmap::kARGB_8888_Config) {
+ if (skiaConfig == SkBitmap::kARGB_8888_Config)
pixels = skiaBitmap->getPixels();
- bitmapSize = IntSize(skiaBitmap->width(), skiaBitmap->height());
- }
#elif PLATFORM(CG)
- // NativeImagePtr is a CGImageRef on Mac OS X.
- int width = CGImageGetWidth(nativeImage);
- int height = CGImageGetHeight(nativeImage);
- requiredTextureSize = IntSize(width, height);
- bitmapSize = requiredTextureSize;
// FIXME: we should get rid of this temporary copy where possible.
int tempRowBytes = width * 4;
Vector<uint8_t> tempVector;
@@ -145,16 +156,8 @@ void ImageLayerChromium::updateContents()
#error "Need to implement for your platform."
#endif
- unsigned textureId = m_contentsTexture;
- if (!textureId)
- textureId = layerRenderer()->createLayerTexture();
-
- // Clip the dirty rect to the bitmap dimensions.
- IntRect dirtyRect(m_dirtyRect);
- dirtyRect.intersect(IntRect(IntPoint(0, 0), bitmapSize));
-
if (pixels)
- updateTextureRect(pixels, bitmapSize, requiredTextureSize, dirtyRect, textureId);
+ updateTextureRect(pixels, bitmapSize, dirtyRect);
}
}