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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 int left, int top, int width, int height, | 264 int left, int top, int width, int height, |
265 GrPixelConfig config, const void* buffer, | 265 GrPixelConfig config, const void* buffer, |
266 size_t rowBytes); | 266 size_t rowBytes); |
267 | 267 |
268 // GrDrawTarget overrides | 268 // GrDrawTarget overrides |
269 virtual void clear(const SkIRect* rect, | 269 virtual void clear(const SkIRect* rect, |
270 GrColor color, | 270 GrColor color, |
271 bool canIgnoreRect, | 271 bool canIgnoreRect, |
272 GrRenderTarget* renderTarget = NULL) SK_OVERRIDE; | 272 GrRenderTarget* renderTarget = NULL) SK_OVERRIDE; |
273 | 273 |
| 274 virtual void clearStencilClip(const SkIRect& rect, |
| 275 bool insideClip, |
| 276 GrRenderTarget* renderTarget = NULL) SK_OVERRI
DE; |
| 277 |
274 virtual void purgeResources() SK_OVERRIDE { | 278 virtual void purgeResources() SK_OVERRIDE { |
275 // The clip mask manager can rebuild all its clip masks so just | 279 // The clip mask manager can rebuild all its clip masks so just |
276 // get rid of them all. | 280 // get rid of them all. |
277 fClipMaskManager.purgeResources(); | 281 fClipMaskManager.purgeResources(); |
278 } | 282 } |
279 | 283 |
280 // After the client interacts directly with the 3D context state the GrGpu | 284 // After the client interacts directly with the 3D context state the GrGpu |
281 // must resync its internal state and assumptions about 3D context state. | 285 // must resync its internal state and assumptions about 3D context state. |
282 // Each time this occurs the GrGpu bumps a timestamp. | 286 // Each time this occurs the GrGpu bumps a timestamp. |
283 // state of the 3D context | 287 // state of the 3D context |
284 // At 10 resets / frame and 60fps a 64bit timestamp will overflow in about | 288 // At 10 resets / frame and 60fps a 64bit timestamp will overflow in about |
285 // a billion years. | 289 // a billion years. |
286 typedef uint64_t ResetTimestamp; | 290 typedef uint64_t ResetTimestamp; |
287 | 291 |
288 // This timestamp is always older than the current timestamp | 292 // This timestamp is always older than the current timestamp |
289 static const ResetTimestamp kExpiredTimestamp = 0; | 293 static const ResetTimestamp kExpiredTimestamp = 0; |
290 // Returns a timestamp based on the number of times the context was reset. | 294 // Returns a timestamp based on the number of times the context was reset. |
291 // This timestamp can be used to lazily detect when cached 3D context state | 295 // This timestamp can be used to lazily detect when cached 3D context state |
292 // is dirty. | 296 // is dirty. |
293 ResetTimestamp getResetTimestamp() const { | 297 ResetTimestamp getResetTimestamp() const { |
294 return fResetTimestamp; | 298 return fResetTimestamp; |
295 } | 299 } |
296 | 300 |
297 // GrGpu subclass sets clip bit in the stencil buffer. The subclass is | |
298 // free to clear the remaining bits to zero if masked clears are more | |
299 // expensive than clearing all bits. | |
300 virtual void clearStencilClip(GrRenderTarget*, const SkIRect& rect, bool ins
ideClip) = 0; | |
301 | |
302 enum PrivateDrawStateStateBits { | 301 enum PrivateDrawStateStateBits { |
303 kFirstBit = (GrDrawState::kLastPublicStateBit << 1), | 302 kFirstBit = (GrDrawState::kLastPublicStateBit << 1), |
304 | 303 |
305 kModifyStencilClip_StateBit = kFirstBit, // allows draws to modify | 304 kModifyStencilClip_StateBit = kFirstBit, // allows draws to modify |
306 // stencil bits used for | 305 // stencil bits used for |
307 // clipping. | 306 // clipping. |
308 }; | 307 }; |
309 | 308 |
310 void getPathStencilSettingsForFillType(SkPath::FillType fill, GrStencilSetti
ngs* outStencilSettings); | 309 void getPathStencilSettingsForFillType(SkPath::FillType fill, GrStencilSetti
ngs* outStencilSettings); |
311 | 310 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&) = 0; | 407 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&) = 0; |
409 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; | 408 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; |
410 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0; | 409 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0; |
411 | 410 |
412 // overridden by backend-specific derived class to perform the clear and | 411 // overridden by backend-specific derived class to perform the clear and |
413 // clearRect. NULL rect means clear whole target. If canIgnoreRect is | 412 // clearRect. NULL rect means clear whole target. If canIgnoreRect is |
414 // true, it is okay to perform a full clear instead of a partial clear | 413 // true, it is okay to perform a full clear instead of a partial clear |
415 virtual void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, | 414 virtual void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, |
416 bool canIgnoreRect) = 0; | 415 bool canIgnoreRect) = 0; |
417 | 416 |
| 417 |
| 418 // Overridden by backend specific classes to perform a clear of the stencil
clip bits. This is |
| 419 // ONLY used by the clip mask manager |
| 420 virtual void onClearStencilClip(GrRenderTarget*, |
| 421 const SkIRect& rect, |
| 422 bool insideClip) = 0; |
| 423 |
418 // overridden by backend-specific derived class to perform the draw call. | 424 // overridden by backend-specific derived class to perform the draw call. |
419 virtual void onGpuDraw(const DrawInfo&) = 0; | 425 virtual void onGpuDraw(const DrawInfo&) = 0; |
420 | 426 |
421 // overridden by backend-specific derived class to perform the read pixels. | 427 // overridden by backend-specific derived class to perform the read pixels. |
422 virtual bool onReadPixels(GrRenderTarget* target, | 428 virtual bool onReadPixels(GrRenderTarget* target, |
423 int left, int top, int width, int height, | 429 int left, int top, int width, int height, |
424 GrPixelConfig, | 430 GrPixelConfig, |
425 void* buffer, | 431 void* buffer, |
426 size_t rowBytes) = 0; | 432 size_t rowBytes) = 0; |
427 | 433 |
(...skipping 12 matching lines...) Expand all Loading... |
440 virtual bool createStencilBufferForRenderTarget(GrRenderTarget*, int width,
int height) = 0; | 446 virtual bool createStencilBufferForRenderTarget(GrRenderTarget*, int width,
int height) = 0; |
441 | 447 |
442 // attaches an existing SB to an existing RT. | 448 // attaches an existing SB to an existing RT. |
443 virtual bool attachStencilBufferToRenderTarget(GrStencilBuffer*, GrRenderTar
get*) = 0; | 449 virtual bool attachStencilBufferToRenderTarget(GrStencilBuffer*, GrRenderTar
get*) = 0; |
444 | 450 |
445 // The GrGpu typically records the clients requested state and then flushes | 451 // The GrGpu typically records the clients requested state and then flushes |
446 // deltas from previous state at draw time. This function does the | 452 // deltas from previous state at draw time. This function does the |
447 // backend-specific flush of the state. | 453 // backend-specific flush of the state. |
448 // returns false if current state is unsupported. | 454 // returns false if current state is unsupported. |
449 virtual bool flushGraphicsState(DrawType, | 455 virtual bool flushGraphicsState(DrawType, |
450 const ScissorState&, | 456 const GrClipMaskManager::ScissorState&, |
451 const GrDeviceCoordTexture* dstCopy) = 0; | 457 const GrDeviceCoordTexture* dstCopy) = 0; |
452 | 458 |
453 // clears target's entire stencil buffer to 0 | 459 // clears target's entire stencil buffer to 0 |
454 virtual void clearStencil(GrRenderTarget* target) = 0; | 460 virtual void clearStencil(GrRenderTarget* target) = 0; |
455 | 461 |
456 // Given a rt, find or create a stencil buffer and attach it | 462 // Given a rt, find or create a stencil buffer and attach it |
457 bool attachStencilBufferToRenderTarget(GrRenderTarget* target); | 463 bool attachStencilBufferToRenderTarget(GrRenderTarget* target); |
458 | 464 |
459 // GrDrawTarget overrides | 465 // GrDrawTarget overrides |
460 virtual void onDraw(const DrawInfo&) SK_OVERRIDE; | 466 virtual void onDraw(const DrawInfo&) SK_OVERRIDE; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 // counts number of uses of vertex/index pool in the geometry stack | 503 // counts number of uses of vertex/index pool in the geometry stack |
498 int fVertexP
oolUseCnt; | 504 int fVertexP
oolUseCnt; |
499 int fIndexPo
olUseCnt; | 505 int fIndexPo
olUseCnt; |
500 // these are mutable so they can be created on-demand | 506 // these are mutable so they can be created on-demand |
501 mutable GrIndexBuffer* fQuadInd
exBuffer; | 507 mutable GrIndexBuffer* fQuadInd
exBuffer; |
502 | 508 |
503 typedef GrDrawTarget INHERITED; | 509 typedef GrDrawTarget INHERITED; |
504 }; | 510 }; |
505 | 511 |
506 #endif | 512 #endif |
OLD | NEW |