summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-20 00:10:13 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-20 00:10:13 +0000
commitfc22f9ef9b459af24ca666e44350d0c8b27b312b (patch)
treeef042cfcc658dc359e2958cdd2d063cf2d4d814a /ui
parente24f876c537646cab5a9e8492658f570ccd7da4a (diff)
downloadchromium_src-fc22f9ef9b459af24ca666e44350d0c8b27b312b.zip
chromium_src-fc22f9ef9b459af24ca666e44350d0c8b27b312b.tar.gz
chromium_src-fc22f9ef9b459af24ca666e44350d0c8b27b312b.tar.bz2
Make CanvasSkia take a gfx::Size as the first parameter.
BUG=100898 R=pkasting@chromium.org TBR=ben@chromium.org,stevenjb@chromium.org Review URL: http://codereview.chromium.org/8990003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115046 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura_shell/launcher/app_launcher_button.cc2
-rw-r--r--ui/base/clipboard/clipboard_gtk.cc4
-rw-r--r--ui/base/clipboard/clipboard_mac.mm2
-rw-r--r--ui/base/clipboard/clipboard_win.cc3
-rw-r--r--ui/gfx/canvas_skia.cc7
-rw-r--r--ui/gfx/canvas_skia.h2
-rw-r--r--ui/gfx/canvas_skia_linux.cc6
-rw-r--r--ui/gfx/canvas_skia_win.cc7
-rw-r--r--ui/gfx/image/image.cc5
-rw-r--r--ui/gfx/render_text_linux.cc2
-rw-r--r--ui/views/controls/glow_hover_controller.cc2
-rw-r--r--ui/views/controls/menu/menu_controller.cc3
-rw-r--r--ui/views/controls/menu/menu_image_util.cc6
-rw-r--r--ui/views/controls/menu/menu_win.cc3
-rw-r--r--ui/views/controls/menu/native_menu_win.cc5
-rw-r--r--ui/views/controls/table/native_table_win.cc7
-rw-r--r--ui/views/controls/table/table_view.cc9
-rw-r--r--ui/views/controls/tree/tree_view.cc2
-rw-r--r--ui/views/drag_utils.cc4
-rw-r--r--ui/views/widget/native_widget_win.cc6
20 files changed, 47 insertions, 40 deletions
diff --git a/ui/aura_shell/launcher/app_launcher_button.cc b/ui/aura_shell/launcher/app_launcher_button.cc
index 6f88b37..b2ee40e 100644
--- a/ui/aura_shell/launcher/app_launcher_button.cc
+++ b/ui/aura_shell/launcher/app_launcher_button.cc
@@ -47,7 +47,7 @@ void AppLauncherButton::SetAppImage(const SkBitmap& image) {
SetImage(BS_NORMAL, &image);
return;
}
- gfx::CanvasSkia canvas(width, height, false);
+ gfx::CanvasSkia canvas(gfx::Size(width, height), false);
canvas.DrawBitmapInt(image, 0, 0, image.width(), image.height(),
0, 0, width, height, false);
SkBitmap resized_image(canvas.ExtractBitmap());
diff --git a/ui/base/clipboard/clipboard_gtk.cc b/ui/base/clipboard/clipboard_gtk.cc
index 7e3a56b..5b6a1a9 100644
--- a/ui/base/clipboard/clipboard_gtk.cc
+++ b/ui/base/clipboard/clipboard_gtk.cc
@@ -509,8 +509,8 @@ SkBitmap Clipboard::ReadImage(Buffer buffer) const {
if (!pixbuf.get())
return SkBitmap();
- gfx::CanvasSkia canvas(gdk_pixbuf_get_width(pixbuf.get()),
- gdk_pixbuf_get_height(pixbuf.get()),
+ gfx::CanvasSkia canvas(gfx::Size(gdk_pixbuf_get_width(pixbuf.get()),
+ gdk_pixbuf_get_height(pixbuf.get())),
false);
{
skia::ScopedPlatformPaint scoped_platform_paint(canvas.sk_canvas());
diff --git a/ui/base/clipboard/clipboard_mac.mm b/ui/base/clipboard/clipboard_mac.mm
index b8e1491..c4671a1 100644
--- a/ui/base/clipboard/clipboard_mac.mm
+++ b/ui/base/clipboard/clipboard_mac.mm
@@ -316,7 +316,7 @@ SkBitmap Clipboard::ReadImage(Buffer buffer) const {
int width = [image size].width;
int height = [image size].height;
- gfx::CanvasSkia canvas(width, height, false);
+ gfx::CanvasSkia canvas(gfx::Size(width, height), false);
{
skia::ScopedPlatformPaint scoped_platform_paint(canvas.sk_canvas());
CGContextRef gc = scoped_platform_paint.GetPlatformSurface();
diff --git a/ui/base/clipboard/clipboard_win.cc b/ui/base/clipboard/clipboard_win.cc
index 79a0faa..66a8233 100644
--- a/ui/base/clipboard/clipboard_win.cc
+++ b/ui/base/clipboard/clipboard_win.cc
@@ -537,7 +537,8 @@ SkBitmap Clipboard::ReadImage(Buffer buffer) const {
const void* bitmap_bits = reinterpret_cast<const char*>(bitmap)
+ bitmap->bmiHeader.biSize + color_table_length * sizeof(RGBQUAD);
- gfx::CanvasSkia canvas(bitmap->bmiHeader.biWidth, bitmap->bmiHeader.biHeight,
+ gfx::CanvasSkia canvas(gfx::Size(bitmap->bmiHeader.biWidth,
+ bitmap->bmiHeader.biHeight),
false);
{
skia::ScopedPlatformPaint scoped_platform_paint(canvas.sk_canvas());
diff --git a/ui/gfx/canvas_skia.cc b/ui/gfx/canvas_skia.cc
index d7c0c0a..6c83d9b 100644
--- a/ui/gfx/canvas_skia.cc
+++ b/ui/gfx/canvas_skia.cc
@@ -48,8 +48,9 @@ namespace gfx {
////////////////////////////////////////////////////////////////////////////////
// CanvasSkia, public:
-CanvasSkia::CanvasSkia(int width, int height, bool is_opaque)
- : owned_canvas_(new skia::PlatformCanvas(width, height, is_opaque)),
+CanvasSkia::CanvasSkia(const gfx::Size& size, bool is_opaque)
+ : owned_canvas_(new skia::PlatformCanvas(size.width(), size.height(),
+ is_opaque)),
canvas_(owned_canvas_.get()) {
}
@@ -387,7 +388,7 @@ Canvas* Canvas::CreateCanvas() {
}
Canvas* Canvas::CreateCanvas(const gfx::Size& size, bool is_opaque) {
- return new CanvasSkia(size.width(), size.height(), is_opaque);
+ return new CanvasSkia(size, is_opaque);
}
#if defined(OS_WIN) && !defined(USE_AURA)
diff --git a/ui/gfx/canvas_skia.h b/ui/gfx/canvas_skia.h
index ac49010..57c58ac 100644
--- a/ui/gfx/canvas_skia.h
+++ b/ui/gfx/canvas_skia.h
@@ -48,7 +48,7 @@ class UI_EXPORT CanvasSkia : public Canvas {
// canvas.
CanvasSkia();
- CanvasSkia(int width, int height, bool is_opaque);
+ CanvasSkia(const gfx::Size& size, bool is_opaque);
explicit CanvasSkia(SkCanvas* canvas);
virtual ~CanvasSkia();
diff --git a/ui/gfx/canvas_skia_linux.cc b/ui/gfx/canvas_skia_linux.cc
index 2d47ff2..fcba08d 100644
--- a/ui/gfx/canvas_skia_linux.cc
+++ b/ui/gfx/canvas_skia_linux.cc
@@ -117,9 +117,9 @@ void DrawStringContext::Draw(const SkColor& text_color) {
void DrawStringContext::DrawWithHalo(const SkColor& text_color,
const SkColor& halo_color) {
- gfx::CanvasSkia text_canvas(bounds_.width() + 2, bounds_.height() + 2, false);
- text_canvas.FillRect(static_cast<SkColor>(0),
- gfx::Rect(0, 0, bounds_.width() + 2, bounds_.height() + 2));
+ gfx::Size size(bounds_.width() + 2, bounds_.height() + 2);
+ gfx::CanvasSkia text_canvas(size, false);
+ text_canvas.FillRect(static_cast<SkColor>(0), gfx::Rect(gfx::Point(), size));
{
skia::ScopedPlatformPaint scoped_platform_paint(text_canvas.sk_canvas());
diff --git a/ui/gfx/canvas_skia_win.cc b/ui/gfx/canvas_skia_win.cc
index 949a056..80a5693 100644
--- a/ui/gfx/canvas_skia_win.cc
+++ b/ui/gfx/canvas_skia_win.cc
@@ -415,10 +415,11 @@ void CanvasSkia::DrawStringWithHalo(const string16& text,
// Create a temporary buffer filled with the halo color. It must leave room
// for the 1-pixel border around the text.
- CanvasSkia text_canvas(w + 2, h + 2, true);
+ gfx::Size size(w + 2, h + 2);
+ CanvasSkia text_canvas(size, true);
SkPaint bkgnd_paint;
bkgnd_paint.setColor(halo_color);
- text_canvas.DrawRect(gfx::Rect(0, 0, w + 2, h + 2), bkgnd_paint);
+ text_canvas.DrawRect(gfx::Rect(gfx::Point(), size), bkgnd_paint);
// Draw the text into the temporary buffer. This will have correct
// ClearType since the background color is the same as the halo color.
@@ -428,7 +429,7 @@ void CanvasSkia::DrawStringWithHalo(const string16& text,
// opaque. We have to do this first since pixelShouldGetHalo will check for
// 0 to see if a pixel has been modified to transparent, and black text that
// Windows draw will look transparent to it!
- skia::MakeOpaque(text_canvas.sk_canvas(), 0, 0, w + 2, h + 2);
+ skia::MakeOpaque(text_canvas.sk_canvas(), 0, 0, size.width(), size.height());
uint32_t halo_premul = SkPreMultiplyColor(halo_color);
SkBitmap& text_bitmap = const_cast<SkBitmap&>(
diff --git a/ui/gfx/image/image.cc b/ui/gfx/image/image.cc
index f14b9ec..05621bf 100644
--- a/ui/gfx/image/image.cc
+++ b/ui/gfx/image/image.cc
@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "base/stl_util.h"
#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/gfx/size.h"
#if defined(TOOLKIT_USES_GTK)
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -33,8 +34,8 @@ bool NSImageToSkBitmaps(NSImage* image, std::vector<const SkBitmap*>* bitmaps);
#if defined(TOOLKIT_USES_GTK)
const SkBitmap* GdkPixbufToSkBitmap(GdkPixbuf* pixbuf) {
- gfx::CanvasSkia canvas(gdk_pixbuf_get_width(pixbuf),
- gdk_pixbuf_get_height(pixbuf),
+ gfx::CanvasSkia canvas(gfx::Size(gdk_pixbuf_get_width(pixbuf),
+ gdk_pixbuf_get_height(pixbuf)),
/*is_opaque=*/false);
canvas.DrawGdkPixbuf(pixbuf, 0, 0);
return new SkBitmap(canvas.ExtractBitmap());
diff --git a/ui/gfx/render_text_linux.cc b/ui/gfx/render_text_linux.cc
index 9a17ab4..a81f050 100644
--- a/ui/gfx/render_text_linux.cc
+++ b/ui/gfx/render_text_linux.cc
@@ -238,7 +238,7 @@ void RenderTextLinux::UpdateLayout() {
void RenderTextLinux::EnsureLayout() {
if (layout_ == NULL) {
- CanvasSkia canvas(display_rect().width(), display_rect().height(), false);
+ CanvasSkia canvas(display_rect().size(), false);
skia::ScopedPlatformPaint scoped_platform_paint(canvas.sk_canvas());
cairo_t* cr = scoped_platform_paint.GetPlatformSurface();
diff --git a/ui/views/controls/glow_hover_controller.cc b/ui/views/controls/glow_hover_controller.cc
index 49ec068..1306c88 100644
--- a/ui/views/controls/glow_hover_controller.cc
+++ b/ui/views/controls/glow_hover_controller.cc
@@ -69,7 +69,7 @@ void GlowHoverController::Draw(gfx::Canvas* canvas,
return;
// Draw a radial gradient to hover_canvas.
- gfx::CanvasSkia hover_canvas(view_->width(), view_->height(), false);
+ gfx::CanvasSkia hover_canvas(view_->size(), false);
// Draw a radial gradient to hover_canvas.
int radius = view_->width() / 3;
diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc
index b0c80de..8a6e5c5 100644
--- a/ui/views/controls/menu/menu_controller.cc
+++ b/ui/views/controls/menu/menu_controller.cc
@@ -477,8 +477,7 @@ void MenuController::OnMouseDragged(SubmenuView* source,
gfx::Point press_loc(press_pt_);
View::ConvertPointToScreen(source->GetScrollViewContainer(), &press_loc);
View::ConvertPointToView(NULL, item, &press_loc);
- // TODO(beng): Convert to CanvasSkia
- gfx::CanvasSkia canvas(item->width(), item->height(), false);
+ gfx::CanvasSkia canvas(gfx::Size(item->width(), item->height()), false);
item->PaintButton(&canvas, MenuItemView::PB_FOR_DRAG);
OSExchangeData data;
diff --git a/ui/views/controls/menu/menu_image_util.cc b/ui/views/controls/menu/menu_image_util.cc
index 061b3f5..ee71c69 100644
--- a/ui/views/controls/menu/menu_image_util.cc
+++ b/ui/views/controls/menu/menu_image_util.cc
@@ -10,6 +10,7 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas_skia.h"
#include "ui/gfx/point.h"
+#include "ui/gfx/size.h"
namespace {
@@ -29,7 +30,8 @@ const SkColor kIndicatorStroke = SkColorSetRGB(0, 0, 0);
SkBitmap* CreateRadioButtonImage(bool selected) {
// + 2 (1px on each side) to cover rounding error.
- gfx::CanvasSkia canvas(kIndicatorSize + 2, kIndicatorSize + 2, false);
+ gfx::CanvasSkia canvas(gfx::Size(kIndicatorSize + 2, kIndicatorSize + 2),
+ false);
canvas.Translate(gfx::Point(1, 1));
SkPoint gradient_points[3];
@@ -88,7 +90,7 @@ SkBitmap* GetRtlSubmenuArrowImage() {
if (!kRtlArrow) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
SkBitmap* r = rb.GetBitmapNamed(IDR_MENU_ARROW);
- gfx::CanvasSkia canvas(r->width(), r->height(), false);
+ gfx::CanvasSkia canvas(gfx::Size(r->width(), r->height()), false);
canvas.Scale(-1, 1);
canvas.DrawBitmapInt(*r, - r->width(), 0);
kRtlArrow = new SkBitmap(canvas.ExtractBitmap());
diff --git a/ui/views/controls/menu/menu_win.cc b/ui/views/controls/menu/menu_win.cc
index e1ad7a5..5928f74 100644
--- a/ui/views/controls/menu/menu_win.cc
+++ b/ui/views/controls/menu/menu_win.cc
@@ -184,7 +184,8 @@ class MenuHostWindow : public ui::WindowImpl {
// Draw the icon after the label, otherwise it would be covered
// by the label.
if (data->icon.width() != 0 && data->icon.height() != 0) {
- gfx::CanvasSkia canvas(data->icon.width(), data->icon.height(), false);
+ gfx::CanvasSkia canvas(gfx::Size(data->icon.width(),
+ data->icon.height()), false);
canvas.sk_canvas()->drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode);
canvas.DrawBitmapInt(data->icon, 0, 0);
skia::DrawToNativeContext(
diff --git a/ui/views/controls/menu/native_menu_win.cc b/ui/views/controls/menu/native_menu_win.cc
index f0dff18..711ac99 100644
--- a/ui/views/controls/menu/native_menu_win.cc
+++ b/ui/views/controls/menu/native_menu_win.cc
@@ -248,7 +248,7 @@ class NativeMenuWin::MenuHostWindow {
if (data->native_menu_win->model_->GetIconAt(data->model_index, &icon)) {
// We currently don't support items with both icons and checkboxes.
DCHECK(type != ui::MenuModel::TYPE_CHECK);
- gfx::CanvasSkia canvas(icon.width(), icon.height(), false);
+ gfx::CanvasSkia canvas(gfx::Size(icon.width(), icon.height()), false);
canvas.sk_canvas()->drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode);
canvas.DrawBitmapInt(icon, 0, 0);
skia::DrawToNativeContext(
@@ -273,7 +273,8 @@ class NativeMenuWin::MenuHostWindow {
int icon_y = kItemTopMargin +
(height - kItemTopMargin - kItemBottomMargin -
config.check_height) / 2;
- gfx::CanvasSkia canvas(config.check_width, config.check_height, false);
+ gfx::CanvasSkia canvas(gfx::Size(config.check_width,
+ config.check_height), false);
NativeTheme::ExtraParams extra;
extra.menu_check.is_radio = false;
gfx::Rect bounds(0, 0, config.check_width, config.check_height);
diff --git a/ui/views/controls/table/native_table_win.cc b/ui/views/controls/table/native_table_win.cc
index 704ff0c..6aca928 100644
--- a/ui/views/controls/table/native_table_win.cc
+++ b/ui/views/controls/table/native_table_win.cc
@@ -393,7 +393,7 @@ void NativeTableWin::CreateNativeControl() {
// We create 2 phony images because we are going to switch images at every
// refresh in order to force a refresh of the icon area (somehow the clip
// rect does not include the icon).
- gfx::CanvasSkia canvas(kImageSize, kImageSize, false);
+ gfx::CanvasSkia canvas(gfx::Size(kImageSize, kImageSize), false);
// Make the background completely transparent.
canvas.sk_canvas()->drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode);
{
@@ -513,8 +513,9 @@ LRESULT NativeTableWin::OnCustomDraw(NMLVCUSTOMDRAW* draw_info) {
client_rect.top += content_offset_;
// Make sure the region need to paint is visible.
if (IntersectRect(&intersection, &icon_rect, &client_rect)) {
- gfx::CanvasSkia canvas(icon_rect.right - icon_rect.left,
- icon_rect.bottom - icon_rect.top, false);
+ gfx::CanvasSkia canvas(
+ gfx::Size(icon_rect.right - icon_rect.left,
+ icon_rect.bottom - icon_rect.top), false);
// It seems the state in nmcd.uItemState is not correct.
// We'll retrieve it explicitly.
diff --git a/ui/views/controls/table/table_view.cc b/ui/views/controls/table/table_view.cc
index bdafbe5..83c4027 100644
--- a/ui/views/controls/table/table_view.cc
+++ b/ui/views/controls/table/table_view.cc
@@ -805,7 +805,7 @@ HWND TableView::CreateNativeControl(HWND parent_container) {
// We create 2 phony images because we are going to switch images at every
// refresh in order to force a refresh of the icon area (somehow the clip
// rect does not include the icon).
- gfx::CanvasSkia canvas(kImageSize, kImageSize, false);
+ gfx::CanvasSkia canvas(gfx::Size(kImageSize, kImageSize), false);
// Make the background completely transparent.
canvas.sk_canvas()->drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode);
{
@@ -1152,7 +1152,7 @@ void TableView::PaintAltText() {
HDC dc = GetDC(GetNativeControlHWND());
gfx::Font font = GetAltTextFont();
gfx::Rect bounds = GetAltTextBounds();
- gfx::CanvasSkia canvas(bounds.width(), bounds.height(), false);
+ gfx::CanvasSkia canvas(bounds.size(), false);
// Pad by 1 for halo.
canvas.DrawStringWithHalo(alt_text_, font, SK_ColorDKGRAY, SK_ColorWHITE, 1,
1, bounds.width() - 2, bounds.height() - 2,
@@ -1236,8 +1236,9 @@ LRESULT TableView::OnCustomDraw(NMLVCUSTOMDRAW* draw_info) {
client_rect.top += content_offset_;
// Make sure the region need to paint is visible.
if (IntersectRect(&intersection, &icon_rect, &client_rect)) {
- gfx::CanvasSkia canvas(icon_rect.right - icon_rect.left,
- icon_rect.bottom - icon_rect.top, false);
+ gfx::CanvasSkia canvas(
+ gfx::Size(icon_rect.right - icon_rect.left,
+ icon_rect.bottom - icon_rect.top), false);
// It seems the state in nmcd.uItemState is not correct.
// We'll retrieve it explicitly.
diff --git a/ui/views/controls/tree/tree_view.cc b/ui/views/controls/tree/tree_view.cc
index 5913633..eaec67c 100644
--- a/ui/views/controls/tree/tree_view.cc
+++ b/ui/views/controls/tree/tree_view.cc
@@ -698,7 +698,7 @@ HIMAGELIST TreeView::CreateImageList() {
// IDR_FOLDER_CLOSED if they aren't already.
if (model_images[i].width() != width ||
model_images[i].height() != height) {
- gfx::CanvasSkia canvas(width, height, false);
+ gfx::CanvasSkia canvas(gfx::Size(width, height), false);
// Make the background completely transparent.
canvas.sk_canvas()->drawColor(SK_ColorBLACK, SkXfermode::kClear_Mode);
diff --git a/ui/views/drag_utils.cc b/ui/views/drag_utils.cc
index 181a599..ae2a3e9 100644
--- a/ui/views/drag_utils.cc
+++ b/ui/views/drag_utils.cc
@@ -47,7 +47,7 @@ void SetURLAndDragImage(const GURL& url,
button.SetBounds(0, 0, prefsize.width(), prefsize.height());
// Render the image.
- gfx::CanvasSkia canvas(prefsize.width(), prefsize.height(), false);
+ gfx::CanvasSkia canvas(prefsize, false);
button.PaintButton(&canvas, views::TextButton::PB_FOR_DRAG);
SetDragImageOnDataObject(canvas, prefsize,
gfx::Point(prefsize.width() / 2, prefsize.height() / 2), data);
@@ -67,7 +67,7 @@ void CreateDragImageForFile(const FilePath& file_name,
// Add +2 here to allow room for the halo.
const int height = font.GetHeight() + icon->height() +
kLinkDragImageVPadding + 2;
- gfx::CanvasSkia canvas(width, height, false /* translucent */);
+ gfx::CanvasSkia canvas(gfx::Size(width, height), false /* translucent */);
// Paint the icon.
canvas.DrawBitmapInt(*icon, (width - icon->width()) / 2, 0);
diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc
index bf22fc7..dfa75f7 100644
--- a/ui/views/widget/native_widget_win.cc
+++ b/ui/views/widget/native_widget_win.cc
@@ -2252,10 +2252,8 @@ void NativeWidgetWin::ClientAreaSizeChanged() {
if (compositor_.get())
compositor_->WidgetSizeChanged(s);
delegate_->OnNativeWidgetSizeChanged(s);
- if (use_layered_buffer_) {
- layered_window_contents_.reset(
- new gfx::CanvasSkia(s.width(), s.height(), false));
- }
+ if (use_layered_buffer_)
+ layered_window_contents_.reset(new gfx::CanvasSkia(s, false));
}
void NativeWidgetWin::ResetWindowRegion(bool force) {