summaryrefslogtreecommitdiffstats
path: root/ui/gfx
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-01 16:29:21 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-01 16:29:21 +0000
commitb9857bdd37282ba346cbb2ccb52b67175ef490c0 (patch)
tree373a6f5904ab4e71c7b407a26512267f0c7b109c /ui/gfx
parent414d57a780c0f774a9e5c2a893f5189b88b43b6e (diff)
downloadchromium_src-b9857bdd37282ba346cbb2ccb52b67175ef490c0.zip
chromium_src-b9857bdd37282ba346cbb2ccb52b67175ef490c0.tar.gz
chromium_src-b9857bdd37282ba346cbb2ccb52b67175ef490c0.tar.bz2
ui: Let skia do the conversion work for us by using the integer version of set() function.
R=pkasting@chromium.org TBR=sky@chromium.org Review URL: https://chromiumcodereview.appspot.com/9544001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124416 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx')
-rw-r--r--ui/gfx/canvas_skia.cc6
-rw-r--r--ui/gfx/native_theme_android.cc23
-rw-r--r--ui/gfx/native_theme_base.cc25
-rw-r--r--ui/gfx/native_theme_chromeos.cc28
-rw-r--r--ui/gfx/skia_util.cc4
5 files changed, 32 insertions, 54 deletions
diff --git a/ui/gfx/canvas_skia.cc b/ui/gfx/canvas_skia.cc
index 6e44931..5ae821c 100644
--- a/ui/gfx/canvas_skia.cc
+++ b/ui/gfx/canvas_skia.cc
@@ -114,11 +114,7 @@ void CanvasSkia::SaveLayerAlpha(uint8 alpha) {
void CanvasSkia::SaveLayerAlpha(uint8 alpha, const gfx::Rect& layer_bounds) {
- SkRect bounds;
- bounds.set(SkIntToScalar(layer_bounds.x()),
- SkIntToScalar(layer_bounds.y()),
- SkIntToScalar(layer_bounds.right()),
- SkIntToScalar(layer_bounds.bottom()));
+ SkRect bounds(gfx::RectToSkRect(layer_bounds));
canvas_->saveLayerAlpha(&bounds, alpha);
}
diff --git a/ui/gfx/native_theme_android.cc b/ui/gfx/native_theme_android.cc
index 82c5ab4..a63f37a 100644
--- a/ui/gfx/native_theme_android.cc
+++ b/ui/gfx/native_theme_android.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -345,10 +345,8 @@ void NativeThemeAndroid::PaintButton(SkCanvas* canvas,
int kLightEnd = state == PRESSED ? 1 : 0;
int kDarkEnd = !kLightEnd;
SkPoint gradient_bounds[2];
- gradient_bounds[kLightEnd].set(SkIntToScalar(rect.x()),
- SkIntToScalar(rect.y()));
- gradient_bounds[kDarkEnd].set(SkIntToScalar(rect.x()),
- SkIntToScalar(kBottom - 1));
+ gradient_bounds[kLightEnd].iset(rect.x(), rect.y());
+ gradient_bounds[kDarkEnd].iset(rect.x(), kBottom - 1);
SkColor colors[2];
colors[0] = light_color;
colors[1] = base_color;
@@ -614,20 +612,15 @@ void NativeThemeAndroid::PaintProgressBar(
int dest_left_border_width = static_cast<int>(left_border_image->width() *
tile_scale);
- SkRect dest_rect = {
- SkIntToScalar(rect.x()),
- SkIntToScalar(rect.y()),
- SkIntToScalar(rect.x() + dest_left_border_width),
- SkIntToScalar(rect.bottom())
- };
+ SkRect dest_rect;
+ dest_rect.iset(rect.x(), rect.y(), rect.x() + dest_left_border_width,
+ rect.bottom());
canvas->drawBitmapRect(*left_border_image, NULL, dest_rect);
int dest_right_border_width = static_cast<int>(right_border_image->width() *
tile_scale);
- dest_rect.set(SkIntToScalar(rect.right() - dest_right_border_width),
- SkIntToScalar(rect.y()),
- SkIntToScalar(rect.right()),
- SkIntToScalar(rect.bottom()));
+ dest_rect.iset(rect.right() - dest_right_border_width, rect.y(), rect.right(),
+ rect.bottom());
canvas->drawBitmapRect(*right_border_image, NULL, dest_rect);
}
diff --git a/ui/gfx/native_theme_base.cc b/ui/gfx/native_theme_base.cc
index 2448d18..0355631 100644
--- a/ui/gfx/native_theme_base.cc
+++ b/ui/gfx/native_theme_base.cc
@@ -520,10 +520,8 @@ void NativeThemeBase::PaintButton(SkCanvas* canvas,
const int kLightEnd = state == kPressed ? 1 : 0;
const int kDarkEnd = !kLightEnd;
SkPoint gradient_bounds[2];
- gradient_bounds[kLightEnd].set(SkIntToScalar(rect.x()),
- SkIntToScalar(rect.y()));
- gradient_bounds[kDarkEnd].set(SkIntToScalar(rect.x()),
- SkIntToScalar(kBottom - 1));
+ gradient_bounds[kLightEnd].iset(rect.x(), rect.y());
+ gradient_bounds[kDarkEnd].iset(rect.x(), kBottom - 1);
SkColor colors[2];
colors[0] = light_color;
colors[1] = base_color;
@@ -804,25 +802,20 @@ void NativeThemeBase::PaintProgressBar(SkCanvas* canvas,
int dest_left_border_width = static_cast<int>(left_border_image->width() *
tile_scale);
- SkRect dest_rect = {
- SkIntToScalar(rect.x()),
- SkIntToScalar(rect.y()),
- SkIntToScalar(rect.x() + dest_left_border_width),
- SkIntToScalar(rect.bottom())
- };
+ SkRect dest_rect;
+ dest_rect.iset(rect.x(), rect.y(), rect.x() + dest_left_border_width,
+ rect.bottom());
canvas->drawBitmapRect(*left_border_image, NULL, dest_rect);
int dest_right_border_width = static_cast<int>(right_border_image->width() *
tile_scale);
- dest_rect.set(SkIntToScalar(rect.right() - dest_right_border_width),
- SkIntToScalar(rect.y()),
- SkIntToScalar(rect.right()),
- SkIntToScalar(rect.bottom()));
+ dest_rect.iset(rect.right() - dest_right_border_width, rect.y(), rect.right(),
+ rect.bottom());
canvas->drawBitmapRect(*right_border_image, NULL, dest_rect);
}
-bool NativeThemeBase::IntersectsClipRectInt(
- SkCanvas* canvas, int x, int y, int w, int h) const {
+bool NativeThemeBase::IntersectsClipRectInt(SkCanvas* canvas,
+ int x, int y, int w, int h) const {
SkRect clip;
return canvas->getClipBounds(&clip) &&
clip.intersect(SkIntToScalar(x), SkIntToScalar(y), SkIntToScalar(x + w),
diff --git a/ui/gfx/native_theme_chromeos.cc b/ui/gfx/native_theme_chromeos.cc
index df9d1b1..a18a337 100644
--- a/ui/gfx/native_theme_chromeos.cc
+++ b/ui/gfx/native_theme_chromeos.cc
@@ -7,10 +7,10 @@
#include "base/basictypes.h"
#include "base/logging.h"
#include "grit/gfx_resources.h"
-#include "third_party/skia/include/effects/SkGradientShader.h"
#include "third_party/skia/include/core/SkPaint.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkShader.h"
+#include "third_party/skia/include/effects/SkGradientShader.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/rect.h"
@@ -136,8 +136,8 @@ void GetGradientPaintForRect(const gfx::Rect& rect,
paint->setAntiAlias(true);
SkPoint points[2];
- points[0].set(SkIntToScalar(rect.x()), SkIntToScalar(rect.y()));
- points[1].set(SkIntToScalar(rect.x()), SkIntToScalar(rect.bottom()));
+ points[0].iset(rect.x(), rect.y());
+ points[1].iset(rect.x(), rect.bottom());
SkShader* shader = SkGradientShader::CreateLinear(points,
colors, stops, count, SkShader::kClamp_TileMode);
@@ -225,8 +225,8 @@ void GetRadioIndicatorGradientPaint(const gfx::Rect bounds,
paint->setAntiAlias(true);
SkPoint points[2];
- points[0].set(SkIntToScalar(bounds.x()), SkIntToScalar(bounds.y()));
- points[1].set(SkIntToScalar(bounds.x()), SkIntToScalar(bounds.bottom()));
+ points[0].iset(bounds.x(), bounds.y());
+ points[1].iset(bounds.x(), bounds.bottom());
static const SkScalar kGradientPoints[2] = {
SkIntToScalar(0),
@@ -588,12 +588,11 @@ void NativeThemeChromeos::PaintTextField(SkCanvas* canvas,
};
SkPoint points[2];
- points[0].set(SkIntToScalar(rect.x()), SkIntToScalar(rect.y()));
- points[1].set(SkIntToScalar(rect.x()), SkIntToScalar(rect.bottom()));
+ points[0].iset(rect.x(), rect.y());
+ points[1].iset(rect.x(), rect.bottom());
- GetGradientPaintForRect(rect,
- gradient_colors, gradient_points, arraysize(gradient_points),
- &fill_paint);
+ GetGradientPaintForRect(rect, gradient_colors, gradient_points,
+ arraysize(gradient_points), &fill_paint);
}
SkPath border;
@@ -675,8 +674,8 @@ void NativeThemeChromeos::PaintMenuPopupBackground(
};
SkPoint points[2];
- points[0].set(SkIntToScalar(0), SkIntToScalar(0));
- points[1].set(SkIntToScalar(0), SkIntToScalar(rect.height()));
+ points[0].iset(0, 0);
+ points[1].iset(0, rect.height());
SkShader* shader = SkGradientShader::CreateLinear(points,
kGradientColors, kGradientPoints, arraysize(kGradientPoints),
@@ -690,10 +689,7 @@ void NativeThemeChromeos::PaintMenuPopupBackground(
paint.setStyle(SkPaint::kFill_Style);
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
- SkRect sk_rect;
- sk_rect.set(SkIntToScalar(0), SkIntToScalar(0),
- SkIntToScalar(rect.width()), SkIntToScalar(rect.height()));
- canvas->drawRect(sk_rect, paint);
+ canvas->drawRect(gfx::RectToSkRect(gfx::Rect(rect.size())), paint);
}
void NativeThemeChromeos::PaintProgressBar(SkCanvas* canvas,
diff --git a/ui/gfx/skia_util.cc b/ui/gfx/skia_util.cc
index d64f2b2..bfee378 100644
--- a/ui/gfx/skia_util.cc
+++ b/ui/gfx/skia_util.cc
@@ -37,8 +37,8 @@ SkShader* CreateGradientShader(int start_point,
SkColor end_color) {
SkColor grad_colors[2] = { start_color, end_color};
SkPoint grad_points[2];
- grad_points[0].set(SkIntToScalar(0), SkIntToScalar(start_point));
- grad_points[1].set(SkIntToScalar(0), SkIntToScalar(end_point));
+ grad_points[0].iset(0, start_point);
+ grad_points[1].iset(0, end_point);
return SkGradientShader::CreateLinear(
grad_points, grad_colors, NULL, 2, SkShader::kRepeat_TileMode);