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

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

Issue 2758413002: cc/paint: Remove PaintCanvas::peekPixels. (Closed)
Patch Set: update Created 3 years, 9 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
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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/optional.h"
14 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
15 #include "cc/paint/paint_canvas.h" 16 #include "cc/paint/paint_canvas.h"
16 #include "cc/paint/paint_flags.h" 17 #include "cc/paint/paint_flags.h"
17 #include "cc/paint/paint_surface.h" 18 #include "cc/paint/skia_paint_canvas.h"
18 #include "ui/gfx/image/image_skia.h" 19 #include "ui/gfx/image/image_skia.h"
19 #include "ui/gfx/native_widget_types.h" 20 #include "ui/gfx/native_widget_types.h"
20 #include "ui/gfx/text_constants.h" 21 #include "ui/gfx/text_constants.h"
21 22
22 namespace gfx { 23 namespace gfx {
23 24
24 class Rect; 25 class Rect;
25 class RectF; 26 class RectF;
26 class FontList; 27 class FontList;
27 class Point; 28 class Point;
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 // Apply transformation on the canvas. 465 // Apply transformation on the canvas.
465 void Transform(const Transform& transform); 466 void Transform(const Transform& transform);
466 467
467 // Draws the given string with a fade gradient at the end. 468 // Draws the given string with a fade gradient at the end.
468 void DrawFadedString(const base::string16& text, 469 void DrawFadedString(const base::string16& text,
469 const FontList& font_list, 470 const FontList& font_list,
470 SkColor color, 471 SkColor color,
471 const Rect& display_rect, 472 const Rect& display_rect,
472 int flags); 473 int flags);
473 474
474 SkBitmap ToBitmap(); 475 // Note that writing to this bitmap will modify pixels stored in this canvas.
476 SkBitmap GetBitmap() const;
475 477
476 // TODO(enne): rename sk_canvas members and interface. 478 // TODO(enne): rename sk_canvas members and interface.
477 cc::PaintCanvas* sk_canvas() { return canvas_; } 479 cc::PaintCanvas* sk_canvas() { return canvas_; }
478 float image_scale() const { return image_scale_; } 480 float image_scale() const { return image_scale_; }
479 481
480 private: 482 private:
481 // Tests whether the provided rectangle intersects the current clip rect. 483 // Tests whether the provided rectangle intersects the current clip rect.
482 bool IntersectsClipRect(const SkRect& rect); 484 bool IntersectsClipRect(const SkRect& rect);
483 485
484 // Helper for the DrawImageInt functions declared above. The 486 // Helper for the DrawImageInt functions declared above. The
485 // |remove_image_scale| parameter indicates if the scale of the |image_rep| 487 // |remove_image_scale| parameter indicates if the scale of the |image_rep|
486 // should be removed when drawing the image, to avoid double-scaling it. 488 // should be removed when drawing the image, to avoid double-scaling it.
487 void DrawImageIntHelper(const ImageSkiaRep& image_rep, 489 void DrawImageIntHelper(const ImageSkiaRep& image_rep,
488 int src_x, 490 int src_x,
489 int src_y, 491 int src_y,
490 int src_w, 492 int src_w,
491 int src_h, 493 int src_h,
492 int dest_x, 494 int dest_x,
493 int dest_y, 495 int dest_y,
494 int dest_w, 496 int dest_w,
495 int dest_h, 497 int dest_h,
496 bool filter, 498 bool filter,
497 const cc::PaintFlags& flags, 499 const cc::PaintFlags& flags,
498 bool remove_image_scale); 500 bool remove_image_scale);
501 cc::PaintCanvas* CreateOwnedCanvas(const Size& size, bool is_opaque);
499 502
500 // The device scale factor at which drawing on this canvas occurs. 503 // The device scale factor at which drawing on this canvas occurs.
501 // An additional scale can be applied via Canvas::Scale(). However, 504 // An additional scale can be applied via Canvas::Scale(). However,
502 // Canvas::Scale() does not affect |image_scale_|. 505 // Canvas::Scale() does not affect |image_scale_|.
503 float image_scale_; 506 float image_scale_;
504 507
505 // canvas_ is our active canvas object. Sometimes we are also the owner, 508 // canvas_ is our active canvas object. Sometimes we are also the owner,
506 // in which case surface_ will be set. Other times we are just 509 // in which case bitmap_ and owned_canvas_ will be set. Other times we are
507 // borrowing someone else's canvas, in which case canvas_ will point there 510 // just borrowing someone else's canvas, in which case canvas_ will point
508 // but surface_ will be null. 511 // there but bitmap_ and owned_canvas_ will not exist.
509 sk_sp<cc::PaintSurface> surface_; 512 base::Optional<SkBitmap> bitmap_;
513 base::Optional<cc::SkiaPaintCanvas> owned_canvas_;
510 cc::PaintCanvas* canvas_; 514 cc::PaintCanvas* canvas_;
511 515
512 DISALLOW_COPY_AND_ASSIGN(Canvas); 516 DISALLOW_COPY_AND_ASSIGN(Canvas);
513 }; 517 };
514 518
515 } // namespace gfx 519 } // namespace gfx
516 520
517 #endif // UI_GFX_CANVAS_H_ 521 #endif // UI_GFX_CANVAS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698