Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Side by Side Diff: ui/gfx/canvas.cc

Issue 557953004: Makes GetClipBounds() return the enclosing rect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/gfx/canvas_unittest.cc » ('j') | ui/gfx/canvas_unittest.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/canvas_unittest.cc » ('j') | ui/gfx/canvas_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698