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

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

Issue 2758413002: cc/paint: Remove PaintCanvas::peekPixels. (Closed)
Patch Set: canvas 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
« no previous file with comments | « content/renderer/media/webrtc/webrtc_video_capturer_adapter.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>
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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 SkBitmap ToBitmap();
475 476
476 // TODO(enne): rename sk_canvas members and interface. 477 // TODO(enne): rename sk_canvas members and interface.
477 cc::PaintCanvas* sk_canvas() { return canvas_; } 478 cc::PaintCanvas* sk_canvas() { return canvas_; }
479 SkBitmap& get_bitmap() {
enne (OOO) 2017/03/21 00:46:38 Maybe ToBitmap() should return bitmap_ if it exist
vmpstr 2017/03/21 17:47:12 Oh, I completely missed that there is ToBitmap her
enne (OOO) 2017/03/21 17:51:02 Oh, even better! If that's always the case, then l
480 DCHECK(bitmap_);
481 return bitmap_.value();
482 }
478 float image_scale() const { return image_scale_; } 483 float image_scale() const { return image_scale_; }
479 484
480 private: 485 private:
481 // Tests whether the provided rectangle intersects the current clip rect. 486 // Tests whether the provided rectangle intersects the current clip rect.
482 bool IntersectsClipRect(const SkRect& rect); 487 bool IntersectsClipRect(const SkRect& rect);
483 488
484 // Helper for the DrawImageInt functions declared above. The 489 // Helper for the DrawImageInt functions declared above. The
485 // |remove_image_scale| parameter indicates if the scale of the |image_rep| 490 // |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. 491 // should be removed when drawing the image, to avoid double-scaling it.
487 void DrawImageIntHelper(const ImageSkiaRep& image_rep, 492 void DrawImageIntHelper(const ImageSkiaRep& image_rep,
488 int src_x, 493 int src_x,
489 int src_y, 494 int src_y,
490 int src_w, 495 int src_w,
491 int src_h, 496 int src_h,
492 int dest_x, 497 int dest_x,
493 int dest_y, 498 int dest_y,
494 int dest_w, 499 int dest_w,
495 int dest_h, 500 int dest_h,
496 bool filter, 501 bool filter,
497 const cc::PaintFlags& flags, 502 const cc::PaintFlags& flags,
498 bool remove_image_scale); 503 bool remove_image_scale);
504 cc::PaintCanvas* CreateOwnedCanvas(const Size& size, bool is_opaque);
499 505
500 // The device scale factor at which drawing on this canvas occurs. 506 // The device scale factor at which drawing on this canvas occurs.
501 // An additional scale can be applied via Canvas::Scale(). However, 507 // An additional scale can be applied via Canvas::Scale(). However,
502 // Canvas::Scale() does not affect |image_scale_|. 508 // Canvas::Scale() does not affect |image_scale_|.
503 float image_scale_; 509 float image_scale_;
504 510
505 // canvas_ is our active canvas object. Sometimes we are also the owner, 511 // 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 512 // 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 513 // just borrowing someone else's canvas, in which case canvas_ will point
508 // but surface_ will be null. 514 // there but bitmap_ and owned_canvas_ will not exist.
509 sk_sp<cc::PaintSurface> surface_; 515 base::Optional<SkBitmap> bitmap_;
516 base::Optional<cc::SkiaPaintCanvas> owned_canvas_;
510 cc::PaintCanvas* canvas_; 517 cc::PaintCanvas* canvas_;
511 518
512 DISALLOW_COPY_AND_ASSIGN(Canvas); 519 DISALLOW_COPY_AND_ASSIGN(Canvas);
513 }; 520 };
514 521
515 } // namespace gfx 522 } // namespace gfx
516 523
517 #endif // UI_GFX_CANVAS_H_ 524 #endif // UI_GFX_CANVAS_H_
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc/webrtc_video_capturer_adapter.cc ('k') | ui/gfx/canvas.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698