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