summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--skia/ext/canvas_paint_linux.h4
-rw-r--r--skia/ext/platform_canvas.cc23
-rw-r--r--skia/ext/platform_device.cc35
-rw-r--r--skia/ext/platform_device.h20
-rw-r--r--ui/gfx/canvas_skia_win.cc29
-rw-r--r--ui/views/widget/native_widget_win.cc2
6 files changed, 34 insertions, 79 deletions
diff --git a/skia/ext/canvas_paint_linux.h b/skia/ext/canvas_paint_linux.h
index 608350f..fca12ca 100644
--- a/skia/ext/canvas_paint_linux.h
+++ b/skia/ext/canvas_paint_linux.h
@@ -1,5 +1,5 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -92,7 +92,7 @@ class CanvasPaintT : public T {
// surface.
T::translate(-SkIntToScalar(bounds.x), -SkIntToScalar(bounds.y));
- context_ = BeginPlatformPaint(GetTopDevice(*this));
+ context_ = BeginPlatformPaint(this);
}
cairo_t* context_;
diff --git a/skia/ext/platform_canvas.cc b/skia/ext/platform_canvas.cc
index c6fd17e..2a50ede 100644
--- a/skia/ext/platform_canvas.cc
+++ b/skia/ext/platform_canvas.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -47,24 +47,35 @@ SkDevice* GetTopDevice(const SkCanvas& canvas) {
bool SupportsPlatformPaint(const SkCanvas* canvas) {
// TODO(alokp): Rename IsNativeFontRenderingAllowed after removing these
// calls from WebKit.
- return IsNativeFontRenderingAllowed(GetTopDevice(*canvas));
+ PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas));
+ return platform_device && platform_device->IsNativeFontRenderingAllowed();
}
PlatformSurface BeginPlatformPaint(SkCanvas* canvas) {
- return BeginPlatformPaint(GetTopDevice(*canvas));
+ PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas));
+ if (platform_device)
+ return platform_device->BeginPlatformPaint();
+
+ return 0;
}
void EndPlatformPaint(SkCanvas* canvas) {
- EndPlatformPaint(GetTopDevice(*canvas));
+ PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas));
+ if (platform_device)
+ platform_device->EndPlatformPaint();
}
void DrawToNativeContext(SkCanvas* canvas, PlatformSurface context, int x,
int y, const PlatformRect* src_rect) {
- DrawToNativeContext(GetTopDevice(*canvas), context, x, y, src_rect);
+ PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas));
+ if (platform_device)
+ platform_device->DrawToNativeContext(context, x, y, src_rect);
}
void MakeOpaque(SkCanvas* canvas, int x, int y, int width, int height) {
- MakeOpaque(GetTopDevice(*canvas), x, y, width, height);
+ PlatformDevice* platform_device = GetPlatformDevice(GetTopDevice(*canvas));
+ if (platform_device)
+ platform_device->MakeOpaque(x, y, width, height);
}
} // namespace skia
diff --git a/skia/ext/platform_device.cc b/skia/ext/platform_device.cc
index a08f525..4bfde0f 100644
--- a/skia/ext/platform_device.cc
+++ b/skia/ext/platform_device.cc
@@ -27,40 +27,5 @@ PlatformDevice* GetPlatformDevice(SkDevice* device) {
return NULL;
}
-PlatformSurface BeginPlatformPaint(SkDevice* device) {
- PlatformDevice* platform_device = GetPlatformDevice(device);
- if (platform_device)
- return platform_device->BeginPlatformPaint();
-
- return 0;
-}
-
-void EndPlatformPaint(SkDevice* device) {
- PlatformDevice* platform_device = GetPlatformDevice(device);
- if (platform_device)
- return platform_device->EndPlatformPaint();
-}
-
-bool IsNativeFontRenderingAllowed(SkDevice* device) {
- PlatformDevice* platform_device = GetPlatformDevice(device);
- if (platform_device)
- return platform_device->IsNativeFontRenderingAllowed();
-
- return false;
-}
-
-void DrawToNativeContext(SkDevice* device, PlatformSurface context,
- int x, int y, const PlatformRect* src_rect) {
- PlatformDevice* platform_device = GetPlatformDevice(device);
- if (platform_device)
- platform_device->DrawToNativeContext(context, x, y, src_rect);
-}
-
-void MakeOpaque(SkDevice* device, int x, int y, int width, int height) {
- PlatformDevice* platform_device = GetPlatformDevice(device);
- if (platform_device)
- platform_device->MakeOpaque(x, y, width, height);
-}
-
} // namespace skia
diff --git a/skia/ext/platform_device.h b/skia/ext/platform_device.h
index d6683788..81e475d 100644
--- a/skia/ext/platform_device.h
+++ b/skia/ext/platform_device.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -59,24 +59,6 @@ SK_API void SetPlatformDevice(SkDevice* device,
PlatformDevice* platform_device);
SK_API PlatformDevice* GetPlatformDevice(SkDevice* device);
-// Returns if the native font rendering engine is allowed to render text to
-// this device.
-SK_API bool IsNativeFontRenderingAllowed(SkDevice* device);
-
-// Returns the PlatformSurface used for native rendering into the device.
-SK_API PlatformSurface BeginPlatformPaint(SkDevice* device);
-
-// Finish a previous call to BeginPlatformPaint.
-SK_API void EndPlatformPaint(SkDevice* device);
-
-// Draws to the given PlatformSurface, |context|. Forwards to the
-// PlatformDevice bound to |device|. Otherwise is a NOP.
-SK_API void DrawToNativeContext(SkDevice* device, PlatformSurface context,
- int x, int y, const PlatformRect* src_rect);
-
-// Sets the opacity of each pixel in the specified region to be opaque.
-SK_API void MakeOpaque(SkDevice* device, int x, int y, int width, int height);
-
} // namespace skia
#if defined(WIN32)
diff --git a/ui/gfx/canvas_skia_win.cc b/ui/gfx/canvas_skia_win.cc
index 67491fa..76fe318 100644
--- a/ui/gfx/canvas_skia_win.cc
+++ b/ui/gfx/canvas_skia_win.cc
@@ -164,14 +164,15 @@ void FadeBitmapRect(SkDevice& bmp_device,
// this function draws black on white. It then uses the intensity of black
// to determine how much alpha to use. The text is drawn in |gfx_text_rect| and
// clipped to |gfx_draw_rect|.
-void DrawTextAndClearBackground(SkDevice& bmp_device,
+void DrawTextAndClearBackground(SkCanvas* bmp_canvas,
HFONT font,
COLORREF text_color,
const string16& text,
int flags,
const gfx::Rect& gfx_text_rect,
const gfx::Rect& gfx_draw_rect) {
- HDC hdc = skia::BeginPlatformPaint(&bmp_device);
+ skia::ScopedPlatformPaint scoped_platform_paint(bmp_canvas);
+ HDC hdc = scoped_platform_paint.GetPlatformSurface();
// Clear the background by filling with white.
HBRUSH fill_brush = static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH));
@@ -199,7 +200,7 @@ void DrawTextAndClearBackground(SkDevice& bmp_device,
BYTE text_color_g = GetGValue(text_color);
BYTE text_color_b = GetBValue(text_color);
- SkBitmap bmp = bmp_device.accessBitmap(true);
+ SkBitmap bmp = bmp_canvas->getTopDevice()->accessBitmap(true);
DCHECK_EQ(SkBitmap::kARGB_8888_Config, bmp.config());
SkAutoLockPixels lock(bmp);
@@ -217,15 +218,13 @@ void DrawTextAndClearBackground(SkDevice& bmp_device,
SkColorSetARGB(alpha, text_color_r, text_color_g, text_color_b));
}
}
-
- skia::EndPlatformPaint(&bmp_device);
}
// Draws the given text with a fade out gradient. |bmp_device| is a bitmap
// that is used to temporary drawing. The text is drawn in |text_rect| and
// clipped to |draw_rect|.
void DrawTextGradientPart(HDC hdc,
- SkDevice& bmp_device,
+ SkCanvas* bmp_canvas,
const string16& text,
const SkColor& color,
HFONT font,
@@ -233,16 +232,16 @@ void DrawTextGradientPart(HDC hdc,
const gfx::Rect& draw_rect,
bool fade_to_right,
int flags) {
- DrawTextAndClearBackground(bmp_device, font, skia::SkColorToCOLORREF(color),
+ DrawTextAndClearBackground(bmp_canvas, font, skia::SkColorToCOLORREF(color),
text, flags, text_rect, draw_rect);
- FadeBitmapRect(bmp_device, draw_rect, fade_to_right);
+ FadeBitmapRect(*bmp_canvas->getTopDevice(), draw_rect, fade_to_right);
BLENDFUNCTION blend = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA};
- HDC bmp_hdc = skia::BeginPlatformPaint(&bmp_device);
+ skia::ScopedPlatformPaint scoped_platform_paint(bmp_canvas);
+ HDC bmp_hdc = scoped_platform_paint.GetPlatformSurface();
AlphaBlend(hdc, draw_rect.x(), draw_rect.y(), draw_rect.width(),
draw_rect.height(), bmp_hdc, draw_rect.x(), draw_rect.y(),
draw_rect.width(), draw_rect.height(), blend);
- skia::EndPlatformPaint(&bmp_device);
}
enum PrimarySide {
@@ -557,20 +556,18 @@ void CanvasSkia::DrawFadeTruncatingString(
text_rect.set_width(text_rect.width() + offset_x);
// Create a temporary bitmap to draw the gradient to.
- scoped_ptr<SkDevice> gradient_bitmap(
- skia::BitmapPlatformDevice::create(
- display_rect.width(), display_rect.height(), false, NULL));
- DCHECK(gradient_bitmap.get());
+ scoped_ptr<SkCanvas> gradient_canvas(skia::CreateBitmapCanvas(
+ display_rect.width(), display_rect.height(), false));
{
skia::ScopedPlatformPaint scoped_platform_paint(this);
HDC hdc = scoped_platform_paint.GetPlatformSurface();
if (is_truncating_head)
- DrawTextGradientPart(hdc, *gradient_bitmap, text, color,
+ DrawTextGradientPart(hdc, gradient_canvas.get(), text, color,
font.GetNativeFont(), text_rect, head_part, is_rtl,
flags);
if (is_truncating_tail)
- DrawTextGradientPart(hdc, *gradient_bitmap, text, color,
+ DrawTextGradientPart(hdc, gradient_canvas.get(), text, color,
font.GetNativeFont(), text_rect, tail_part, !is_rtl,
flags);
}
diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc
index 4247547..b097cfe 100644
--- a/ui/views/widget/native_widget_win.cc
+++ b/ui/views/widget/native_widget_win.cc
@@ -460,7 +460,7 @@ void NativeWidgetWin::OnPaint(HDC dc) {
GetWindowRect(hwnd(), &wr);
SIZE size = {wr.right - wr.left, wr.bottom - wr.top};
POINT position = {wr.left, wr.top};
- HDC dib_dc = window_contents_->beginPlatformPaint();
+ HDC dib_dc = window_contents_->BeginPlatformPaint();
POINT zero = {0, 0};
BLENDFUNCTION blend = {AC_SRC_OVER, 0, 125, AC_SRC_ALPHA};
UpdateLayeredWindow(hwnd(), NULL, &position, &size, dib_dc, &zero,