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

Unified Diff: ui/gfx/image/canvas_image_source.h

Issue 2373633002: Improve ergonomics of CanvasImageSource -> gfx::ImageSkia. (Closed)
Patch Set: Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/gfx/image/canvas_image_source.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/image/canvas_image_source.h
diff --git a/ui/gfx/image/canvas_image_source.h b/ui/gfx/image/canvas_image_source.h
index f41c2814c0a81a59b86cf07da949a5b0d0c80284..55cb7a6c286219a5d595001524de95e33179b4b4 100644
--- a/ui/gfx/image/canvas_image_source.h
+++ b/ui/gfx/image/canvas_image_source.h
@@ -7,8 +7,10 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/gfx_export.h"
+#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_source.h"
namespace gfx {
@@ -21,6 +23,15 @@ class ImageSkiaRep;
// completed.
class GFX_EXPORT CanvasImageSource : public gfx::ImageSkiaSource {
public:
+ template <typename T, typename... Args>
Robert Sesek 2016/09/26 21:59:53 Should have a comment here.
Evan Stade 2016/09/28 01:52:34 Done.
+ static ImageSkia MakeImageSkia(Args&&... args) {
+ auto source = base::MakeUnique<T>(std::forward<Args>(args)...);
+ gfx::Size size = source->size();
oshima 2016/09/27 22:50:26 why not just do this inline below?
Evan Stade 2016/09/28 01:52:34 source.release() invalidates source and we don't k
+ return gfx::ImageSkia(source.release(), size);
+ }
+
+ ~CanvasImageSource() override {}
Robert Sesek 2016/09/26 21:59:53 Place the dtor after the ctor.
Evan Stade 2016/09/28 01:52:34 Done.
+
CanvasImageSource(const gfx::Size& size, bool is_opaque);
// Called when a new image needs to be drawn for a scale factor.
@@ -33,8 +44,6 @@ class GFX_EXPORT CanvasImageSource : public gfx::ImageSkiaSource {
gfx::ImageSkiaRep GetImageForScale(float scale) override;
protected:
- ~CanvasImageSource() override {}
-
const gfx::Size size_;
const bool is_opaque_;
DISALLOW_COPY_AND_ASSIGN(CanvasImageSource);
« no previous file with comments | « no previous file | ui/gfx/image/canvas_image_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698