summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-14 15:57:30 +0000
committeralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-14 15:57:30 +0000
commitc74f990ca18f0e83b310b431e54b316c0015e0bc (patch)
tree647ff77751361417e765e66357a4cdfe2b8252d4
parentf5401be48055a57c6538215b17b4868a3b7fc092 (diff)
downloadchromium_src-c74f990ca18f0e83b310b431e54b316c0015e0bc.zip
chromium_src-c74f990ca18f0e83b310b431e54b316c0015e0bc.tar.gz
chromium_src-c74f990ca18f0e83b310b431e54b316c0015e0bc.tar.bz2
Refactored PaintSadPlugin to just use SkCanvas API to paint the sad plugin bitmap. This is in preparation for doing accelerated page drawing.
Note that CG port still uses a temporary canvas and uses CG native context. Review URL: http://codereview.chromium.org/7044112 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88999 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/DEPS1
-rw-r--r--webkit/plugins/sad_plugin.cc42
2 files changed, 22 insertions, 21 deletions
diff --git a/webkit/DEPS b/webkit/DEPS
index b1db55e..e6a4621 100644
--- a/webkit/DEPS
+++ b/webkit/DEPS
@@ -9,6 +9,7 @@ include_rules = [
# For bridge/c/c_utility.h in npruntime_util.cc
"+bridge",
"+grit", # For generated headers
+ "+skia",
"+third_party/sqlite",
"+third_party/tcmalloc",
"+ui/gfx",
diff --git a/webkit/plugins/sad_plugin.cc b/webkit/plugins/sad_plugin.cc
index b85d48a..a850ee8 100644
--- a/webkit/plugins/sad_plugin.cc
+++ b/webkit/plugins/sad_plugin.cc
@@ -4,10 +4,11 @@
#include "webkit/plugins/sad_plugin.h"
-#include "third_party/skia/include/core/SkPaint.h"
-#include "third_party/skia/include/core/SkScalar.h"
+#include <algorithm>
+
+#include "base/memory/scoped_ptr.h"
+#include "skia/ext/platform_canvas.h"
#include "ui/gfx/blit.h"
-#include "ui/gfx/canvas_skia.h"
#include "ui/gfx/rect.h"
namespace webkit {
@@ -15,35 +16,34 @@ namespace webkit {
void PaintSadPlugin(WebKit::WebCanvas* webcanvas,
const gfx::Rect& plugin_rect,
const SkBitmap& sad_plugin_bitmap) {
- // Make a temporary canvas for the background image.
const int width = plugin_rect.width();
const int height = plugin_rect.height();
- gfx::CanvasSkia canvas(width, height, false);
-#if defined(OS_MACOSX)
+
+#if WEBKIT_USING_SKIA
+ SkCanvas* canvas = webcanvas;
+#elif WEBKIT_USING_CG
+ // Make a temporary canvas for the background image.
+ scoped_ptr<SkCanvas> canvas(skia::CreateBitmapCanvas(width, height, false));
// Flip the canvas, since the context expects flipped data.
- canvas.translate(0, height);
- canvas.scale(1, -1);
+ canvas->translate(0, height);
+ canvas->scale(1, -1);
#endif
- SkPaint paint;
+ SkPaint paint;
paint.setStyle(SkPaint::kFill_Style);
paint.setColor(SK_ColorBLACK);
- canvas.drawRectCoords(0, 0, SkIntToScalar(width), SkIntToScalar(height),
- paint);
- canvas.DrawBitmapInt(sad_plugin_bitmap,
- std::max(0, (width - sad_plugin_bitmap.width()) / 2),
- std::max(0, (height - sad_plugin_bitmap.height()) / 2));
+ canvas->drawRectCoords(0, 0, SkIntToScalar(width), SkIntToScalar(height),
+ paint);
+ canvas->drawBitmap(
+ sad_plugin_bitmap,
+ SkIntToScalar(std::max(0, (width - sad_plugin_bitmap.width()) / 2)),
+ SkIntToScalar(std::max(0, (height - sad_plugin_bitmap.height()) / 2)));
// It's slightly less code to make a big SkBitmap of the sad tab image and
// then copy that to the screen than to use the native APIs. The small speed
// penalty is not important when drawing crashed plugins.
-#if WEBKIT_USING_SKIA
- skia::ScopedPlatformPaint scoped_platform_paint(webcanvas);
- gfx::NativeDrawingContext context =
- scoped_platform_paint.GetPlatformSurface();
- BlitCanvasToContext(context, plugin_rect, &canvas, gfx::Point(0, 0));
-#elif WEBKIT_USING_CG
- BlitCanvasToContext(webcanvas, plugin_rect, &canvas, gfx::Point(0, 0));
+#if WEBKIT_USING_CG
+ BlitCanvasToContext(webcanvas, plugin_rect, canvas.get(), gfx::Point(0, 0));
#endif
}