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

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

Issue 2502373003: stop using SkXfermode -- use SkBlendMode instead (Closed)
Patch Set: Created 4 years, 1 month 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
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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 214
215 void Canvas::Translate(const Vector2d& offset) { 215 void Canvas::Translate(const Vector2d& offset) {
216 canvas_->translate(SkIntToScalar(offset.x()), SkIntToScalar(offset.y())); 216 canvas_->translate(SkIntToScalar(offset.x()), SkIntToScalar(offset.y()));
217 } 217 }
218 218
219 void Canvas::Scale(int x_scale, int y_scale) { 219 void Canvas::Scale(int x_scale, int y_scale) {
220 canvas_->scale(SkIntToScalar(x_scale), SkIntToScalar(y_scale)); 220 canvas_->scale(SkIntToScalar(x_scale), SkIntToScalar(y_scale));
221 } 221 }
222 222
223 void Canvas::DrawColor(SkColor color) { 223 void Canvas::DrawColor(SkColor color) {
224 DrawColor(color, SkXfermode::kSrcOver_Mode); 224 DrawColor(color, SkBlendMode::kSrcOver);
225 } 225 }
226 226
227 void Canvas::DrawColor(SkColor color, SkXfermode::Mode mode) { 227 void Canvas::DrawColor(SkColor color, SkBlendMode mode) {
228 canvas_->drawColor(color, static_cast<SkBlendMode>(mode)); 228 canvas_->drawColor(color, mode);
229 } 229 }
230 230
231 void Canvas::FillRect(const Rect& rect, SkColor color) { 231 void Canvas::FillRect(const Rect& rect, SkColor color) {
232 FillRect(rect, color, SkXfermode::kSrcOver_Mode); 232 FillRect(rect, color, SkBlendMode::kSrcOver);
233 } 233 }
234 234
235 void Canvas::FillRect(const Rect& rect, 235 void Canvas::FillRect(const Rect& rect, SkColor color, SkBlendMode mode) {
236 SkColor color,
237 SkXfermode::Mode mode) {
238 SkPaint paint; 236 SkPaint paint;
239 paint.setColor(color); 237 paint.setColor(color);
240 paint.setStyle(SkPaint::kFill_Style); 238 paint.setStyle(SkPaint::kFill_Style);
241 paint.setBlendMode(static_cast<SkBlendMode>(mode)); 239 paint.setBlendMode(static_cast<SkBlendMode>(mode));
f(malita) 2016/11/16 21:10:58 nit: cast no longer needed.
reed1 2016/11/16 21:31:17 Done.
242 DrawRect(rect, paint); 240 DrawRect(rect, paint);
243 } 241 }
244 242
245 void Canvas::DrawRect(const Rect& rect, SkColor color) { 243 void Canvas::DrawRect(const Rect& rect, SkColor color) {
246 DrawRect(RectF(rect), color); 244 DrawRect(RectF(rect), color);
247 } 245 }
248 246
249 void Canvas::DrawRect(const RectF& rect, SkColor color) { 247 void Canvas::DrawRect(const RectF& rect, SkColor color) {
250 DrawRect(rect, color, SkXfermode::kSrcOver_Mode); 248 DrawRect(rect, color, SkBlendMode::kSrcOver);
251 } 249 }
252 250
253 void Canvas::DrawRect(const Rect& rect, 251 void Canvas::DrawRect(const Rect& rect, SkColor color, SkBlendMode mode) {
254 SkColor color,
255 SkXfermode::Mode mode) {
256 DrawRect(RectF(rect), color, mode); 252 DrawRect(RectF(rect), color, mode);
257 } 253 }
258 254
259 void Canvas::DrawRect(const RectF& rect, 255 void Canvas::DrawRect(const RectF& rect, SkColor color, SkBlendMode mode) {
260 SkColor color,
261 SkXfermode::Mode mode) {
262 SkPaint paint; 256 SkPaint paint;
263 paint.setColor(color); 257 paint.setColor(color);
264 paint.setStyle(SkPaint::kStroke_Style); 258 paint.setStyle(SkPaint::kStroke_Style);
265 // Set a stroke width of 0, which will put us down the stroke rect path. If 259 // Set a stroke width of 0, which will put us down the stroke rect path. If
266 // we set a stroke width of 1, for example, this will internally create a 260 // we set a stroke width of 1, for example, this will internally create a
267 // path and fill it, which causes problems near the edge of the canvas. 261 // path and fill it, which causes problems near the edge of the canvas.
268 paint.setStrokeWidth(SkIntToScalar(0)); 262 paint.setStrokeWidth(SkIntToScalar(0));
269 paint.setBlendMode(static_cast<SkBlendMode>(mode)); 263 paint.setBlendMode(static_cast<SkBlendMode>(mode));
270 264
271 DrawRect(rect, paint); 265 DrawRect(rect, paint);
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 p.setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality); 595 p.setFilterQuality(filter ? kLow_SkFilterQuality : kNone_SkFilterQuality);
602 p.setShader(CreateImageRepShaderForScale( 596 p.setShader(CreateImageRepShaderForScale(
603 image_rep, SkShader::kRepeat_TileMode, shader_scale, 597 image_rep, SkShader::kRepeat_TileMode, shader_scale,
604 remove_image_scale ? image_rep.scale() : 1.f)); 598 remove_image_scale ? image_rep.scale() : 1.f));
605 599
606 // The rect will be filled by the bitmap. 600 // The rect will be filled by the bitmap.
607 canvas_->drawRect(dest_rect, p); 601 canvas_->drawRect(dest_rect, p);
608 } 602 }
609 603
610 } // namespace gfx 604 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698