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 |
57 /** | 63 /** |
58 * The GrGpu object normally assumes that no outsider is setting state | 64 * The GrGpu object normally assumes that no outsider is setting state |
59 * within the underlying 3D API's context/device/whatever. This call informs | 65 * within the underlying 3D API's context/device/whatever. This call informs |
60 * the GrGpu that the state was modified and it shouldn't make assumptions | 66 * the GrGpu that the state was modified and it shouldn't make assumptions |
61 * about the state. | 67 * about the state. |
62 */ | 68 */ |
63 void markContextDirty(uint32_t state = kAll_GrBackendState) { | 69 void markContextDirty(uint32_t state = kAll_GrBackendState) { |
64 fResetBits |= state; | 70 fResetBits |= state; |
65 } | 71 } |
66 | 72 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 * @param config the pixel config of the source buffer | 247 * @param config the pixel config of the source buffer |
242 * @param buffer memory to read pixels from | 248 * @param buffer memory to read pixels from |
243 * @param rowBytes number of bytes between consecutive rows. Zero | 249 * @param rowBytes number of bytes between consecutive rows. Zero |
244 * means rows are tightly packed. | 250 * means rows are tightly packed. |
245 */ | 251 */ |
246 bool writeTexturePixels(GrTexture* texture, | 252 bool writeTexturePixels(GrTexture* texture, |
247 int left, int top, int width, int height, | 253 int left, int top, int width, int height, |
248 GrPixelConfig config, const void* buffer, | 254 GrPixelConfig config, const void* buffer, |
249 size_t rowBytes); | 255 size_t rowBytes); |
250 | 256 |
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 | |
275 // GrDrawTarget overrides | 257 // GrDrawTarget overrides |
276 virtual void clear(const SkIRect* rect, | 258 virtual void clear(const SkIRect* rect, |
277 GrColor color, | 259 GrColor color, |
278 bool canIgnoreRect, | 260 bool canIgnoreRect, |
279 GrRenderTarget* renderTarget = NULL) SK_OVERRIDE; | 261 GrRenderTarget* renderTarget = NULL) SK_OVERRIDE; |
280 | 262 |
281 virtual void purgeResources() SK_OVERRIDE { | 263 virtual void purgeResources() SK_OVERRIDE { |
282 // 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 |
283 // get rid of them all. | 265 // get rid of them all. |
284 fClipMaskManager.releaseResources(); | 266 fClipMaskManager.purgeResources(); |
285 } | 267 } |
286 | 268 |
287 // After the client interacts directly with the 3D context state the GrGpu | 269 // After the client interacts directly with the 3D context state the GrGpu |
288 // must resync its internal state and assumptions about 3D context state. | 270 // must resync its internal state and assumptions about 3D context state. |
289 // Each time this occurs the GrGpu bumps a timestamp. | 271 // Each time this occurs the GrGpu bumps a timestamp. |
290 // state of the 3D context | 272 // state of the 3D context |
291 // At 10 resets / frame and 60fps a 64bit timestamp will overflow in about | 273 // At 10 resets / frame and 60fps a 64bit timestamp will overflow in about |
292 // a billion years. | 274 // a billion years. |
293 typedef uint64_t ResetTimestamp; | 275 typedef uint64_t ResetTimestamp; |
294 | 276 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 | 501 |
520 void handleDirtyContext() { | 502 void handleDirtyContext() { |
521 if (fResetBits) { | 503 if (fResetBits) { |
522 this->resetContext(); | 504 this->resetContext(); |
523 } | 505 } |
524 } | 506 } |
525 | 507 |
526 enum { | 508 enum { |
527 kPreallocGeomPoolStateStackCnt = 4, | 509 kPreallocGeomPoolStateStackCnt = 4, |
528 }; | 510 }; |
529 typedef SkTInternalLList<GrGpuResource> ObjectList; | |
530 SkSTArray<kPreallocGeomPoolStateStackCnt, GeometryPoolState, true> fGeomPoo
lStateStack; | 511 SkSTArray<kPreallocGeomPoolStateStackCnt, GeometryPoolState, true> fGeomPoo
lStateStack; |
531 ResetTimestamp fResetTi
mestamp; | 512 ResetTimestamp fResetTi
mestamp; |
532 uint32_t fResetBi
ts; | 513 uint32_t fResetBi
ts; |
533 GrVertexBufferAllocPool* fVertexP
ool; | 514 GrVertexBufferAllocPool* fVertexP
ool; |
534 GrIndexBufferAllocPool* fIndexPo
ol; | 515 GrIndexBufferAllocPool* fIndexPo
ol; |
535 // counts number of uses of vertex/index pool in the geometry stack | 516 // counts number of uses of vertex/index pool in the geometry stack |
536 int fVertexP
oolUseCnt; | 517 int fVertexP
oolUseCnt; |
537 int fIndexPo
olUseCnt; | 518 int fIndexPo
olUseCnt; |
538 // these are mutable so they can be created on-demand | 519 // these are mutable so they can be created on-demand |
539 mutable GrIndexBuffer* fQuadInd
exBuffer; | 520 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; | |
543 | 521 |
544 typedef GrDrawTarget INHERITED; | 522 typedef GrDrawTarget INHERITED; |
545 }; | 523 }; |
546 | 524 |
547 #endif | 525 #endif |
OLD | NEW |