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 |
11 #include "GrPipelineBuilder.h" | 11 #include "GrPipelineBuilder.h" |
12 #include "GrProgramDesc.h" | 12 #include "GrProgramDesc.h" |
13 #include "GrStencil.h" | 13 #include "GrStencil.h" |
14 #include "GrSwizzle.h" | 14 #include "GrSwizzle.h" |
15 #include "GrTextureParamsAdjuster.h" | 15 #include "GrTextureParamsAdjuster.h" |
| 16 #include "GrTypes.h" |
16 #include "GrXferProcessor.h" | 17 #include "GrXferProcessor.h" |
17 #include "SkPath.h" | 18 #include "SkPath.h" |
| 19 #include "SkTArray.h" |
18 | 20 |
19 class GrBatchTracker; | 21 class GrBatchTracker; |
20 class GrContext; | 22 class GrContext; |
21 class GrGLContext; | 23 class GrGLContext; |
22 class GrIndexBuffer; | 24 class GrIndexBuffer; |
23 class GrNonInstancedVertices; | 25 class GrNonInstancedVertices; |
24 class GrPath; | 26 class GrPath; |
25 class GrPathRange; | 27 class GrPathRange; |
26 class GrPathRenderer; | 28 class GrPathRenderer; |
27 class GrPathRendererChain; | 29 class GrPathRendererChain; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 void markContextDirty(uint32_t state = kAll_GrBackendState) { fResetBits |=
state; } | 77 void markContextDirty(uint32_t state = kAll_GrBackendState) { fResetBits |=
state; } |
76 | 78 |
77 /** | 79 /** |
78 * Creates a texture object. If kRenderTarget_GrSurfaceFlag the texture can | 80 * Creates a texture object. If kRenderTarget_GrSurfaceFlag the texture can |
79 * be used as a render target by calling GrTexture::asRenderTarget(). Not al
l | 81 * be used as a render target by calling GrTexture::asRenderTarget(). Not al
l |
80 * pixel configs can be used as render targets. Support for configs as textu
res | 82 * pixel configs can be used as render targets. Support for configs as textu
res |
81 * or render targets can be checked using GrCaps. | 83 * or render targets can be checked using GrCaps. |
82 * | 84 * |
83 * @param desc describes the texture to be created. | 85 * @param desc describes the texture to be created. |
84 * @param budgeted does this texture count against the resource cache bud
get? | 86 * @param budgeted does this texture count against the resource cache bud
get? |
85 * @param srcData texel data to load texture. Begins with full-size | 87 * @param texels array of mipmap levels containing texel data to load. |
86 * palette data for paletted textures. For compressed | 88 * Each level begins with full-size palette data for pale
tted textures. |
87 * formats it contains the compressed pixel data. Otherwi
se, | 89 * For compressed formats the level contains the compress
ed pixel data. |
88 * it contains width*height texels. If nullptr texture da
ta | 90 * Otherwise, it contains width*height texels. If there i
s only one |
89 * is uninitialized. | 91 * element and it contains nullptr fPixels, texture data
is |
90 * @param rowBytes the number of bytes between consecutive rows. Zero | 92 * uninitialized. |
91 * means rows are tightly packed. This field is ignored | 93 * @return The texture object if successful, otherwise nullptr. |
92 * for compressed formats. | 94 */ |
| 95 GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted, |
| 96 const SkTArray<GrMipLevel>& texels); |
| 97 |
| 98 /** |
| 99 * This function is a shim which creates a SkTArGrMipLevell> of size 1. |
| 100 * It then calls createTexture with that SkTArray. |
93 * | 101 * |
94 * @return The texture object if successful, otherwise nullptr. | 102 * @param srcData texel data to load texture. Begins with full-size |
| 103 * palette data for paletted texture. For compressed |
| 104 * formats it contains the compressed pixel data. Otherwise, |
| 105 * it contains width*height texels. If nullptr texture data |
| 106 * is uninitialized. |
| 107 * @param rowBytes the number of bytes between consecutive rows. Zero |
| 108 * means rows are tightly packed. This field is ignored |
| 109 * for compressed pixel formats. |
| 110 * @return The texture object if successful, otherwise, nullptr. |
95 */ | 111 */ |
96 GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted, | 112 GrTexture* createTexture(const GrSurfaceDesc& desc, bool budgeted, |
97 const void* srcData, size_t rowBytes); | 113 const void* srcData, size_t rowBytes); |
98 | 114 |
99 /** | 115 /** |
100 * Implements GrContext::wrapBackendTexture | 116 * Implements GrContext::wrapBackendTexture |
101 */ | 117 */ |
102 GrTexture* wrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership); | 118 GrTexture* wrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership); |
103 | 119 |
104 /** | 120 /** |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 264 |
249 /** | 265 /** |
250 * Updates the pixels in a rectangle of a surface. | 266 * Updates the pixels in a rectangle of a surface. |
251 * | 267 * |
252 * @param surface The surface to write to. | 268 * @param surface The surface to write to. |
253 * @param left left edge of the rectangle to write (inclusive) | 269 * @param left left edge of the rectangle to write (inclusive) |
254 * @param top top edge of the rectangle to write (inclusive) | 270 * @param top top edge of the rectangle to write (inclusive) |
255 * @param width width of rectangle to write in pixels. | 271 * @param width width of rectangle to write in pixels. |
256 * @param height height of rectangle to write in pixels. | 272 * @param height height of rectangle to write in pixels. |
257 * @param config the pixel config of the source buffer | 273 * @param config the pixel config of the source buffer |
258 * @param buffer memory to read pixels from | 274 * @param texels array of mipmap levels containing texture data |
259 * @param rowBytes number of bytes between consecutive rows. Zero | |
260 * means rows are tightly packed. | |
261 */ | 275 */ |
262 bool writePixels(GrSurface* surface, | 276 bool writePixels(GrSurface* surface, |
263 int left, int top, int width, int height, | 277 int left, int top, int width, int height, |
| 278 GrPixelConfig config, |
| 279 const SkTArray<GrMipLevel>& texels); |
| 280 |
| 281 /** |
| 282 * This function is a shim which creates a SkTArray<GrMipLevel> of size 1. |
| 283 * It then calls writePixels with that SkTArray. |
| 284 * |
| 285 * @param buffer memory to read pixels from. |
| 286 * @param rowBytes number of bytes between consecutive rows. Zero |
| 287 * means rows are tightly packed. |
| 288 */ |
| 289 bool writePixels(GrSurface* surface, |
| 290 int left, int top, int width, int height, |
264 GrPixelConfig config, const void* buffer, | 291 GrPixelConfig config, const void* buffer, |
265 size_t rowBytes); | 292 size_t rowBytes); |
266 | 293 |
267 /** | 294 /** |
268 * Updates the pixels in a rectangle of a surface using a GrTransferBuffer | 295 * Updates the pixels in a rectangle of a surface using a GrTransferBuffer |
269 * | 296 * |
270 * @param surface The surface to write to. | 297 * @param surface The surface to write to. |
271 * @param left left edge of the rectangle to write (inclusive) | 298 * @param left left edge of the rectangle to write (inclusive) |
272 * @param top top edge of the rectangle to write (inclusive) | 299 * @param top top edge of the rectangle to write (inclusive) |
273 * @param width width of rectangle to write in pixels. | 300 * @param width width of rectangle to write in pixels. |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 virtual void onResetContext(uint32_t resetBits) = 0; | 525 virtual void onResetContext(uint32_t resetBits) = 0; |
499 | 526 |
500 // Called before certain draws in order to guarantee coherent results from d
st reads. | 527 // Called before certain draws in order to guarantee coherent results from d
st reads. |
501 virtual void xferBarrier(GrRenderTarget*, GrXferBarrierType) = 0; | 528 virtual void xferBarrier(GrRenderTarget*, GrXferBarrierType) = 0; |
502 | 529 |
503 // overridden by backend-specific derived class to create objects. | 530 // overridden by backend-specific derived class to create objects. |
504 // Texture size and sample size will have already been validated in base cla
ss before | 531 // Texture size and sample size will have already been validated in base cla
ss before |
505 // onCreateTexture/CompressedTexture are called. | 532 // onCreateTexture/CompressedTexture are called. |
506 virtual GrTexture* onCreateTexture(const GrSurfaceDesc& desc, | 533 virtual GrTexture* onCreateTexture(const GrSurfaceDesc& desc, |
507 GrGpuResource::LifeCycle lifeCycle, | 534 GrGpuResource::LifeCycle lifeCycle, |
508 const void* srcData, size_t rowBytes) = 0
; | 535 const SkTArray<GrMipLevel>& texels) = 0; |
509 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, | 536 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, |
510 GrGpuResource::LifeCycle lifeCy
cle, | 537 GrGpuResource::LifeCycle lifeCy
cle, |
511 const void* srcData) = 0; | 538 const SkTArray<GrMipLevel>& tex
els) = 0; |
| 539 |
512 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapO
wnership) = 0; | 540 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapO
wnership) = 0; |
513 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&, | 541 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&, |
514 GrWrapOwnership) = 0; | 542 GrWrapOwnership) = 0; |
515 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; | 543 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; |
516 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0; | 544 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0; |
517 virtual GrTransferBuffer* onCreateTransferBuffer(size_t size, TransferType t
ype) = 0; | 545 virtual GrTransferBuffer* onCreateTransferBuffer(size_t size, TransferType t
ype) = 0; |
518 | 546 |
519 // overridden by backend-specific derived class to perform the clear. | 547 // overridden by backend-specific derived class to perform the clear. |
520 virtual void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) =
0; | 548 virtual void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) =
0; |
521 | 549 |
(...skipping 19 matching lines...) Expand all Loading... |
541 virtual bool onReadPixels(GrSurface*, | 569 virtual bool onReadPixels(GrSurface*, |
542 int left, int top, | 570 int left, int top, |
543 int width, int height, | 571 int width, int height, |
544 GrPixelConfig, | 572 GrPixelConfig, |
545 void* buffer, | 573 void* buffer, |
546 size_t rowBytes) = 0; | 574 size_t rowBytes) = 0; |
547 | 575 |
548 // overridden by backend-specific derived class to perform the surface write | 576 // overridden by backend-specific derived class to perform the surface write |
549 virtual bool onWritePixels(GrSurface*, | 577 virtual bool onWritePixels(GrSurface*, |
550 int left, int top, int width, int height, | 578 int left, int top, int width, int height, |
551 GrPixelConfig config, const void* buffer, | 579 GrPixelConfig config, |
552 size_t rowBytes) = 0; | 580 const SkTArray<GrMipLevel>& texels) = 0; |
553 | 581 |
554 // overridden by backend-specific derived class to perform the surface write | 582 // overridden by backend-specific derived class to perform the surface write |
555 virtual bool onTransferPixels(GrSurface*, | 583 virtual bool onTransferPixels(GrSurface*, |
556 int left, int top, int width, int height, | 584 int left, int top, int width, int height, |
557 GrPixelConfig config, GrTransferBuffer* buffer
, | 585 GrPixelConfig config, GrTransferBuffer* buffer
, |
558 size_t offset, size_t rowBytes) = 0; | 586 size_t offset, size_t rowBytes) = 0; |
559 | 587 |
560 // overridden by backend-specific derived class to perform the resolve | 588 // overridden by backend-specific derived class to perform the resolve |
561 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; | 589 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; |
562 | 590 |
(...skipping 12 matching lines...) Expand all Loading... |
575 ResetTimestamp fResetTi
mestamp; | 603 ResetTimestamp fResetTi
mestamp; |
576 uint32_t fResetBi
ts; | 604 uint32_t fResetBi
ts; |
577 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. | 605 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. |
578 GrContext* fContext
; | 606 GrContext* fContext
; |
579 | 607 |
580 friend class GrPathRendering; | 608 friend class GrPathRendering; |
581 typedef SkRefCnt INHERITED; | 609 typedef SkRefCnt INHERITED; |
582 }; | 610 }; |
583 | 611 |
584 #endif | 612 #endif |
OLD | NEW |