| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gfx/canvas.h" | 5 #include "ui/gfx/canvas.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "third_party/skia/include/core/SkBitmap.h" | 12 #include "third_party/skia/include/core/SkBitmap.h" |
| 13 #include "third_party/skia/include/effects/SkGradientShader.h" | 13 #include "third_party/skia/include/effects/SkGradientShader.h" |
| 14 #include "ui/gfx/font_list.h" | 14 #include "ui/gfx/font_list.h" |
| 15 #include "ui/gfx/geometry/rect_conversions.h" |
| 15 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
| 16 #include "ui/gfx/size_conversions.h" | 17 #include "ui/gfx/size_conversions.h" |
| 17 #include "ui/gfx/skia_util.h" | 18 #include "ui/gfx/skia_util.h" |
| 18 #include "ui/gfx/transform.h" | 19 #include "ui/gfx/transform.h" |
| 19 | 20 |
| 20 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
| 21 #include "ui/gfx/canvas_skia_paint.h" | 22 #include "ui/gfx/canvas_skia_paint.h" |
| 22 #endif | 23 #endif |
| 23 | 24 |
| 24 namespace gfx { | 25 namespace gfx { |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 void Canvas::ClipPath(const SkPath& path, bool do_anti_alias) { | 203 void Canvas::ClipPath(const SkPath& path, bool do_anti_alias) { |
| 203 canvas_->clipPath(path, SkRegion::kIntersect_Op, do_anti_alias); | 204 canvas_->clipPath(path, SkRegion::kIntersect_Op, do_anti_alias); |
| 204 } | 205 } |
| 205 | 206 |
| 206 bool Canvas::IsClipEmpty() const { | 207 bool Canvas::IsClipEmpty() const { |
| 207 return canvas_->isClipEmpty(); | 208 return canvas_->isClipEmpty(); |
| 208 } | 209 } |
| 209 | 210 |
| 210 bool Canvas::GetClipBounds(Rect* bounds) { | 211 bool Canvas::GetClipBounds(Rect* bounds) { |
| 211 SkRect out; | 212 SkRect out; |
| 212 bool has_non_empty_clip = canvas_->getClipBounds(&out); | 213 if (canvas_->getClipBounds(&out)) { |
| 213 bounds->SetRect(out.left(), out.top(), out.width(), out.height()); | 214 *bounds = ToEnclosingRect(SkRectToRectF(out)); |
| 214 return has_non_empty_clip; | 215 return true; |
| 216 } |
| 217 *bounds = gfx::Rect(); |
| 218 return false; |
| 215 } | 219 } |
| 216 | 220 |
| 217 void Canvas::Translate(const Vector2d& offset) { | 221 void Canvas::Translate(const Vector2d& offset) { |
| 218 canvas_->translate(SkIntToScalar(offset.x()), SkIntToScalar(offset.y())); | 222 canvas_->translate(SkIntToScalar(offset.x()), SkIntToScalar(offset.y())); |
| 219 } | 223 } |
| 220 | 224 |
| 221 void Canvas::Scale(int x_scale, int y_scale) { | 225 void Canvas::Scale(int x_scale, int y_scale) { |
| 222 canvas_->scale(SkIntToScalar(x_scale), SkIntToScalar(y_scale)); | 226 canvas_->scale(SkIntToScalar(x_scale), SkIntToScalar(y_scale)); |
| 223 } | 227 } |
| 224 | 228 |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 SkPaint p(paint); | 635 SkPaint p(paint); |
| 632 p.setFilterLevel(filter ? SkPaint::kLow_FilterLevel | 636 p.setFilterLevel(filter ? SkPaint::kLow_FilterLevel |
| 633 : SkPaint::kNone_FilterLevel); | 637 : SkPaint::kNone_FilterLevel); |
| 634 p.setShader(shader.get()); | 638 p.setShader(shader.get()); |
| 635 | 639 |
| 636 // The rect will be filled by the bitmap. | 640 // The rect will be filled by the bitmap. |
| 637 canvas_->drawRect(dest_rect, p); | 641 canvas_->drawRect(dest_rect, p); |
| 638 } | 642 } |
| 639 | 643 |
| 640 } // namespace gfx | 644 } // namespace gfx |
| OLD | NEW |