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

Side by Side Diff: include/utils/SkDeferredCanvas.h

Issue 16040002: Changing SkDeferredCanvas to use factories for creation (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « gm/gmmain.cpp ('k') | src/utils/SkDeferredCanvas.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkDeferredCanvas_DEFINED 8 #ifndef SkDeferredCanvas_DEFINED
9 #define SkDeferredCanvas_DEFINED 9 #define SkDeferredCanvas_DEFINED
10 10
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 #include "SkPixelRef.h" 12 #include "SkPixelRef.h"
13 13
14 class DeferredDevice; 14 class DeferredDevice;
15 class SkImage; 15 class SkImage;
16 class SkSurface; 16 class SkSurface;
17 17
18 #if !defined(SK_DEFERRED_CANVAS_USES_FACTORIES)
19 // This is temporary, for rolling the API change into Chromium/Blink
20 #define SK_DEFERRED_CANVAS_USES_FACTORIES 0
21 #endif
22
18 /** \class SkDeferredCanvas 23 /** \class SkDeferredCanvas
19 Subclass of SkCanvas that encapsulates an SkPicture or SkGPipe for deferred 24 Subclass of SkCanvas that encapsulates an SkPicture or SkGPipe for deferred
20 drawing. The main difference between this class and SkPictureRecord (the 25 drawing. The main difference between this class and SkPictureRecord (the
21 canvas provided by SkPicture) is that this is a full drop-in replacement 26 canvas provided by SkPicture) is that this is a full drop-in replacement
22 for SkCanvas, while SkPictureRecord only supports draw operations. 27 for SkCanvas, while SkPictureRecord only supports draw operations.
23 SkDeferredCanvas will transparently trigger the flushing of deferred 28 SkDeferredCanvas will transparently trigger the flushing of deferred
24 draw operations when an attempt is made to access the pixel data. 29 draw operations when an attempt is made to access the pixel data.
25 */ 30 */
26 class SK_API SkDeferredCanvas : public SkCanvas { 31 class SK_API SkDeferredCanvas : public SkCanvas {
27 public: 32 public:
28 class NotificationClient; 33 class NotificationClient;
29 34
35 #if SK_DEFERRED_CANVAS_USES_FACTORIES
reed1 2013/05/28 12:55:18 Why do we need to ever hide the new methods?
36 /** Construct a canvas with the specified device to draw into.
37 @param device Specifies a device for the canvas to draw into.
38 */
39 static SkDeferredCanvas* create(SkDevice* device);
reed1 2013/05/28 12:55:18 Static methods are Capitalized.
reed1 2013/05/28 12:55:18 Do we really need to expose a version that takes a
Justin Novosad 2013/05/28 14:05:30 It would require a whole lot of work in our test p
40
41 /** Construct a canvas with the specified surface to draw into.
42 This factory must be used for newImageSnapshot to work.
43 @param surface Specifies a surface for the canvas to draw into.
44 */
45 static SkDeferredCanvas* create(SkSurface* surface);
46 #else
47 /** DEPRECATED
48 */
30 SkDeferredCanvas(); 49 SkDeferredCanvas();
31 50
32 /** Construct a canvas with the specified device to draw into. 51 /** DEPRACATED, use create instead
52 Construct a canvas with the specified device to draw into.
33 Equivalent to calling default constructor, then setDevice. 53 Equivalent to calling default constructor, then setDevice.
34 @param device Specifies a device for the canvas to draw into. 54 @param device Specifies a device for the canvas to draw into.
35 */ 55 */
36 explicit SkDeferredCanvas(SkDevice* device); 56 explicit SkDeferredCanvas(SkDevice* device);
37 57
38 /** Construct a canvas with the specified surface to draw into. 58 /** DEPRECATED, use create instead
59 Construct a canvas with the specified surface to draw into.
39 This constructor must be used for newImageSnapshot to work. 60 This constructor must be used for newImageSnapshot to work.
40 @param surface Specifies a surface for the canvas to draw into. 61 @param surface Specifies a surface for the canvas to draw into.
41 */ 62 */
42 explicit SkDeferredCanvas(SkSurface* surface); 63 explicit SkDeferredCanvas(SkSurface* surface);
64 #endif
43 65
44 virtual ~SkDeferredCanvas(); 66 virtual ~SkDeferredCanvas();
45 67
46 /** 68 /** DEPRECATED
47 * Specify a device to be used by this canvas. Calling setDevice will 69 * Specify a device to be used by this canvas. Calling setDevice will
48 * release the previously set device, if any. Takes a reference on the 70 * release the previously set device, if any. Takes a reference on the
49 * device. 71 * device.
50 * 72 *
51 * @param device The device that the canvas will raw into 73 * @param device The device that the canvas will raw into
52 * @return The device argument, for convenience. 74 * @return The device argument, for convenience.
53 */ 75 */
54 virtual SkDevice* setDevice(SkDevice* device); 76 virtual SkDevice* setDevice(SkDevice* device);
55 77
56 /** 78 /**
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 * or completely overwritten by the command currently being recorded. 269 * or completely overwritten by the command currently being recorded.
248 */ 270 */
249 virtual void skippedPendingDrawCommands() {} 271 virtual void skippedPendingDrawCommands() {}
250 }; 272 };
251 273
252 protected: 274 protected:
253 virtual SkCanvas* canvasForDrawIter(); 275 virtual SkCanvas* canvasForDrawIter();
254 DeferredDevice* getDeferredDevice() const; 276 DeferredDevice* getDeferredDevice() const;
255 277
256 private: 278 private:
279 #if SK_DEFERRED_CANVAS_USES_FACTORIES
280 SkDeferredCanvas(DeferredDevice*);
281 #endif
282
257 void recordedDrawCommand(); 283 void recordedDrawCommand();
258 SkCanvas* drawingCanvas() const; 284 SkCanvas* drawingCanvas() const;
259 SkCanvas* immediateCanvas() const; 285 SkCanvas* immediateCanvas() const;
260 bool isFullFrame(const SkRect*, const SkPaint*) const; 286 bool isFullFrame(const SkRect*, const SkPaint*) const;
261 void validate() const; 287 void validate() const;
262 void init(); 288 void init();
263 bool fDeferredDrawing; 289 bool fDeferredDrawing;
264 290
265 friend class SkDeferredCanvasTester; // for unit testing 291 friend class SkDeferredCanvasTester; // for unit testing
266 typedef SkCanvas INHERITED; 292 typedef SkCanvas INHERITED;
267 }; 293 };
268 294
269 295
270 #endif 296 #endif
OLDNEW
« no previous file with comments | « gm/gmmain.cpp ('k') | src/utils/SkDeferredCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698