OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * 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 |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrGpu_DEFINED | 8 #ifndef GrGpu_DEFINED |
9 #define GrGpu_DEFINED | 9 #define GrGpu_DEFINED |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 class GrStencilAttachment; | 31 class GrStencilAttachment; |
32 class GrSurface; | 32 class GrSurface; |
33 class GrTexture; | 33 class GrTexture; |
34 class GrVertexBuffer; | 34 class GrVertexBuffer; |
35 class GrVertices; | 35 class GrVertices; |
36 | 36 |
37 class GrGpu : public SkRefCnt { | 37 class GrGpu : public SkRefCnt { |
38 public: | 38 public: |
39 /** | 39 /** |
40 * Create an instance of GrGpu that matches the specified backend. If the re
quested backend is | 40 * Create an instance of GrGpu that matches the specified backend. If the re
quested backend is |
41 * not supported (at compile-time or run-time) this returns NULL. The contex
t will not be | 41 * not supported (at compile-time or run-time) this returns nullptr. The con
text will not be |
42 * fully constructed and should not be used by GrGpu until after this functi
on returns. | 42 * fully constructed and should not be used by GrGpu until after this functi
on returns. |
43 */ | 43 */ |
44 static GrGpu* Create(GrBackend, GrBackendContext, const GrContextOptions&, G
rContext* context); | 44 static GrGpu* Create(GrBackend, GrBackendContext, const GrContextOptions&, G
rContext* context); |
45 | 45 |
46 //////////////////////////////////////////////////////////////////////////// | 46 //////////////////////////////////////////////////////////////////////////// |
47 | 47 |
48 GrGpu(GrContext* context); | 48 GrGpu(GrContext* context); |
49 ~GrGpu() override; | 49 ~GrGpu() override; |
50 | 50 |
51 GrContext* getContext() { return fContext; } | 51 GrContext* getContext() { return fContext; } |
(...skipping 24 matching lines...) Expand all Loading... |
76 * Creates a texture object. If kRenderTarget_GrSurfaceFlag the texture can | 76 * Creates a texture object. If kRenderTarget_GrSurfaceFlag the texture can |
77 * be used as a render target by calling GrTexture::asRenderTarget(). Not al
l | 77 * be used as a render target by calling GrTexture::asRenderTarget(). Not al
l |
78 * pixel configs can be used as render targets. Support for configs as textu
res | 78 * pixel configs can be used as render targets. Support for configs as textu
res |
79 * or render targets can be checked using GrCaps. | 79 * or render targets can be checked using GrCaps. |
80 * | 80 * |
81 * @param desc describes the texture to be created. | 81 * @param desc describes the texture to be created. |
82 * @param budgeted does this texture count against the resource cache bud
get? | 82 * @param budgeted does this texture count against the resource cache bud
get? |
83 * @param srcData texel data to load texture. Begins with full-size | 83 * @param srcData texel data to load texture. Begins with full-size |
84 * palette data for paletted textures. For compressed | 84 * palette data for paletted textures. For compressed |
85 * formats it contains the compressed pixel data. Otherwi
se, | 85 * formats it contains the compressed pixel data. Otherwi
se, |
86 * it contains width*height texels. If NULL texture data | 86 * it contains width*height texels. If nullptr texture da
ta |
87 * is uninitialized. | 87 * is uninitialized. |
88 * @param rowBytes the number of bytes between consecutive rows. Zero | 88 * @param rowBytes the number of bytes between consecutive rows. Zero |
89 * means rows are tightly packed. This field is ignored | 89 * means rows are tightly packed. This field is ignored |
90 * for compressed formats. | 90 * for compressed formats. |
91 * | 91 * |
92 * @return The texture object if successful, otherwise NULL. | 92 * @return The texture object if successful, otherwise nullptr. |
93 */ | 93 */ |
94 GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted, | 94 GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted, |
95 const void* srcData, size_t rowBytes); | 95 const void* srcData, size_t rowBytes); |
96 | 96 |
97 /** | 97 /** |
98 * Implements GrContext::wrapBackendTexture | 98 * Implements GrContext::wrapBackendTexture |
99 */ | 99 */ |
100 GrTexture* wrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership); | 100 GrTexture* wrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership); |
101 | 101 |
102 /** | 102 /** |
103 * Implements GrContext::wrapBackendTexture | 103 * Implements GrContext::wrapBackendTexture |
104 */ | 104 */ |
105 GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc&, Gr
WrapOwnership); | 105 GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc&, Gr
WrapOwnership); |
106 | 106 |
107 /** | 107 /** |
108 * Creates a vertex buffer. | 108 * Creates a vertex buffer. |
109 * | 109 * |
110 * @param size size in bytes of the vertex buffer | 110 * @param size size in bytes of the vertex buffer |
111 * @param dynamic hints whether the data will be frequently changed | 111 * @param dynamic hints whether the data will be frequently changed |
112 * by either GrVertexBuffer::map() or | 112 * by either GrVertexBuffer::map() or |
113 * GrVertexBuffer::updateData(). | 113 * GrVertexBuffer::updateData(). |
114 * | 114 * |
115 * @return The vertex buffer if successful, otherwise NULL. | 115 * @return The vertex buffer if successful, otherwise nullptr. |
116 */ | 116 */ |
117 GrVertexBuffer* createVertexBuffer(size_t size, bool dynamic); | 117 GrVertexBuffer* createVertexBuffer(size_t size, bool dynamic); |
118 | 118 |
119 /** | 119 /** |
120 * Creates an index buffer. | 120 * Creates an index buffer. |
121 * | 121 * |
122 * @param size size in bytes of the index buffer | 122 * @param size size in bytes of the index buffer |
123 * @param dynamic hints whether the data will be frequently changed | 123 * @param dynamic hints whether the data will be frequently changed |
124 * by either GrIndexBuffer::map() or | 124 * by either GrIndexBuffer::map() or |
125 * GrIndexBuffer::updateData(). | 125 * GrIndexBuffer::updateData(). |
126 * | 126 * |
127 * @return The index buffer if successful, otherwise NULL. | 127 * @return The index buffer if successful, otherwise nullptr. |
128 */ | 128 */ |
129 GrIndexBuffer* createIndexBuffer(size_t size, bool dynamic); | 129 GrIndexBuffer* createIndexBuffer(size_t size, bool dynamic); |
130 | 130 |
131 /** | 131 /** |
132 * Resolves MSAA. | 132 * Resolves MSAA. |
133 */ | 133 */ |
134 void resolveRenderTarget(GrRenderTarget* target); | 134 void resolveRenderTarget(GrRenderTarget* target); |
135 | 135 |
136 /** Info struct returned by getReadPixelsInfo about performing intermediate
draws before | 136 /** Info struct returned by getReadPixelsInfo about performing intermediate
draws before |
137 reading pixels for performance or correctness. */ | 137 reading pixels for performance or correctness. */ |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 | 250 |
251 /** | 251 /** |
252 * Clear the passed in render target. Ignores the draw state and clip. | 252 * Clear the passed in render target. Ignores the draw state and clip. |
253 */ | 253 */ |
254 void clear(const SkIRect& rect, GrColor color, GrRenderTarget* renderTarget)
; | 254 void clear(const SkIRect& rect, GrColor color, GrRenderTarget* renderTarget)
; |
255 | 255 |
256 | 256 |
257 void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget*
renderTarget); | 257 void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget*
renderTarget); |
258 | 258 |
259 /** | 259 /** |
260 * Discards the contents render target. NULL indicates that the current rend
er target should | 260 * Discards the contents render target. nullptr indicates that the current r
ender target should |
261 * be discarded. | 261 * be discarded. |
262 **/ | 262 **/ |
263 virtual void discard(GrRenderTarget* = NULL) = 0; | 263 virtual void discard(GrRenderTarget* = nullptr) = 0; |
264 | 264 |
265 /** | 265 /** |
266 * This is can be called before allocating a texture to be a dst for copySur
face. It will | 266 * This is can be called before allocating a texture to be a dst for copySur
face. It will |
267 * populate the origin, config, and flags fields of the desc such that copyS
urface can | 267 * populate the origin, config, and flags fields of the desc such that copyS
urface can |
268 * efficiently succeed. It should only succeed if it can allow copySurface t
o perform a copy | 268 * efficiently succeed. It should only succeed if it can allow copySurface t
o perform a copy |
269 * that would be more effecient than drawing the src to a dst render target. | 269 * that would be more effecient than drawing the src to a dst render target. |
270 */ | 270 */ |
271 virtual bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* des
c) const = 0; | 271 virtual bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* des
c) const = 0; |
272 | 272 |
273 // After the client interacts directly with the 3D context state the GrGpu | 273 // After the client interacts directly with the 3D context state the GrGpu |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 // only to be used in GPU-specific tests | 386 // only to be used in GPU-specific tests |
387 virtual GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w,
int h, | 387 virtual GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w,
int h, |
388 GrPixelConfig config
) const = 0; | 388 GrPixelConfig config
) const = 0; |
389 virtual bool isTestingOnlyBackendTexture(GrBackendObject id) const = 0; | 389 virtual bool isTestingOnlyBackendTexture(GrBackendObject id) const = 0; |
390 virtual void deleteTestingOnlyBackendTexture(GrBackendObject id) const = 0; | 390 virtual void deleteTestingOnlyBackendTexture(GrBackendObject id) const = 0; |
391 | 391 |
392 // Given a rt, find or create a stencil buffer and attach it | 392 // Given a rt, find or create a stencil buffer and attach it |
393 bool attachStencilAttachmentToRenderTarget(GrRenderTarget* target); | 393 bool attachStencilAttachmentToRenderTarget(GrRenderTarget* target); |
394 | 394 |
395 // This is only to be used in GL-specific tests. | 395 // This is only to be used in GL-specific tests. |
396 virtual const GrGLContext* glContextForTesting() const { return NULL; } | 396 virtual const GrGLContext* glContextForTesting() const { return nullptr; } |
397 | 397 |
398 protected: | 398 protected: |
399 // Functions used to map clip-respecting stencil tests into normal | 399 // Functions used to map clip-respecting stencil tests into normal |
400 // stencil funcs supported by GPUs. | 400 // stencil funcs supported by GPUs. |
401 static GrStencilFunc ConvertStencilFunc(bool stencilInClip, | 401 static GrStencilFunc ConvertStencilFunc(bool stencilInClip, |
402 GrStencilFunc func); | 402 GrStencilFunc func); |
403 static void ConvertStencilFuncAndMask(GrStencilFunc func, | 403 static void ConvertStencilFuncAndMask(GrStencilFunc func, |
404 bool clipInStencil, | 404 bool clipInStencil, |
405 unsigned int clipBit, | 405 unsigned int clipBit, |
406 unsigned int userBits, | 406 unsigned int userBits, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 GrTraceMarkerSet fActiveT
raceMarkers; | 521 GrTraceMarkerSet fActiveT
raceMarkers; |
522 GrTraceMarkerSet fStoredT
raceMarkers; | 522 GrTraceMarkerSet fStoredT
raceMarkers; |
523 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. | 523 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. |
524 GrContext* fContext
; | 524 GrContext* fContext
; |
525 | 525 |
526 friend class GrPathRendering; | 526 friend class GrPathRendering; |
527 typedef SkRefCnt INHERITED; | 527 typedef SkRefCnt INHERITED; |
528 }; | 528 }; |
529 | 529 |
530 #endif | 530 #endif |
OLD | NEW |