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 |
11 #ifndef SkGpuDevice_DEFINED | 11 #ifndef SkGpuDevice_DEFINED |
12 #define SkGpuDevice_DEFINED | 12 #define SkGpuDevice_DEFINED |
13 | 13 |
14 #include "SkGr.h" | 14 #include "SkGr.h" |
15 #include "SkBitmap.h" | 15 #include "SkBitmap.h" |
16 #include "SkDevice.h" | 16 #include "SkDevice.h" |
17 #include "SkRegion.h" | 17 #include "SkRegion.h" |
18 #include "GrContext.h" | 18 #include "GrContext.h" |
19 | 19 |
20 struct SkDrawProcs; | 20 struct SkDrawProcs; |
21 struct GrSkDrawProcs; | 21 struct GrSkDrawProcs; |
22 class GrTextContext; | 22 class GrTextContext; |
23 | 23 |
24 /** | 24 /** |
25 * Subclass of SkDevice, which directs all drawing to the GrGpu owned by the | 25 * Subclass of SkDevice, which directs all drawing to the GrGpu owned by the |
26 * canvas. | 26 * canvas. |
27 */ | 27 */ |
28 class SK_API SkGpuDevice : public SkDevice { | 28 class SK_API SkGpuDevice : public SkDevice { |
29 public: | 29 public: |
| 30 |
| 31 /** |
| 32 * Creates an SkGpuDevice from a GrSurface. This will fail if the surface is
not a render |
| 33 * target. The caller owns a ref on the returned device. |
| 34 */ |
| 35 static SkGpuDevice* Create(GrSurface* surface); |
| 36 |
30 /** | 37 /** |
31 * New device that will create an offscreen renderTarget based on the | 38 * New device that will create an offscreen renderTarget based on the |
32 * config, width, height, and sampleCount. The device's storage will not | 39 * config, width, height, and sampleCount. The device's storage will not |
33 * count against the GrContext's texture cache budget. The device's pixels | 40 * count against the GrContext's texture cache budget. The device's pixels |
34 * will be uninitialized. | 41 * will be uninitialized. TODO: This can fail, replace with a factory funct
ion. |
35 */ | 42 */ |
36 SkGpuDevice(GrContext*, SkBitmap::Config, int width, int height, int sampleC
ount = 0); | 43 SkGpuDevice(GrContext*, SkBitmap::Config, int width, int height, int sampleC
ount = 0); |
37 | 44 |
38 /** | 45 /** |
39 * New device that will render to the specified renderTarget. | 46 * New device that will render to the specified renderTarget. |
| 47 * DEPRECATED: Use Create(surface) |
40 */ | 48 */ |
41 SkGpuDevice(GrContext*, GrRenderTarget*); | 49 SkGpuDevice(GrContext*, GrRenderTarget*); |
42 | 50 |
43 /** | 51 /** |
44 * New device that will render to the texture (as a rendertarget). | 52 * New device that will render to the texture (as a rendertarget). |
45 * The GrTexture's asRenderTarget() must be non-NULL or device will not | 53 * The GrTexture's asRenderTarget() must be non-NULL or device will not |
46 * function. | 54 * function. |
| 55 * DEPRECATED: Use Create(surface) |
47 */ | 56 */ |
48 SkGpuDevice(GrContext*, GrTexture*); | 57 SkGpuDevice(GrContext*, GrTexture*); |
49 | 58 |
50 virtual ~SkGpuDevice(); | 59 virtual ~SkGpuDevice(); |
51 | 60 |
52 GrContext* context() const { return fContext; } | 61 GrContext* context() const { return fContext; } |
53 | 62 |
54 virtual SkGpuRenderTarget* accessRenderTarget() SK_OVERRIDE; | 63 virtual SkGpuRenderTarget* accessRenderTarget() SK_OVERRIDE; |
55 | 64 |
56 // overrides from SkDevice | 65 // overrides from SkDevice |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 185 |
177 /** | 186 /** |
178 * Returns non-initialized instance. | 187 * Returns non-initialized instance. |
179 */ | 188 */ |
180 GrTextContext* getTextContext(); | 189 GrTextContext* getTextContext(); |
181 | 190 |
182 typedef SkDevice INHERITED; | 191 typedef SkDevice INHERITED; |
183 }; | 192 }; |
184 | 193 |
185 #endif | 194 #endif |
OLD | NEW |