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

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

Issue 2502373003: stop using SkXfermode -- use SkBlendMode instead (Closed)
Patch Set: rebase Created 4 years 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/compositor/compositing_recorder.cc ('k') | ui/gfx/canvas.cc » ('j') | 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 #ifndef UI_GFX_CANVAS_H_ 5 #ifndef UI_GFX_CANVAS_H_
6 #define UI_GFX_CANVAS_H_ 6 #define UI_GFX_CANVAS_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 20 matching lines...) Expand all
31 31
32 // Canvas is a SkCanvas wrapper that provides a number of methods for 32 // Canvas is a SkCanvas wrapper that provides a number of methods for
33 // common operations used throughout an application built using ui/gfx. 33 // common operations used throughout an application built using ui/gfx.
34 // 34 //
35 // All methods that take integer arguments (as is used throughout views) 35 // All methods that take integer arguments (as is used throughout views)
36 // end with Int. If you need to use methods provided by SkCanvas, you'll 36 // end with Int. If you need to use methods provided by SkCanvas, you'll
37 // need to do a conversion. In particular you'll need to use |SkIntToScalar()|, 37 // need to do a conversion. In particular you'll need to use |SkIntToScalar()|,
38 // or if converting from a scalar to an integer |SkScalarRound()|. 38 // or if converting from a scalar to an integer |SkScalarRound()|.
39 // 39 //
40 // A handful of methods in this class are overloaded providing an additional 40 // A handful of methods in this class are overloaded providing an additional
41 // argument of type SkXfermode::Mode. SkXfermode::Mode specifies how the 41 // argument of type SkBlendMode. SkBlendMode specifies how the
42 // source and destination colors are combined. Unless otherwise specified, 42 // source and destination colors are combined. Unless otherwise specified,
43 // the variant that does not take a SkXfermode::Mode uses a transfer mode 43 // the variant that does not take a SkBlendMode uses a transfer mode
44 // of kSrcOver_Mode. 44 // of kSrcOver_Mode.
45 class GFX_EXPORT Canvas { 45 class GFX_EXPORT Canvas {
46 public: 46 public:
47 enum { 47 enum {
48 // Specifies the alignment for text rendered with the DrawStringRect method. 48 // Specifies the alignment for text rendered with the DrawStringRect method.
49 TEXT_ALIGN_LEFT = 1 << 0, 49 TEXT_ALIGN_LEFT = 1 << 0,
50 TEXT_ALIGN_CENTER = 1 << 1, 50 TEXT_ALIGN_CENTER = 1 << 1,
51 TEXT_ALIGN_RIGHT = 1 << 2, 51 TEXT_ALIGN_RIGHT = 1 << 2,
52 TEXT_ALIGN_TO_HEAD = 1 << 3, 52 TEXT_ALIGN_TO_HEAD = 1 << 3,
53 53
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 208
209 // Returns the bounds of the current clip (in local coordinates) in the 209 // Returns the bounds of the current clip (in local coordinates) in the
210 // |bounds| parameter, and returns true if it is non empty. 210 // |bounds| parameter, and returns true if it is non empty.
211 bool GetClipBounds(Rect* bounds); 211 bool GetClipBounds(Rect* bounds);
212 212
213 void Translate(const Vector2d& offset); 213 void Translate(const Vector2d& offset);
214 214
215 void Scale(int x_scale, int y_scale); 215 void Scale(int x_scale, int y_scale);
216 216
217 // Fills the entire canvas' bitmap (restricted to current clip) with 217 // Fills the entire canvas' bitmap (restricted to current clip) with
218 // specified |color| using a transfer mode of SkXfermode::kSrcOver_Mode. 218 // specified |color| using a transfer mode of SkBlendMode::kSrcOver.
219 void DrawColor(SkColor color); 219 void DrawColor(SkColor color);
220 220
221 // Fills the entire canvas' bitmap (restricted to current clip) with 221 // Fills the entire canvas' bitmap (restricted to current clip) with
222 // specified |color| and |mode|. 222 // specified |color| and |mode|.
223 void DrawColor(SkColor color, SkXfermode::Mode mode); 223 void DrawColor(SkColor color, SkBlendMode mode);
224 224
225 // Fills |rect| with |color| using a transfer mode of 225 // Fills |rect| with |color| using a transfer mode of
226 // SkXfermode::kSrcOver_Mode. 226 // SkBlendMode::kSrcOver.
227 void FillRect(const Rect& rect, SkColor color); 227 void FillRect(const Rect& rect, SkColor color);
228 228
229 // Fills |rect| with the specified |color| and |mode|. 229 // Fills |rect| with the specified |color| and |mode|.
230 void FillRect(const Rect& rect, SkColor color, SkXfermode::Mode mode); 230 void FillRect(const Rect& rect, SkColor color, SkBlendMode mode);
231 231
232 // Draws a single pixel rect in the specified region with the specified 232 // Draws a single pixel rect in the specified region with the specified
233 // color, using a transfer mode of SkXfermode::kSrcOver_Mode. 233 // color, using a transfer mode of SkBlendMode::kSrcOver.
234 // 234 //
235 // NOTE: if you need a single pixel line, use DrawLine. 235 // NOTE: if you need a single pixel line, use DrawLine.
236 // DEPRECATED in favor of the RectF version below. 236 // DEPRECATED in favor of the RectF version below.
237 // TODO(funkysidd): Remove this (http://crbug.com/553726) 237 // TODO(funkysidd): Remove this (http://crbug.com/553726)
238 void DrawRect(const Rect& rect, SkColor color); 238 void DrawRect(const Rect& rect, SkColor color);
239 239
240 // Draws a single pixel rect in the specified region with the specified 240 // Draws a single pixel rect in the specified region with the specified
241 // color, using a transfer mode of SkXfermode::kSrcOver_Mode. 241 // color, using a transfer mode of SkBlendMode::kSrcOver.
242 // 242 //
243 // NOTE: if you need a single pixel line, use DrawLine. 243 // NOTE: if you need a single pixel line, use DrawLine.
244 void DrawRect(const RectF& rect, SkColor color); 244 void DrawRect(const RectF& rect, SkColor color);
245 245
246 // Draws a single pixel rect in the specified region with the specified 246 // Draws a single pixel rect in the specified region with the specified
247 // color and transfer mode. 247 // color and transfer mode.
248 // 248 //
249 // NOTE: if you need a single pixel line, use DrawLine. 249 // NOTE: if you need a single pixel line, use DrawLine.
250 // DEPRECATED in favor of the RectF version below. 250 // DEPRECATED in favor of the RectF version below.
251 // TODO(funkysidd): Remove this (http://crbug.com/553726) 251 // TODO(funkysidd): Remove this (http://crbug.com/553726)
252 void DrawRect(const Rect& rect, SkColor color, SkXfermode::Mode mode); 252 void DrawRect(const Rect& rect, SkColor color, SkBlendMode mode);
253 253
254 // Draws a single pixel rect in the specified region with the specified 254 // Draws a single pixel rect in the specified region with the specified
255 // color and transfer mode. 255 // color and transfer mode.
256 // 256 //
257 // NOTE: if you need a single pixel line, use DrawLine. 257 // NOTE: if you need a single pixel line, use DrawLine.
258 void DrawRect(const RectF& rect, SkColor color, SkXfermode::Mode mode); 258 void DrawRect(const RectF& rect, SkColor color, SkBlendMode mode);
259 259
260 // Draws the given rectangle with the given |paint| parameters. 260 // Draws the given rectangle with the given |paint| parameters.
261 // DEPRECATED in favor of the RectF version below. 261 // DEPRECATED in favor of the RectF version below.
262 // TODO(funkysidd): Remove this (http://crbug.com/553726) 262 // TODO(funkysidd): Remove this (http://crbug.com/553726)
263 void DrawRect(const Rect& rect, const SkPaint& paint); 263 void DrawRect(const Rect& rect, const SkPaint& paint);
264 264
265 // Draws the given rectangle with the given |paint| parameters. 265 // Draws the given rectangle with the given |paint| parameters.
266 void DrawRect(const RectF& rect, const SkPaint& paint); 266 void DrawRect(const RectF& rect, const SkPaint& paint);
267 267
268 // Draw the given point with the given |paint| parameters. 268 // Draw the given point with the given |paint| parameters.
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 // but canvas_owner_ will be null. 517 // but canvas_owner_ will be null.
518 std::unique_ptr<SkCanvas> canvas_owner_; 518 std::unique_ptr<SkCanvas> canvas_owner_;
519 SkCanvas* canvas_; 519 SkCanvas* canvas_;
520 520
521 DISALLOW_COPY_AND_ASSIGN(Canvas); 521 DISALLOW_COPY_AND_ASSIGN(Canvas);
522 }; 522 };
523 523
524 } // namespace gfx 524 } // namespace gfx
525 525
526 #endif // UI_GFX_CANVAS_H_ 526 #endif // UI_GFX_CANVAS_H_
OLDNEW
« no previous file with comments | « ui/compositor/compositing_recorder.cc ('k') | ui/gfx/canvas.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698