| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 static GrGpu* Create(GrBackend, GrBackendContext, GrContext* context); | 47 static GrGpu* Create(GrBackend, GrBackendContext, GrContext* context); |
| 48 | 48 |
| 49 //////////////////////////////////////////////////////////////////////////// | 49 //////////////////////////////////////////////////////////////////////////// |
| 50 | 50 |
| 51 GrGpu(GrContext* context); | 51 GrGpu(GrContext* context); |
| 52 virtual ~GrGpu(); | 52 virtual ~GrGpu(); |
| 53 | 53 |
| 54 GrContext* getContext() { return this->INHERITED::getContext(); } | 54 GrContext* getContext() { return this->INHERITED::getContext(); } |
| 55 const GrContext* getContext() const { return this->INHERITED::getContext();
} | 55 const GrContext* getContext() const { return this->INHERITED::getContext();
} |
| 56 | 56 |
| 57 // Called by GrContext when the underlying backend context has been destroye
d. | |
| 58 // GrGpu should use this to ensure that no backend API calls will be made fr
om | |
| 59 // here onward, including in its destructor. Subclasses should call | |
| 60 // INHERITED::contextAbandonded() if they override this. | |
| 61 virtual void contextAbandonded(); | |
| 62 | |
| 63 /** | 57 /** |
| 64 * The GrGpu object normally assumes that no outsider is setting state | 58 * The GrGpu object normally assumes that no outsider is setting state |
| 65 * within the underlying 3D API's context/device/whatever. This call informs | 59 * within the underlying 3D API's context/device/whatever. This call informs |
| 66 * the GrGpu that the state was modified and it shouldn't make assumptions | 60 * the GrGpu that the state was modified and it shouldn't make assumptions |
| 67 * about the state. | 61 * about the state. |
| 68 */ | 62 */ |
| 69 void markContextDirty(uint32_t state = kAll_GrBackendState) { | 63 void markContextDirty(uint32_t state = kAll_GrBackendState) { |
| 70 fResetBits |= state; | 64 fResetBits |= state; |
| 71 } | 65 } |
| 72 | 66 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 * @param config the pixel config of the source buffer | 241 * @param config the pixel config of the source buffer |
| 248 * @param buffer memory to read pixels from | 242 * @param buffer memory to read pixels from |
| 249 * @param rowBytes number of bytes between consecutive rows. Zero | 243 * @param rowBytes number of bytes between consecutive rows. Zero |
| 250 * means rows are tightly packed. | 244 * means rows are tightly packed. |
| 251 */ | 245 */ |
| 252 bool writeTexturePixels(GrTexture* texture, | 246 bool writeTexturePixels(GrTexture* texture, |
| 253 int left, int top, int width, int height, | 247 int left, int top, int width, int height, |
| 254 GrPixelConfig config, const void* buffer, | 248 GrPixelConfig config, const void* buffer, |
| 255 size_t rowBytes); | 249 size_t rowBytes); |
| 256 | 250 |
| 251 /** |
| 252 * Called to tell GrGpu that all GrGpuResources have been lost and should |
| 253 * be abandoned. Overrides must call INHERITED::abandonResources(). |
| 254 */ |
| 255 virtual void abandonResources(); |
| 256 |
| 257 /** |
| 258 * Called to tell GrGpu to release all GrGpuResources. Overrides must call |
| 259 * INHERITED::releaseResources(). |
| 260 */ |
| 261 void releaseResources(); |
| 262 |
| 263 /** |
| 264 * Add object to list of objects. Should only be called by GrGpuResource. |
| 265 * @param resource the resource to add. |
| 266 */ |
| 267 void insertObject(GrGpuResource* object); |
| 268 |
| 269 /** |
| 270 * Remove object from list of objects. Should only be called by GrGpuResourc
e. |
| 271 * @param resource the resource to remove. |
| 272 */ |
| 273 void removeObject(GrGpuResource* object); |
| 274 |
| 257 // GrDrawTarget overrides | 275 // GrDrawTarget overrides |
| 258 virtual void clear(const SkIRect* rect, | 276 virtual void clear(const SkIRect* rect, |
| 259 GrColor color, | 277 GrColor color, |
| 260 bool canIgnoreRect, | 278 bool canIgnoreRect, |
| 261 GrRenderTarget* renderTarget = NULL) SK_OVERRIDE; | 279 GrRenderTarget* renderTarget = NULL) SK_OVERRIDE; |
| 262 | 280 |
| 263 virtual void purgeResources() SK_OVERRIDE { | 281 virtual void purgeResources() SK_OVERRIDE { |
| 264 // The clip mask manager can rebuild all its clip masks so just | 282 // The clip mask manager can rebuild all its clip masks so just |
| 265 // get rid of them all. | 283 // get rid of them all. |
| 266 fClipMaskManager.purgeResources(); | 284 fClipMaskManager.releaseResources(); |
| 267 } | 285 } |
| 268 | 286 |
| 269 // After the client interacts directly with the 3D context state the GrGpu | 287 // After the client interacts directly with the 3D context state the GrGpu |
| 270 // must resync its internal state and assumptions about 3D context state. | 288 // must resync its internal state and assumptions about 3D context state. |
| 271 // Each time this occurs the GrGpu bumps a timestamp. | 289 // Each time this occurs the GrGpu bumps a timestamp. |
| 272 // state of the 3D context | 290 // state of the 3D context |
| 273 // At 10 resets / frame and 60fps a 64bit timestamp will overflow in about | 291 // At 10 resets / frame and 60fps a 64bit timestamp will overflow in about |
| 274 // a billion years. | 292 // a billion years. |
| 275 typedef uint64_t ResetTimestamp; | 293 typedef uint64_t ResetTimestamp; |
| 276 | 294 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 | 519 |
| 502 void handleDirtyContext() { | 520 void handleDirtyContext() { |
| 503 if (fResetBits) { | 521 if (fResetBits) { |
| 504 this->resetContext(); | 522 this->resetContext(); |
| 505 } | 523 } |
| 506 } | 524 } |
| 507 | 525 |
| 508 enum { | 526 enum { |
| 509 kPreallocGeomPoolStateStackCnt = 4, | 527 kPreallocGeomPoolStateStackCnt = 4, |
| 510 }; | 528 }; |
| 529 typedef SkTInternalLList<GrGpuResource> ObjectList; |
| 511 SkSTArray<kPreallocGeomPoolStateStackCnt, GeometryPoolState, true> fGeomPoo
lStateStack; | 530 SkSTArray<kPreallocGeomPoolStateStackCnt, GeometryPoolState, true> fGeomPoo
lStateStack; |
| 512 ResetTimestamp fResetTi
mestamp; | 531 ResetTimestamp fResetTi
mestamp; |
| 513 uint32_t fResetBi
ts; | 532 uint32_t fResetBi
ts; |
| 514 GrVertexBufferAllocPool* fVertexP
ool; | 533 GrVertexBufferAllocPool* fVertexP
ool; |
| 515 GrIndexBufferAllocPool* fIndexPo
ol; | 534 GrIndexBufferAllocPool* fIndexPo
ol; |
| 516 // counts number of uses of vertex/index pool in the geometry stack | 535 // counts number of uses of vertex/index pool in the geometry stack |
| 517 int fVertexP
oolUseCnt; | 536 int fVertexP
oolUseCnt; |
| 518 int fIndexPo
olUseCnt; | 537 int fIndexPo
olUseCnt; |
| 519 // these are mutable so they can be created on-demand | 538 // these are mutable so they can be created on-demand |
| 520 mutable GrIndexBuffer* fQuadInd
exBuffer; | 539 mutable GrIndexBuffer* fQuadInd
exBuffer; |
| 540 // Used to abandon/release all resources created by this GrGpu. TODO: Move t
his |
| 541 // functionality to GrResourceCache. |
| 542 ObjectList fObjectL
ist; |
| 521 | 543 |
| 522 typedef GrDrawTarget INHERITED; | 544 typedef GrDrawTarget INHERITED; |
| 523 }; | 545 }; |
| 524 | 546 |
| 525 #endif | 547 #endif |
| OLD | NEW |