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

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

Issue 2799213003: Remove deprecated functions from Canvas in favor of the RectF version. (Closed)
Patch Set: Remove deprecated functions from Canvas in favor of the RectF version Created 3 years, 8 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 | « ui/gfx/canvas.h ('k') | no next file » | no next file with comments »
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"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // to call extractSubset or the copy constructor, since we want an actual copy 108 // to call extractSubset or the copy constructor, since we want an actual copy
109 // of the bitmap. 109 // of the bitmap.
110 const SkISize size = canvas_->getBaseLayerSize(); 110 const SkISize size = canvas_->getBaseLayerSize();
111 SkBitmap result; 111 SkBitmap result;
112 result.allocN32Pixels(size.width(), size.height()); 112 result.allocN32Pixels(size.width(), size.height());
113 113
114 canvas_->readPixels(&result, 0, 0); 114 canvas_->readPixels(&result, 0, 0);
115 return ImageSkiaRep(result, image_scale_); 115 return ImageSkiaRep(result, image_scale_);
116 } 116 }
117 117
118 void Canvas::DrawDashedRect(const Rect& rect, SkColor color) {
119 DrawDashedRect(RectF(rect), color);
120 }
121
122 void Canvas::DrawDashedRect(const RectF& rect, SkColor color) { 118 void Canvas::DrawDashedRect(const RectF& rect, SkColor color) {
123 if (rect.IsEmpty()) 119 if (rect.IsEmpty())
124 return; 120 return;
125 // Create a 2D bitmap containing alternating on/off pixels - we do this 121 // Create a 2D bitmap containing alternating on/off pixels - we do this
126 // so that you never get two pixels of the same color around the edges 122 // so that you never get two pixels of the same color around the edges
127 // of the focus rect (this may mean that opposing edges of the rect may 123 // of the focus rect (this may mean that opposing edges of the rect may
128 // have a dot pattern out of phase to each other). 124 // have a dot pattern out of phase to each other).
129 static SkColor last_color; 125 static SkColor last_color;
130 static SkBitmap* dots = NULL; 126 static SkBitmap* dots = NULL;
131 if (!dots || last_color != color) { 127 if (!dots || last_color != color) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 231 }
236 232
237 void Canvas::FillRect(const Rect& rect, SkColor color, SkBlendMode mode) { 233 void Canvas::FillRect(const Rect& rect, SkColor color, SkBlendMode mode) {
238 cc::PaintFlags flags; 234 cc::PaintFlags flags;
239 flags.setColor(color); 235 flags.setColor(color);
240 flags.setStyle(cc::PaintFlags::kFill_Style); 236 flags.setStyle(cc::PaintFlags::kFill_Style);
241 flags.setBlendMode(mode); 237 flags.setBlendMode(mode);
242 DrawRect(rect, flags); 238 DrawRect(rect, flags);
243 } 239 }
244 240
245 void Canvas::DrawRect(const Rect& rect, SkColor color) {
246 DrawRect(RectF(rect), color);
247 }
248
249 void Canvas::DrawRect(const RectF& rect, SkColor color) { 241 void Canvas::DrawRect(const RectF& rect, SkColor color) {
250 DrawRect(rect, color, SkBlendMode::kSrcOver); 242 DrawRect(rect, color, SkBlendMode::kSrcOver);
251 } 243 }
252 244
253 void Canvas::DrawRect(const Rect& rect, SkColor color, SkBlendMode mode) {
254 DrawRect(RectF(rect), color, mode);
255 }
256
257 void Canvas::DrawRect(const RectF& rect, SkColor color, SkBlendMode mode) { 245 void Canvas::DrawRect(const RectF& rect, SkColor color, SkBlendMode mode) {
258 cc::PaintFlags flags; 246 cc::PaintFlags flags;
259 flags.setColor(color); 247 flags.setColor(color);
260 flags.setStyle(cc::PaintFlags::kStroke_Style); 248 flags.setStyle(cc::PaintFlags::kStroke_Style);
261 // Set a stroke width of 0, which will put us down the stroke rect path. If 249 // Set a stroke width of 0, which will put us down the stroke rect path. If
262 // we set a stroke width of 1, for example, this will internally create a 250 // we set a stroke width of 1, for example, this will internally create a
263 // path and fill it, which causes problems near the edge of the canvas. 251 // path and fill it, which causes problems near the edge of the canvas.
264 flags.setStrokeWidth(SkIntToScalar(0)); 252 flags.setStrokeWidth(SkIntToScalar(0));
265 flags.setBlendMode(mode); 253 flags.setBlendMode(mode);
266 254
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 bitmap_.emplace(); 610 bitmap_.emplace();
623 bitmap_->allocPixels(info); 611 bitmap_->allocPixels(info);
624 // Ensure that the bitmap is zeroed, since the code expects that. 612 // Ensure that the bitmap is zeroed, since the code expects that.
625 memset(bitmap_->getPixels(), 0, bitmap_->getSafeSize()); 613 memset(bitmap_->getPixels(), 0, bitmap_->getSafeSize());
626 614
627 owned_canvas_ = cc::SkiaPaintCanvas(bitmap_.value()); 615 owned_canvas_ = cc::SkiaPaintCanvas(bitmap_.value());
628 return &owned_canvas_.value(); 616 return &owned_canvas_.value();
629 } 617 }
630 618
631 } // namespace gfx 619 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/canvas.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698