Adding resized image caching for Skia.
authordimich@chromium.org <dimich@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 May 2010 20:36:05 +0000 (20:36 +0000)
committerdimich@chromium.org <dimich@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 May 2010 20:36:05 +0000 (20:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=39085

Patch by Sergey Ulanov <sergeyu@chromium.org> on 2010-05-14
Reviewed by Dmitry Titov and Brett Wilson.

Tests: HTML5 video on YouTube.

* platform/graphics/skia/ImageSkia.cpp:
(WebCore::Image::drawPattern): Use bitmap->resizedBitmap() to cache resized image when possible.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@59487 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/graphics/skia/ImageSkia.cpp

index ff24ec9..94729e8 100644 (file)
@@ -1,3 +1,15 @@
+2010-05-14  Sergey Ulanov  <sergeyu@chromium.org>
+
+        Reviewed by Dmitry Titov and Brett Wilson.
+
+        Adding resized image caching for Skia.
+        https://bugs.webkit.org/show_bug.cgi?id=39085
+
+        Tests: HTML5 video on YouTube.
+
+        * platform/graphics/skia/ImageSkia.cpp:
+        (WebCore::Image::drawPattern): Use bitmap->resizedBitmap() to cache resized image when possible.
+
 2010-05-14  Alexey Proskuryakov  <ap@apple.com>
 
         Reviewed by Brady Eidson.
index b1bfbdd..21ba934 100644 (file)
@@ -346,10 +346,19 @@ void Image::drawPattern(GraphicsContext* context,
 
     if (resampling == RESAMPLE_AWESOME) {
         // Do nice resampling.
-        SkBitmap resampled = skia::ImageOperations::Resize(srcSubset,
-            skia::ImageOperations::RESIZE_LANCZOS3,
-            static_cast<int>(destBitmapWidth),
-            static_cast<int>(destBitmapHeight));
+        SkBitmap resampled;
+        int width = static_cast<int>(destBitmapWidth);
+        int height = static_cast<int>(destBitmapHeight);
+        if (!srcRect.fLeft && !srcRect.fTop
+            && srcRect.fRight == bitmap->width() && srcRect.fBottom == bitmap->height()
+            && (bitmap->hasResizedBitmap(width, height)
+                || bitmap->shouldCacheResampling(width, height, width, height))) {
+            // resizedBitmap() caches resized image.
+            resampled = bitmap->resizedBitmap(width, height);
+        } else {
+            resampled = skia::ImageOperations::Resize(srcSubset,
+                skia::ImageOperations::RESIZE_LANCZOS3, width, height);
+        }
         shader = SkShader::CreateBitmapShader(resampled, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode);
 
         // Since we just resized the bitmap, we need to undo the scale set in