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

Side by Side Diff: include/core/SkCanvas.h

Issue 154163002: remove SkCanvas::createCompatibleDevice, and add SkCanvas::newSurface (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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
OLDNEW
1
2 /* 1 /*
3 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
4 * 3 *
5 * 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
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
8 7
9
10 #ifndef SkCanvas_DEFINED 8 #ifndef SkCanvas_DEFINED
11 #define SkCanvas_DEFINED 9 #define SkCanvas_DEFINED
12 10
13 #include "SkTypes.h" 11 #include "SkTypes.h"
14 #include "SkBitmap.h" 12 #include "SkBitmap.h"
15 #include "SkDeque.h" 13 #include "SkDeque.h"
16 #include "SkClipStack.h" 14 #include "SkClipStack.h"
17 #include "SkPaint.h" 15 #include "SkPaint.h"
18 #include "SkRefCnt.h" 16 #include "SkRefCnt.h"
19 #include "SkPath.h" 17 #include "SkPath.h"
20 #include "SkRegion.h" 18 #include "SkRegion.h"
21 #include "SkXfermode.h" 19 #include "SkXfermode.h"
22 20
21 //#define SK_SUPPORT_LEGACY_CANVAS_CREATECOMPATIBLEDEVICE
22
23 class SkBounder; 23 class SkBounder;
24 class SkBaseDevice; 24 class SkBaseDevice;
25 class SkDraw; 25 class SkDraw;
26 class SkDrawFilter; 26 class SkDrawFilter;
27 class SkMetaData; 27 class SkMetaData;
28 class SkPicture; 28 class SkPicture;
29 class SkRRect; 29 class SkRRect;
30 class SkSurface;
30 class SkSurface_Base; 31 class SkSurface_Base;
31 class GrContext; 32 class GrContext;
32 33
33 /** \class SkCanvas 34 /** \class SkCanvas
34 35
35 A Canvas encapsulates all of the state about drawing into a device (bitmap). 36 A Canvas encapsulates all of the state about drawing into a device (bitmap).
36 This includes a reference to the device itself, and a stack of matrix/clip 37 This includes a reference to the device itself, and a stack of matrix/clip
37 values. For any given draw call (e.g. drawRect), the geometry of the object 38 values. For any given draw call (e.g. drawRect), the geometry of the object
38 being drawn is transformed by the concatenation of all the matrices in the 39 being drawn is transformed by the concatenation of all the matrices in the
39 stack. The transformed geometry is clipped by the intersection of all of 40 stack. The transformed geometry is clipped by the intersection of all of
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 * The reference count of the device is not changed. 106 * The reference count of the device is not changed.
106 * 107 *
107 * @param updateMatrixClip If this is true, then before the device is 108 * @param updateMatrixClip If this is true, then before the device is
108 * returned, we ensure that its has been notified about the current 109 * returned, we ensure that its has been notified about the current
109 * matrix and clip. Note: this happens automatically when the device 110 * matrix and clip. Note: this happens automatically when the device
110 * is drawn to, but is optional here, as there is a small perf hit 111 * is drawn to, but is optional here, as there is a small perf hit
111 * sometimes. 112 * sometimes.
112 */ 113 */
113 SkBaseDevice* getTopDevice(bool updateMatrixClip = false) const; 114 SkBaseDevice* getTopDevice(bool updateMatrixClip = false) const;
114 115
116 #ifdef SK_SUPPORT_LEGACY_CANVAS_CREATECOMPATIBLEDEVICE
115 /** 117 /**
116 * Shortcut for getDevice()->createCompatibleDevice(...). 118 * Shortcut for getDevice()->createCompatibleDevice(...).
117 * If getDevice() == NULL, this method does nothing, and returns NULL. 119 * If getDevice() == NULL, this method does nothing, and returns NULL.
118 */ 120 */
119 SkBaseDevice* createCompatibleDevice(SkBitmap::Config config, 121 SkBaseDevice* createCompatibleDevice(SkBitmap::Config config,
120 int width, int height, 122 int width, int height,
121 bool isOpaque); 123 bool isOpaque);
124 #endif
125
126 /**
127 * Create a new surface matching the specified info, one that attempts to
128 * be maximally compatible when used with this canvas.
scroggo 2014/02/05 16:41:12 What does it mean to be used with this canvas? Dra
129 */
130 SkSurface* newSurface(const SkImageInfo&);
122 131
123 /** 132 /**
124 * Return the GPU context of the device that is associated with the canvas. 133 * Return the GPU context of the device that is associated with the canvas.
125 * For a canvas with non-GPU device, NULL is returned. 134 * For a canvas with non-GPU device, NULL is returned.
126 */ 135 */
127 GrContext* getGrContext(); 136 GrContext* getGrContext();
128 137
129 /////////////////////////////////////////////////////////////////////////// 138 ///////////////////////////////////////////////////////////////////////////
130 139
131 /** 140 /**
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 // in our constructor to ensure that fStorage is large enough 1021 // in our constructor to ensure that fStorage is large enough
1013 // (though needs to be a compile-time-assert!). We use intptr_t to work 1022 // (though needs to be a compile-time-assert!). We use intptr_t to work
1014 // safely with 32 and 64 bit machines (to ensure the storage is enough) 1023 // safely with 32 and 64 bit machines (to ensure the storage is enough)
1015 intptr_t fStorage[32]; 1024 intptr_t fStorage[32];
1016 class SkDrawIter* fImpl; // this points at fStorage 1025 class SkDrawIter* fImpl; // this points at fStorage
1017 SkPaint fDefaultPaint; 1026 SkPaint fDefaultPaint;
1018 bool fDone; 1027 bool fDone;
1019 }; 1028 };
1020 1029
1021 protected: 1030 protected:
1031 // default impl defers to getDevice()->newSurface(info)
1032 virtual SkSurface* onNewSurface(const SkImageInfo&);
1033
1022 // Returns the canvas to be used by DrawIter. Default implementation 1034 // Returns the canvas to be used by DrawIter. Default implementation
1023 // returns this. Subclasses that encapsulate an indirect canvas may 1035 // returns this. Subclasses that encapsulate an indirect canvas may
1024 // need to overload this method. The impl must keep track of this, as it 1036 // need to overload this method. The impl must keep track of this, as it
1025 // is not released or deleted by the caller. 1037 // is not released or deleted by the caller.
1026 virtual SkCanvas* canvasForDrawIter(); 1038 virtual SkCanvas* canvasForDrawIter();
1027 1039
1028 // Clip rectangle bounds. Called internally by saveLayer. 1040 // Clip rectangle bounds. Called internally by saveLayer.
1029 // returns false if the entire rectangle is entirely clipped out 1041 // returns false if the entire rectangle is entirely clipped out
1030 bool clipRectBounds(const SkRect* bounds, SaveFlags flags, 1042 bool clipRectBounds(const SkRect* bounds, SaveFlags flags,
1031 SkIRect* intersection); 1043 SkIRect* intersection);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 fCanvas->endCommentGroup(); 1209 fCanvas->endCommentGroup();
1198 } 1210 }
1199 } 1211 }
1200 1212
1201 private: 1213 private:
1202 SkCanvas* fCanvas; 1214 SkCanvas* fCanvas;
1203 }; 1215 };
1204 #define SkAutoCommentBlock(...) SK_REQUIRE_LOCAL_VAR(SkAutoCommentBlock) 1216 #define SkAutoCommentBlock(...) SK_REQUIRE_LOCAL_VAR(SkAutoCommentBlock)
1205 1217
1206 #endif 1218 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698