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

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

Issue 22978012: Split SkDevice into SkBaseDevice and SkBitmapDevice (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Updating to ToT (10994) Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/core/SkBitmapDevice.h ('k') | include/core/SkDevice.h » ('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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkCanvas_DEFINED 10 #ifndef SkCanvas_DEFINED
11 #define SkCanvas_DEFINED 11 #define SkCanvas_DEFINED
12 12
13 #include "SkTypes.h" 13 #include "SkTypes.h"
14 #include "SkBitmap.h" 14 #include "SkBitmap.h"
15 #include "SkDeque.h" 15 #include "SkDeque.h"
16 #include "SkClipStack.h" 16 #include "SkClipStack.h"
17 #include "SkPaint.h" 17 #include "SkPaint.h"
18 #include "SkRefCnt.h" 18 #include "SkRefCnt.h"
19 #include "SkPath.h" 19 #include "SkPath.h"
20 #include "SkRegion.h" 20 #include "SkRegion.h"
21 #include "SkScalarCompare.h" 21 #include "SkScalarCompare.h"
22 #include "SkXfermode.h" 22 #include "SkXfermode.h"
23 23
24 class SkBounder; 24 class SkBounder;
25 class SkDevice; 25 class SkBaseDevice;
26 class SkDraw; 26 class SkDraw;
27 class SkDrawFilter; 27 class SkDrawFilter;
28 class SkMetaData; 28 class SkMetaData;
29 class SkPicture; 29 class SkPicture;
30 class SkRRect; 30 class SkRRect;
31 class SkSurface_Base; 31 class SkSurface_Base;
32 32
33 /** \class SkCanvas 33 /** \class SkCanvas
34 34
35 A Canvas encapsulates all of the state about drawing into a device (bitmap). 35 A Canvas encapsulates all of the state about drawing into a device (bitmap).
(...skipping 12 matching lines...) Expand all
48 class SK_API SkCanvas : public SkRefCnt { 48 class SK_API SkCanvas : public SkRefCnt {
49 public: 49 public:
50 SK_DECLARE_INST_COUNT(SkCanvas) 50 SK_DECLARE_INST_COUNT(SkCanvas)
51 51
52 SkCanvas(); 52 SkCanvas();
53 53
54 /** Construct a canvas with the specified device to draw into. 54 /** Construct a canvas with the specified device to draw into.
55 55
56 @param device Specifies a device for the canvas to draw into. 56 @param device Specifies a device for the canvas to draw into.
57 */ 57 */
58 explicit SkCanvas(SkDevice* device); 58 explicit SkCanvas(SkBaseDevice* device);
59 59
60 /** Deprecated - Construct a canvas with the specified bitmap to draw into. 60 /** Deprecated - Construct a canvas with the specified bitmap to draw into.
61 @param bitmap Specifies a bitmap for the canvas to draw into. Its 61 @param bitmap Specifies a bitmap for the canvas to draw into. Its
62 structure are copied to the canvas. 62 structure are copied to the canvas.
63 */ 63 */
64 explicit SkCanvas(const SkBitmap& bitmap); 64 explicit SkCanvas(const SkBitmap& bitmap);
65 virtual ~SkCanvas(); 65 virtual ~SkCanvas();
66 66
67 SkMetaData& getMetaData(); 67 SkMetaData& getMetaData();
68 68
69 /////////////////////////////////////////////////////////////////////////// 69 ///////////////////////////////////////////////////////////////////////////
70 70
71 /** 71 /**
72 * Trigger the immediate execution of all pending draw operations. 72 * Trigger the immediate execution of all pending draw operations.
73 */ 73 */
74 void flush(); 74 void flush();
75 75
76 /** 76 /**
77 * Return the width/height of the underlying device. The current drawable 77 * Return the width/height of the underlying device. The current drawable
78 * area may be small (due to clipping or saveLayer). For a canvas with 78 * area may be small (due to clipping or saveLayer). For a canvas with
79 * no device, 0,0 will be returned. 79 * no device, 0,0 will be returned.
80 */ 80 */
81 SkISize getDeviceSize() const; 81 SkISize getDeviceSize() const;
82 82
83 /** Return the canvas' device object, which may be null. The device holds 83 /** Return the canvas' device object, which may be null. The device holds
84 the bitmap of the pixels that the canvas draws into. The reference count 84 the bitmap of the pixels that the canvas draws into. The reference count
85 of the returned device is not changed by this call. 85 of the returned device is not changed by this call.
86 */ 86 */
87 SkDevice* getDevice() const; 87 SkBaseDevice* getDevice() const;
88 88
89 /** 89 /**
90 * saveLayer() can create another device (which is later drawn onto 90 * saveLayer() can create another device (which is later drawn onto
91 * the previous device). getTopDevice() returns the top-most device current 91 * the previous device). getTopDevice() returns the top-most device current
92 * installed. Note that this can change on other calls like save/restore, 92 * installed. Note that this can change on other calls like save/restore,
93 * so do not access this device after subsequent canvas calls. 93 * so do not access this device after subsequent canvas calls.
94 * The reference count of the device is not changed. 94 * The reference count of the device is not changed.
95 * 95 *
96 * @param updateMatrixClip If this is true, then before the device is 96 * @param updateMatrixClip If this is true, then before the device is
97 * returned, we ensure that its has been notified about the current 97 * returned, we ensure that its has been notified about the current
98 * matrix and clip. Note: this happens automatically when the device 98 * matrix and clip. Note: this happens automatically when the device
99 * is drawn to, but is optional here, as there is a small perf hit 99 * is drawn to, but is optional here, as there is a small perf hit
100 * sometimes. 100 * sometimes.
101 */ 101 */
102 SkDevice* getTopDevice(bool updateMatrixClip = false) const; 102 SkBaseDevice* getTopDevice(bool updateMatrixClip = false) const;
103 103
104 /** 104 /**
105 * Shortcut for getDevice()->createCompatibleDevice(...). 105 * Shortcut for getDevice()->createCompatibleDevice(...).
106 * If getDevice() == NULL, this method does nothing, and returns NULL. 106 * If getDevice() == NULL, this method does nothing, and returns NULL.
107 */ 107 */
108 SkDevice* createCompatibleDevice(SkBitmap::Config config, 108 SkBaseDevice* createCompatibleDevice(SkBitmap::Config config,
109 int width, int height, 109 int width, int height,
110 bool isOpaque); 110 bool isOpaque);
111 111
112 /////////////////////////////////////////////////////////////////////////// 112 ///////////////////////////////////////////////////////////////////////////
113 113
114 /** 114 /**
115 * This enum can be used with read/writePixels to perform a pixel ops to or 115 * This enum can be used with read/writePixels to perform a pixel ops to or
116 * from an 8888 config other than Skia's native config (SkPMColor). There 116 * from an 8888 config other than Skia's native config (SkPMColor). There
117 * are three byte orders supported: native, BGRA, and RGBA. Each has a 117 * are three byte orders supported: native, BGRA, and RGBA. Each has a
118 * premultiplied and unpremultiplied variant. 118 * premultiplied and unpremultiplied variant.
119 * 119 *
120 * Components of a 8888 pixel can be packed/unpacked from a 32bit word using 120 * Components of a 8888 pixel can be packed/unpacked from a 32bit word using
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 LayerIter(SkCanvas*, bool skipEmptyClips); 987 LayerIter(SkCanvas*, bool skipEmptyClips);
988 ~LayerIter(); 988 ~LayerIter();
989 989
990 /** Return true if the iterator is done */ 990 /** Return true if the iterator is done */
991 bool done() const { return fDone; } 991 bool done() const { return fDone; }
992 /** Cycle to the next device */ 992 /** Cycle to the next device */
993 void next(); 993 void next();
994 994
995 // These reflect the current device in the iterator 995 // These reflect the current device in the iterator
996 996
997 SkDevice* device() const; 997 SkBaseDevice* device() const;
998 const SkMatrix& matrix() const; 998 const SkMatrix& matrix() const;
999 const SkRegion& clip() const; 999 const SkRegion& clip() const;
1000 const SkPaint& paint() const; 1000 const SkPaint& paint() const;
1001 int x() const; 1001 int x() const;
1002 int y() const; 1002 int y() const;
1003 1003
1004 private: 1004 private:
1005 // used to embed the SkDrawIter object directly in our instance, w/o 1005 // used to embed the SkDrawIter object directly in our instance, w/o
1006 // having to expose that class def to the public. There is an assert 1006 // having to expose that class def to the public. There is an assert
1007 // in our constructor to ensure that fStorage is large enough 1007 // in our constructor to ensure that fStorage is large enough
(...skipping 28 matching lines...) Expand all
1036 1036
1037 /** DEPRECATED -- use constructor(device) 1037 /** DEPRECATED -- use constructor(device)
1038 1038
1039 Marked as 'protected' to avoid new clients using this before we can 1039 Marked as 'protected' to avoid new clients using this before we can
1040 completely remove it. 1040 completely remove it.
1041 1041
1042 Specify a device for this canvas to draw into. If it is not null, its 1042 Specify a device for this canvas to draw into. If it is not null, its
1043 reference count is incremented. If the canvas was already holding a 1043 reference count is incremented. If the canvas was already holding a
1044 device, its reference count is decremented. The new device is returned. 1044 device, its reference count is decremented. The new device is returned.
1045 */ 1045 */
1046 virtual SkDevice* setDevice(SkDevice* device); 1046 virtual SkBaseDevice* setDevice(SkBaseDevice* device);
1047 1047
1048 private: 1048 private:
1049 class MCRec; 1049 class MCRec;
1050 1050
1051 SkClipStack fClipStack; 1051 SkClipStack fClipStack;
1052 SkDeque fMCStack; 1052 SkDeque fMCStack;
1053 // points to top of stack 1053 // points to top of stack
1054 MCRec* fMCRec; 1054 MCRec* fMCRec;
1055 // the first N recs that can fit here mean we won't call malloc 1055 // the first N recs that can fit here mean we won't call malloc
1056 uint32_t fMCRecStorage[32]; 1056 uint32_t fMCRecStorage[32];
(...skipping 10 matching lines...) Expand all
1067 } 1067 }
1068 friend class SkSurface_Base; 1068 friend class SkSurface_Base;
1069 friend class SkSurface_Gpu; 1069 friend class SkSurface_Gpu;
1070 1070
1071 bool fDeviceCMDirty; // cleared by updateDeviceCMCache() 1071 bool fDeviceCMDirty; // cleared by updateDeviceCMCache()
1072 void updateDeviceCMCache(); 1072 void updateDeviceCMCache();
1073 1073
1074 friend class SkDrawIter; // needs setupDrawForLayerDevice() 1074 friend class SkDrawIter; // needs setupDrawForLayerDevice()
1075 friend class AutoDrawLooper; 1075 friend class AutoDrawLooper;
1076 1076
1077 SkDevice* createLayerDevice(SkBitmap::Config, int width, int height, 1077 SkBaseDevice* createLayerDevice(SkBitmap::Config, int width, int height,
1078 bool isOpaque); 1078 bool isOpaque);
1079 1079
1080 SkDevice* init(SkDevice*); 1080 SkBaseDevice* init(SkBaseDevice*);
1081 1081
1082 // internal methods are not virtual, so they can safely be called by other 1082 // internal methods are not virtual, so they can safely be called by other
1083 // canvas apis, without confusing subclasses (like SkPictureRecording) 1083 // canvas apis, without confusing subclasses (like SkPictureRecording)
1084 void internalDrawBitmap(const SkBitmap&, const SkMatrix& m, const SkPaint* p aint); 1084 void internalDrawBitmap(const SkBitmap&, const SkMatrix& m, const SkPaint* p aint);
1085 void internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src, 1085 void internalDrawBitmapRect(const SkBitmap& bitmap, const SkRect* src,
1086 const SkRect& dst, const SkPaint* paint, 1086 const SkRect& dst, const SkPaint* paint,
1087 DrawBitmapRectFlags flags); 1087 DrawBitmapRectFlags flags);
1088 void internalDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center, 1088 void internalDrawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
1089 const SkRect& dst, const SkPaint* paint); 1089 const SkRect& dst, const SkPaint* paint);
1090 void internalDrawPaint(const SkPaint& paint); 1090 void internalDrawPaint(const SkPaint& paint);
1091 int internalSaveLayer(const SkRect* bounds, const SkPaint* paint, 1091 int internalSaveLayer(const SkRect* bounds, const SkPaint* paint,
1092 SaveFlags, bool justForImageFilter); 1092 SaveFlags, bool justForImageFilter);
1093 void internalDrawDevice(SkDevice*, int x, int y, const SkPaint*); 1093 void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*);
1094 1094
1095 // shared by save() and saveLayer() 1095 // shared by save() and saveLayer()
1096 int internalSave(SaveFlags flags); 1096 int internalSave(SaveFlags flags);
1097 void internalRestore(); 1097 void internalRestore();
1098 static void DrawRect(const SkDraw& draw, const SkPaint& paint, 1098 static void DrawRect(const SkDraw& draw, const SkPaint& paint,
1099 const SkRect& r, SkScalar textSize); 1099 const SkRect& r, SkScalar textSize);
1100 static void DrawTextDecorations(const SkDraw& draw, const SkPaint& paint, 1100 static void DrawTextDecorations(const SkDraw& draw, const SkPaint& paint,
1101 const char text[], size_t byteLength, 1101 const char text[], size_t byteLength,
1102 SkScalar x, SkScalar y); 1102 SkScalar x, SkScalar y);
1103 1103
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 if (NULL != fCanvas) { 1189 if (NULL != fCanvas) {
1190 fCanvas->endCommentGroup(); 1190 fCanvas->endCommentGroup();
1191 } 1191 }
1192 } 1192 }
1193 1193
1194 private: 1194 private:
1195 SkCanvas* fCanvas; 1195 SkCanvas* fCanvas;
1196 }; 1196 };
1197 1197
1198 #endif 1198 #endif
OLDNEW
« no previous file with comments | « include/core/SkBitmapDevice.h ('k') | include/core/SkDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698