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 #ifndef SkGpuDevice_DEFINED | 9 #ifndef SkGpuDevice_DEFINED |
10 #define SkGpuDevice_DEFINED | 10 #define SkGpuDevice_DEFINED |
11 | 11 |
12 #include "SkGr.h" | 12 #include "SkGr.h" |
13 #include "SkBitmap.h" | 13 #include "SkBitmap.h" |
14 #include "SkDevice.h" | 14 #include "SkDevice.h" |
15 #include "SkPicture.h" | 15 #include "SkPicture.h" |
16 #include "SkRegion.h" | 16 #include "SkRegion.h" |
17 #include "SkSurface.h" | 17 #include "SkSurface.h" |
| 18 #include "GrDrawContext.h" |
18 #include "GrContext.h" | 19 #include "GrContext.h" |
19 #include "GrSurfacePriv.h" | 20 #include "GrSurfacePriv.h" |
20 | 21 |
21 class GrAccelData; | 22 class GrAccelData; |
22 class GrTextureProducer; | 23 class GrTextureProducer; |
23 struct GrCachedLayer; | 24 struct GrCachedLayer; |
24 | 25 |
25 /** | 26 /** |
26 * Subclass of SkBaseDevice, which directs all drawing to the GrGpu owned by th
e | 27 * Subclass of SkBaseDevice, which directs all drawing to the GrGpu owned by th
e |
27 * canvas. | 28 * canvas. |
(...skipping 18 matching lines...) Expand all Loading... |
46 const SkSurfaceProps*, InitContents); | 47 const SkSurfaceProps*, InitContents); |
47 | 48 |
48 /** | 49 /** |
49 * New device that will create an offscreen renderTarget based on the ImageI
nfo and | 50 * New device that will create an offscreen renderTarget based on the ImageI
nfo and |
50 * sampleCount. The Budgeted param controls whether the device's backing sto
re counts against | 51 * sampleCount. The Budgeted param controls whether the device's backing sto
re counts against |
51 * the resource cache budget. On failure, returns nullptr. | 52 * the resource cache budget. On failure, returns nullptr. |
52 */ | 53 */ |
53 static SkGpuDevice* Create(GrContext*, SkSurface::Budgeted, const SkImageInf
o&, | 54 static SkGpuDevice* Create(GrContext*, SkSurface::Budgeted, const SkImageInf
o&, |
54 int sampleCount, const SkSurfaceProps*, InitConte
nts); | 55 int sampleCount, const SkSurfaceProps*, InitConte
nts); |
55 | 56 |
56 virtual ~SkGpuDevice(); | 57 ~SkGpuDevice() override {} |
57 | 58 |
58 SkGpuDevice* cloneDevice(const SkSurfaceProps& props) { | 59 SkGpuDevice* cloneDevice(const SkSurfaceProps& props) { |
59 SkBaseDevice* dev = this->onCreateDevice(CreateInfo(this->imageInfo(), k
Possible_TileUsage, | 60 SkBaseDevice* dev = this->onCreateDevice(CreateInfo(this->imageInfo(), k
Possible_TileUsage, |
60 props.pixelGeometry(
)), | 61 props.pixelGeometry(
)), |
61 nullptr); | 62 nullptr); |
62 return static_cast<SkGpuDevice*>(dev); | 63 return static_cast<SkGpuDevice*>(dev); |
63 } | 64 } |
64 | 65 |
65 GrContext* context() const { return fContext; } | 66 GrContext* context() const { return fContext; } |
66 | 67 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 protected: | 147 protected: |
147 bool onReadPixels(const SkImageInfo&, void*, size_t, int, int) override; | 148 bool onReadPixels(const SkImageInfo&, void*, size_t, int, int) override; |
148 bool onWritePixels(const SkImageInfo&, const void*, size_t, int, int) overri
de; | 149 bool onWritePixels(const SkImageInfo&, const void*, size_t, int, int) overri
de; |
149 bool onShouldDisableLCD(const SkPaint&) const final; | 150 bool onShouldDisableLCD(const SkPaint&) const final; |
150 | 151 |
151 /** PRIVATE / EXPERIMENTAL -- do not call */ | 152 /** PRIVATE / EXPERIMENTAL -- do not call */ |
152 virtual bool EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pic
ture, | 153 virtual bool EXPERIMENTAL_drawPicture(SkCanvas* canvas, const SkPicture* pic
ture, |
153 const SkMatrix*, const SkPaint*) overr
ide; | 154 const SkMatrix*, const SkPaint*) overr
ide; |
154 | 155 |
155 private: | 156 private: |
156 GrContext* fContext; | 157 // We want these unreffed in DrawContext, RenderTarget, GrContext order. |
| 158 SkAutoTUnref<GrContext> fContext; |
| 159 SkAutoTUnref<GrRenderTarget> fRenderTarget; |
| 160 SkAutoTUnref<GrDrawContext> fDrawContext; |
| 161 |
157 SkAutoTUnref<const SkClipStack> fClipStack; | 162 SkAutoTUnref<const SkClipStack> fClipStack; |
158 SkIPoint fClipOrigin; | 163 SkIPoint fClipOrigin; |
159 GrClip fClip; | 164 GrClip fClip;; |
160 SkAutoTUnref<GrDrawContext> fDrawContext; | |
161 GrRenderTarget* fRenderTarget; | |
162 // remove when our clients don't rely on accessBitmap() | 165 // remove when our clients don't rely on accessBitmap() |
163 SkBitmap fLegacyBitmap; | 166 SkBitmap fLegacyBitmap; |
164 bool fNeedClear; | 167 bool fNeedClear; |
165 bool fOpaque; | 168 bool fOpaque; |
166 | 169 |
167 enum Flags { | 170 enum Flags { |
168 kNeedClear_Flag = 1 << 0, //!< Surface requires an initial clear | 171 kNeedClear_Flag = 1 << 0, //!< Surface requires an initial clear |
169 kIsOpaque_Flag = 1 << 1, //!< Hint from client that rendering to this
device will be | 172 kIsOpaque_Flag = 1 << 1, //!< Hint from client that rendering to this
device will be |
170 // opaque even if the config supports alpha
. | 173 // opaque even if the config supports alpha
. |
171 }; | 174 }; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 257 |
255 static GrRenderTarget* CreateRenderTarget(GrContext*, SkSurface::Budgeted, c
onst SkImageInfo&, | 258 static GrRenderTarget* CreateRenderTarget(GrContext*, SkSurface::Budgeted, c
onst SkImageInfo&, |
256 int sampleCount); | 259 int sampleCount); |
257 | 260 |
258 friend class GrAtlasTextContext; | 261 friend class GrAtlasTextContext; |
259 friend class SkSurface_Gpu; // for access to surfaceProps | 262 friend class SkSurface_Gpu; // for access to surfaceProps |
260 typedef SkBaseDevice INHERITED; | 263 typedef SkBaseDevice INHERITED; |
261 }; | 264 }; |
262 | 265 |
263 #endif | 266 #endif |
OLD | NEW |