OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
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 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 struct GrSkDrawProcs; | 22 struct GrSkDrawProcs; |
23 | 23 |
24 class GrTextContext; | 24 class GrTextContext; |
25 | 25 |
26 /** | 26 /** |
27 * Subclass of SkBitmapDevice, which directs all drawing to the GrGpu owned by
the | 27 * Subclass of SkBitmapDevice, which directs all drawing to the GrGpu owned by
the |
28 * canvas. | 28 * canvas. |
29 */ | 29 */ |
30 class SK_API SkGpuDevice : public SkBitmapDevice { | 30 class SK_API SkGpuDevice : public SkBitmapDevice { |
31 public: | 31 public: |
| 32 enum Flags { |
| 33 kNeedClear_Flag = 1 << 0, //!< Surface requires an initial clear |
| 34 kCached_Flag = 1 << 1, //!< Surface is cached and needs to be unlock
ed when released |
| 35 }; |
32 | 36 |
33 /** | 37 /** |
34 * Creates an SkGpuDevice from a GrSurface. This will fail if the surface is
not a render | 38 * Creates an SkGpuDevice from a GrSurface. This will fail if the surface is
not a render |
35 * target. The caller owns a ref on the returned device. | 39 * target. The caller owns a ref on the returned device. If the surface is c
ached, |
| 40 * the kCached_Flag should be specified to make the device responsible for u
nlocking |
| 41 * the surface when it is released. |
36 */ | 42 */ |
37 static SkGpuDevice* Create(GrSurface* surface); | 43 static SkGpuDevice* Create(GrSurface* surface, unsigned flags = 0); |
38 | 44 |
39 /** | 45 /** |
40 * New device that will create an offscreen renderTarget based on the | 46 * New device that will create an offscreen renderTarget based on the |
41 * ImageInfo and sampleCount. The device's storage will not | 47 * ImageInfo and sampleCount. The device's storage will not |
42 * count against the GrContext's texture cache budget. The device's pixels | 48 * count against the GrContext's texture cache budget. The device's pixels |
43 * will be uninitialized. On failure, returns NULL. | 49 * will be uninitialized. On failure, returns NULL. |
44 */ | 50 */ |
45 static SkGpuDevice* Create(GrContext*, const SkImageInfo&, int sampleCount); | 51 static SkGpuDevice* Create(GrContext*, const SkImageInfo&, int sampleCount); |
46 | 52 |
47 #ifdef SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG | 53 #ifdef SK_SUPPORT_LEGACY_COMPATIBLEDEVICE_CONFIG |
48 /** | 54 /** |
49 * New device that will create an offscreen renderTarget based on the | 55 * New device that will create an offscreen renderTarget based on the |
50 * config, width, height, and sampleCount. The device's storage will not | 56 * config, width, height, and sampleCount. The device's storage will not |
51 * count against the GrContext's texture cache budget. The device's pixels | 57 * count against the GrContext's texture cache budget. The device's pixels |
52 * will be uninitialized. TODO: This can fail, replace with a factory funct
ion. | 58 * will be uninitialized. TODO: This can fail, replace with a factory funct
ion. |
53 */ | 59 */ |
54 SkGpuDevice(GrContext*, SkBitmap::Config, int width, int height, int sampleC
ount = 0); | 60 SkGpuDevice(GrContext*, SkBitmap::Config, int width, int height, int sampleC
ount = 0); |
55 #endif | 61 #endif |
56 | 62 |
57 /** | 63 /** |
58 * DEPRECATED -- need to make this private, call Create(surface) | 64 * DEPRECATED -- need to make this private, call Create(surface) |
59 * New device that will render to the specified renderTarget. | 65 * New device that will render to the specified renderTarget. |
60 */ | 66 */ |
61 SkGpuDevice(GrContext*, GrRenderTarget*); | 67 SkGpuDevice(GrContext*, GrRenderTarget*, unsigned flags = 0); |
62 | 68 |
63 /** | 69 /** |
64 * DEPRECATED -- need to make this private, call Create(surface) | 70 * DEPRECATED -- need to make this private, call Create(surface) |
65 * New device that will render to the texture (as a rendertarget). | 71 * New device that will render to the texture (as a rendertarget). |
66 * The GrTexture's asRenderTarget() must be non-NULL or device will not | 72 * The GrTexture's asRenderTarget() must be non-NULL or device will not |
67 * function. | 73 * function. |
68 */ | 74 */ |
69 SkGpuDevice(GrContext*, GrTexture*); | 75 SkGpuDevice(GrContext*, GrTexture*, unsigned flags = 0); |
70 | 76 |
71 virtual ~SkGpuDevice(); | 77 virtual ~SkGpuDevice(); |
72 | 78 |
73 GrContext* context() const { return fContext; } | 79 GrContext* context() const { return fContext; } |
74 | 80 |
75 virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE; | 81 virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE; |
76 | 82 |
77 // overrides from SkBaseDevice | 83 // overrides from SkBaseDevice |
78 virtual int width() const SK_OVERRIDE { | 84 virtual int width() const SK_OVERRIDE { |
79 return NULL == fRenderTarget ? 0 : fRenderTarget->width(); | 85 return NULL == fRenderTarget ? 0 : fRenderTarget->width(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 GrClipData fClipData; | 170 GrClipData fClipData; |
165 | 171 |
166 GrTextContext* fMainTextContext; | 172 GrTextContext* fMainTextContext; |
167 GrTextContext* fFallbackTextContext; | 173 GrTextContext* fFallbackTextContext; |
168 | 174 |
169 // state for our render-target | 175 // state for our render-target |
170 GrRenderTarget* fRenderTarget; | 176 GrRenderTarget* fRenderTarget; |
171 bool fNeedClear; | 177 bool fNeedClear; |
172 | 178 |
173 // called from rt and tex cons | 179 // called from rt and tex cons |
174 void initFromRenderTarget(GrContext*, GrRenderTarget*, bool cached); | 180 void initFromRenderTarget(GrContext*, GrRenderTarget*, unsigned flags); |
175 | |
176 // used by createCompatibleDevice | |
177 SkGpuDevice(GrContext*, GrTexture* texture, bool needClear); | |
178 | 181 |
179 virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE; | 182 virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE; |
180 | 183 |
181 virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE; | 184 virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE; |
182 | 185 |
183 // sets the render target, clip, and matrix on GrContext. Use forceIdenity t
o override | 186 // sets the render target, clip, and matrix on GrContext. Use forceIdenity t
o override |
184 // SkDraw's matrix and draw in device coords. | 187 // SkDraw's matrix and draw in device coords. |
185 void prepareDraw(const SkDraw&, bool forceIdentity); | 188 void prepareDraw(const SkDraw&, bool forceIdentity); |
186 | 189 |
187 /** | 190 /** |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 SkCanvas::DrawBitmapRectFlags flags, | 223 SkCanvas::DrawBitmapRectFlags flags, |
221 int tileSize, | 224 int tileSize, |
222 bool bicubic); | 225 bool bicubic); |
223 | 226 |
224 static SkPicture::AccelData::Key ComputeAccelDataKey(); | 227 static SkPicture::AccelData::Key ComputeAccelDataKey(); |
225 | 228 |
226 typedef SkBitmapDevice INHERITED; | 229 typedef SkBitmapDevice INHERITED; |
227 }; | 230 }; |
228 | 231 |
229 #endif | 232 #endif |
OLD | NEW |