| 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 | 405 |
| 406 /** | 406 /** |
| 407 * Sets source of index data for the next indexed draw. Data does not have | 407 * Sets source of index data for the next indexed draw. Data does not have |
| 408 * to be in the buffer until drawIndexed. | 408 * to be in the buffer until drawIndexed. |
| 409 * | 409 * |
| 410 * @param buffer index buffer containing indices. Must be unlocked | 410 * @param buffer index buffer containing indices. Must be unlocked |
| 411 * before indexed draw call. | 411 * before indexed draw call. |
| 412 */ | 412 */ |
| 413 void setIndexSourceToBuffer(const GrIndexBuffer* buffer); | 413 void setIndexSourceToBuffer(const GrIndexBuffer* buffer); |
| 414 | 414 |
| 415 virtual void draw(const GrDrawTarget::DrawInfo&, |
| 416 const GrClipMaskManager::ScissorState&); |
| 417 virtual void stencilPath(const GrPath*, |
| 418 const GrClipMaskManager::ScissorState&, |
| 419 const GrStencilSettings&); |
| 420 virtual void drawPath(const GrPath*, |
| 421 const GrClipMaskManager::ScissorState&, |
| 422 const GrStencilSettings&, |
| 423 const GrDeviceCoordTexture* dstCopy); |
| 424 virtual void drawPaths(const GrPathRange*, |
| 425 const uint32_t indices[], |
| 426 int count, |
| 427 const float transforms[], |
| 428 GrDrawTarget::PathTransformType, |
| 429 const GrClipMaskManager::ScissorState&, |
| 430 const GrStencilSettings&, |
| 431 const GrDeviceCoordTexture*); |
| 432 |
| 415 protected: | 433 protected: |
| 416 DrawType PrimTypeToDrawType(GrPrimitiveType type) { | 434 DrawType PrimTypeToDrawType(GrPrimitiveType type) { |
| 417 switch (type) { | 435 switch (type) { |
| 418 case kTriangles_GrPrimitiveType: | 436 case kTriangles_GrPrimitiveType: |
| 419 case kTriangleStrip_GrPrimitiveType: | 437 case kTriangleStrip_GrPrimitiveType: |
| 420 case kTriangleFan_GrPrimitiveType: | 438 case kTriangleFan_GrPrimitiveType: |
| 421 return kDrawTriangles_DrawType; | 439 return kDrawTriangles_DrawType; |
| 422 case kPoints_GrPrimitiveType: | 440 case kPoints_GrPrimitiveType: |
| 423 return kDrawPoints_DrawType; | 441 return kDrawPoints_DrawType; |
| 424 case kLines_GrPrimitiveType: | 442 case kLines_GrPrimitiveType: |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 const void* srcData, | 495 const void* srcData, |
| 478 size_t rowBytes) = 0; | 496 size_t rowBytes) = 0; |
| 479 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, | 497 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, |
| 480 const void* srcData) = 0; | 498 const void* srcData) = 0; |
| 481 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) = 0; | 499 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) = 0; |
| 482 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&) = 0; | 500 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&) = 0; |
| 483 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; | 501 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; |
| 484 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0; | 502 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0; |
| 485 | 503 |
| 486 // overridden by backend-specific derived class to perform the clear. | 504 // overridden by backend-specific derived class to perform the clear. |
| 487 virtual void onGpuClear(GrRenderTarget*, const SkIRect* rect, GrColor color, | 505 virtual void onClear(GrRenderTarget*, const SkIRect* rect, GrColor color, |
| 488 bool canIgnoreRect) = 0; | 506 bool canIgnoreRect) = 0; |
| 489 | 507 |
| 490 | 508 |
| 491 // Overridden by backend specific classes to perform a clear of the stencil
clip bits. This is | 509 // Overridden by backend specific classes to perform a clear of the stencil
clip bits. This is |
| 492 // ONLY used by the the clip target | 510 // ONLY used by the the clip target |
| 493 virtual void onClearStencilClip(GrRenderTarget*, | 511 virtual void onClearStencilClip(GrRenderTarget*, |
| 494 const SkIRect& rect, | 512 const SkIRect& rect, |
| 495 bool insideClip) = 0; | 513 bool insideClip) = 0; |
| 496 | 514 |
| 497 // overridden by backend-specific derived class to perform the draw call. | 515 // overridden by backend-specific derived class to perform the draw call. |
| 498 virtual void onGpuDraw(const GrDrawTarget::DrawInfo&) = 0; | 516 virtual void onDraw(const GrDrawTarget::DrawInfo&) = 0; |
| 499 | 517 |
| 500 // overridden by backend-specific derived class to perform the read pixels. | 518 // overridden by backend-specific derived class to perform the read pixels. |
| 501 virtual bool onReadPixels(GrRenderTarget* target, | 519 virtual bool onReadPixels(GrRenderTarget* target, |
| 502 int left, int top, int width, int height, | 520 int left, int top, int width, int height, |
| 503 GrPixelConfig, | 521 GrPixelConfig, |
| 504 void* buffer, | 522 void* buffer, |
| 505 size_t rowBytes) = 0; | 523 size_t rowBytes) = 0; |
| 506 | 524 |
| 507 // overridden by backend-specific derived class to perform the texture updat
e | 525 // overridden by backend-specific derived class to perform the texture updat
e |
| 508 virtual bool onWriteTexturePixels(GrTexture* texture, | 526 virtual bool onWriteTexturePixels(GrTexture* texture, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 528 virtual bool flushGraphicsState(DrawType, | 546 virtual bool flushGraphicsState(DrawType, |
| 529 const GrClipMaskManager::ScissorState&, | 547 const GrClipMaskManager::ScissorState&, |
| 530 const GrDeviceCoordTexture* dstCopy) = 0; | 548 const GrDeviceCoordTexture* dstCopy) = 0; |
| 531 | 549 |
| 532 // clears target's entire stencil buffer to 0 | 550 // clears target's entire stencil buffer to 0 |
| 533 virtual void clearStencil(GrRenderTarget* target) = 0; | 551 virtual void clearStencil(GrRenderTarget* target) = 0; |
| 534 | 552 |
| 535 // Given a rt, find or create a stencil buffer and attach it | 553 // Given a rt, find or create a stencil buffer and attach it |
| 536 bool attachStencilBufferToRenderTarget(GrRenderTarget* target); | 554 bool attachStencilBufferToRenderTarget(GrRenderTarget* target); |
| 537 | 555 |
| 538 // GrDrawTarget overrides | |
| 539 virtual void onDraw(const GrDrawTarget::DrawInfo&, | |
| 540 const GrClipMaskManager::ScissorState&); | |
| 541 virtual void onStencilPath(const GrPath*, | |
| 542 const GrClipMaskManager::ScissorState&, | |
| 543 const GrStencilSettings&); | |
| 544 virtual void onDrawPath(const GrPath*, | |
| 545 const GrClipMaskManager::ScissorState&, | |
| 546 const GrStencilSettings&, | |
| 547 const GrDeviceCoordTexture* dstCopy); | |
| 548 virtual void onDrawPaths(const GrPathRange*, | |
| 549 const uint32_t indices[], | |
| 550 int count, | |
| 551 const float transforms[], | |
| 552 GrDrawTarget::PathTransformType, | |
| 553 const GrClipMaskManager::ScissorState&, | |
| 554 const GrStencilSettings&, | |
| 555 const GrDeviceCoordTexture*); | |
| 556 | |
| 557 virtual void didAddGpuTraceMarker() = 0; | 556 virtual void didAddGpuTraceMarker() = 0; |
| 558 virtual void didRemoveGpuTraceMarker() = 0; | 557 virtual void didRemoveGpuTraceMarker() = 0; |
| 559 | 558 |
| 560 void resetContext() { | 559 void resetContext() { |
| 561 this->onResetContext(fResetBits); | 560 this->onResetContext(fResetBits); |
| 562 fResetBits = 0; | 561 fResetBits = 0; |
| 563 ++fResetTimestamp; | 562 ++fResetTimestamp; |
| 564 } | 563 } |
| 565 | 564 |
| 566 void handleDirtyContext() { | 565 void handleDirtyContext() { |
| 567 if (fResetBits) { | 566 if (fResetBits) { |
| 568 this->resetContext(); | 567 this->resetContext(); |
| 569 } | 568 } |
| 570 } | 569 } |
| 571 | 570 |
| 572 GeometrySrcState fGeoSrcS
tate; | 571 GeometrySrcState fGeoSrcS
tate; |
| 573 ResetTimestamp fResetTi
mestamp; | 572 ResetTimestamp fResetTi
mestamp; |
| 574 uint32_t fResetBi
ts; | 573 uint32_t fResetBi
ts; |
| 575 // these are mutable so they can be created on-demand | 574 // these are mutable so they can be created on-demand |
| 576 mutable GrIndexBuffer* fQuadInd
exBuffer; | 575 mutable GrIndexBuffer* fQuadInd
exBuffer; |
| 577 GrDrawState fDefault
DrawState; | 576 GrDrawState fDefault
DrawState; |
| 578 GrDrawState* fDrawSta
te; | 577 GrDrawState* fDrawSta
te; |
| 579 // To keep track that we always have at least as many debug marker adds as r
emoves | 578 // To keep track that we always have at least as many debug marker adds as r
emoves |
| 580 int fGpuTrac
eMarkerCount; | 579 int fGpuTrac
eMarkerCount; |
| 581 GrTraceMarkerSet fActiveT
raceMarkers; | 580 GrTraceMarkerSet fActiveT
raceMarkers; |
| 582 GrTraceMarkerSet fStoredT
raceMarkers; | 581 GrTraceMarkerSet fStoredT
raceMarkers; |
| 583 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. | 582 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. |
| 584 GrContext* fContext
; | 583 GrContext* fContext
; |
| 585 | 584 |
| 586 // TODO fix this | |
| 587 friend class GrInOrderDrawBuffer; | |
| 588 | |
| 589 typedef SkRefCnt INHERITED; | 585 typedef SkRefCnt INHERITED; |
| 590 }; | 586 }; |
| 591 | 587 |
| 592 #endif | 588 #endif |
| OLD | NEW |