| 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 "GrDrawTarget.h" | 11 #include "GrDrawTarget.h" |
| 12 #include "GrClipMaskManager.h" | 12 #include "GrClipMaskManager.h" |
| 13 #include "SkPath.h" | 13 #include "SkPath.h" |
| 14 | 14 |
| 15 class GrContext; | 15 class GrContext; |
| 16 class GrGpuObject; |
| 16 class GrIndexBufferAllocPool; | 17 class GrIndexBufferAllocPool; |
| 17 class GrPath; | 18 class GrPath; |
| 18 class GrPathRenderer; | 19 class GrPathRenderer; |
| 19 class GrPathRendererChain; | 20 class GrPathRendererChain; |
| 20 class GrResource; | |
| 21 class GrStencilBuffer; | 21 class GrStencilBuffer; |
| 22 class GrVertexBufferAllocPool; | 22 class GrVertexBufferAllocPool; |
| 23 | 23 |
| 24 class GrGpu : public GrDrawTarget { | 24 class GrGpu : public GrDrawTarget { |
| 25 public: | 25 public: |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * Additional blend coefficients for dual source blending, not exposed | 28 * Additional blend coefficients for dual source blending, not exposed |
| 29 * through GrPaint/GrContext. | 29 * through GrPaint/GrContext. |
| 30 */ | 30 */ |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 * @param buffer memory to read pixels from | 224 * @param buffer memory to read pixels from |
| 225 * @param rowBytes number of bytes between consecutive rows. Zero | 225 * @param rowBytes number of bytes between consecutive rows. Zero |
| 226 * means rows are tightly packed. | 226 * means rows are tightly packed. |
| 227 */ | 227 */ |
| 228 bool writeTexturePixels(GrTexture* texture, | 228 bool writeTexturePixels(GrTexture* texture, |
| 229 int left, int top, int width, int height, | 229 int left, int top, int width, int height, |
| 230 GrPixelConfig config, const void* buffer, | 230 GrPixelConfig config, const void* buffer, |
| 231 size_t rowBytes); | 231 size_t rowBytes); |
| 232 | 232 |
| 233 /** | 233 /** |
| 234 * Called to tell Gpu object that all GrResources have been lost and should | 234 * Called to tell GrGpu that all GrGpuObjects have been lost and should |
| 235 * be abandoned. Overrides must call INHERITED::abandonResources(). | 235 * be abandoned. Overrides must call INHERITED::abandonResources(). |
| 236 */ | 236 */ |
| 237 virtual void abandonResources(); | 237 virtual void abandonResources(); |
| 238 | 238 |
| 239 /** | 239 /** |
| 240 * Called to tell Gpu object to release all GrResources. Overrides must call | 240 * Called to tell GrGpu to release all GrGpuObjects. Overrides must call |
| 241 * INHERITED::releaseResources(). | 241 * INHERITED::releaseResources(). |
| 242 */ | 242 */ |
| 243 void releaseResources(); | 243 void releaseResources(); |
| 244 | 244 |
| 245 /** | 245 /** |
| 246 * Add resource to list of resources. Should only be called by GrResource. | 246 * Add object to list of objects. Should only be called by GrGpuObject. |
| 247 * @param resource the resource to add. | 247 * @param resource the resource to add. |
| 248 */ | 248 */ |
| 249 void insertResource(GrResource* resource); | 249 void insertObject(GrGpuObject* object); |
| 250 | 250 |
| 251 /** | 251 /** |
| 252 * Remove resource from list of resources. Should only be called by | 252 * Remove object from list of objects. Should only be called by GrGpuObject. |
| 253 * GrResource. | |
| 254 * @param resource the resource to remove. | 253 * @param resource the resource to remove. |
| 255 */ | 254 */ |
| 256 void removeResource(GrResource* resource); | 255 void removeObject(GrGpuObject* object); |
| 257 | 256 |
| 258 // GrDrawTarget overrides | 257 // GrDrawTarget overrides |
| 259 virtual void clear(const SkIRect* rect, | 258 virtual void clear(const SkIRect* rect, |
| 260 GrColor color, | 259 GrColor color, |
| 261 bool canIgnoreRect, | 260 bool canIgnoreRect, |
| 262 GrRenderTarget* renderTarget = NULL) SK_OVERRIDE; | 261 GrRenderTarget* renderTarget = NULL) SK_OVERRIDE; |
| 263 | 262 |
| 264 virtual void purgeResources() SK_OVERRIDE { | 263 virtual void purgeResources() SK_OVERRIDE { |
| 265 // The clip mask manager can rebuild all its clip masks so just | 264 // The clip mask manager can rebuild all its clip masks so just |
| 266 // get rid of them all. | 265 // get rid of them all. |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 | 495 |
| 497 void handleDirtyContext() { | 496 void handleDirtyContext() { |
| 498 if (fResetBits) { | 497 if (fResetBits) { |
| 499 this->resetContext(); | 498 this->resetContext(); |
| 500 } | 499 } |
| 501 } | 500 } |
| 502 | 501 |
| 503 enum { | 502 enum { |
| 504 kPreallocGeomPoolStateStackCnt = 4, | 503 kPreallocGeomPoolStateStackCnt = 4, |
| 505 }; | 504 }; |
| 506 typedef SkTInternalLList<GrResource> ResourceList; | 505 typedef SkTInternalLList<GrGpuObject> ObjectList; |
| 507 SkSTArray<kPreallocGeomPoolStateStackCnt, GeometryPoolState, true> fGeomPoo
lStateStack; | 506 SkSTArray<kPreallocGeomPoolStateStackCnt, GeometryPoolState, true> fGeomPoo
lStateStack; |
| 508 ResetTimestamp fResetTi
mestamp; | 507 ResetTimestamp fResetTi
mestamp; |
| 509 uint32_t fResetBi
ts; | 508 uint32_t fResetBi
ts; |
| 510 GrVertexBufferAllocPool* fVertexP
ool; | 509 GrVertexBufferAllocPool* fVertexP
ool; |
| 511 GrIndexBufferAllocPool* fIndexPo
ol; | 510 GrIndexBufferAllocPool* fIndexPo
ol; |
| 512 // counts number of uses of vertex/index pool in the geometry stack | 511 // counts number of uses of vertex/index pool in the geometry stack |
| 513 int fVertexP
oolUseCnt; | 512 int fVertexP
oolUseCnt; |
| 514 int fIndexPo
olUseCnt; | 513 int fIndexPo
olUseCnt; |
| 515 // these are mutable so they can be created on-demand | 514 // these are mutable so they can be created on-demand |
| 516 mutable GrIndexBuffer* fQuadInd
exBuffer; | 515 mutable GrIndexBuffer* fQuadInd
exBuffer; |
| 517 // Used to abandon/release all resources created by this GrGpu. TODO: Move t
his | 516 // Used to abandon/release all resources created by this GrGpu. TODO: Move t
his |
| 518 // functionality to GrResourceCache. | 517 // functionality to GrResourceCache. |
| 519 ResourceList fResourc
eList; | 518 ObjectList fObjectL
ist; |
| 520 | 519 |
| 521 typedef GrDrawTarget INHERITED; | 520 typedef GrDrawTarget INHERITED; |
| 522 }; | 521 }; |
| 523 | 522 |
| 524 #endif | 523 #endif |
| OLD | NEW |