| 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 |
| 11 #include "GrPipelineBuilder.h" | 11 #include "GrPipelineBuilder.h" |
| 12 #include "GrProgramDesc.h" | 12 #include "GrProgramDesc.h" |
| 13 #include "GrRenderTargetPriv.h" |
| 13 #include "GrStencil.h" | 14 #include "GrStencil.h" |
| 14 #include "GrSwizzle.h" | 15 #include "GrSwizzle.h" |
| 15 #include "GrTextureParamsAdjuster.h" | 16 #include "GrTextureParamsAdjuster.h" |
| 16 #include "GrTypes.h" | 17 #include "GrTypes.h" |
| 17 #include "GrXferProcessor.h" | 18 #include "GrXferProcessor.h" |
| 18 #include "SkPath.h" | 19 #include "SkPath.h" |
| 19 #include "SkTArray.h" | 20 #include "SkTArray.h" |
| 21 #include <map> |
| 20 | 22 |
| 21 class GrBatchTracker; | 23 class GrBatchTracker; |
| 22 class GrContext; | 24 class GrContext; |
| 23 class GrGLContext; | 25 class GrGLContext; |
| 24 class GrIndexBuffer; | 26 class GrIndexBuffer; |
| 25 class GrNonInstancedVertices; | 27 class GrNonInstancedVertices; |
| 26 class GrPath; | 28 class GrPath; |
| 27 class GrPathRange; | 29 class GrPathRange; |
| 28 class GrPathRenderer; | 30 class GrPathRenderer; |
| 29 class GrPathRendererChain; | 31 class GrPathRendererChain; |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 | 360 |
| 359 // Called to perform a surface to surface copy. Fallbacks to issuing a draw
from the src to dst | 361 // Called to perform a surface to surface copy. Fallbacks to issuing a draw
from the src to dst |
| 360 // take place at the GrDrawTarget level and this function implement faster c
opy paths. The rect | 362 // take place at the GrDrawTarget level and this function implement faster c
opy paths. The rect |
| 361 // and point are pre-clipped. The src rect and implied dst rect are guarante
ed to be within the | 363 // and point are pre-clipped. The src rect and implied dst rect are guarante
ed to be within the |
| 362 // src/dst bounds and non-empty. | 364 // src/dst bounds and non-empty. |
| 363 bool copySurface(GrSurface* dst, | 365 bool copySurface(GrSurface* dst, |
| 364 GrSurface* src, | 366 GrSurface* src, |
| 365 const SkIRect& srcRect, | 367 const SkIRect& srcRect, |
| 366 const SkIPoint& dstPoint); | 368 const SkIPoint& dstPoint); |
| 367 | 369 |
| 370 typedef GrRenderTargetPriv::MultisampleSpecs MultisampleSpecs; |
| 371 |
| 372 const MultisampleSpecs& getMultisampleSpecs(GrRenderTarget*, const GrStencil
Settings&); |
| 373 |
| 368 struct DrawArgs { | 374 struct DrawArgs { |
| 369 DrawArgs(const GrPrimitiveProcessor* primProc, | 375 DrawArgs(const GrPrimitiveProcessor* primProc, |
| 370 const GrPipeline* pipeline, | 376 const GrPipeline* pipeline, |
| 371 const GrProgramDesc* desc) | 377 const GrProgramDesc* desc) |
| 372 : fPrimitiveProcessor(primProc) | 378 : fPrimitiveProcessor(primProc) |
| 373 , fPipeline(pipeline) | 379 , fPipeline(pipeline) |
| 374 , fDesc(desc) { | 380 , fDesc(desc) { |
| 375 SkASSERT(primProc && pipeline && desc); | 381 SkASSERT(primProc && pipeline && desc); |
| 376 } | 382 } |
| 377 const GrPrimitiveProcessor* fPrimitiveProcessor; | 383 const GrPrimitiveProcessor* fPrimitiveProcessor; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 if (fResetBits) { | 523 if (fResetBits) { |
| 518 this->resetContext(); | 524 this->resetContext(); |
| 519 } | 525 } |
| 520 } | 526 } |
| 521 | 527 |
| 522 Stats fStats; | 528 Stats fStats; |
| 523 SkAutoTDelete<GrPathRendering> fPathRendering; | 529 SkAutoTDelete<GrPathRendering> fPathRendering; |
| 524 // Subclass must initialize this in its constructor. | 530 // Subclass must initialize this in its constructor. |
| 525 SkAutoTUnref<const GrCaps> fCaps; | 531 SkAutoTUnref<const GrCaps> fCaps; |
| 526 | 532 |
| 533 typedef SkTArray<SkPoint, true> SamplePattern; |
| 534 |
| 527 private: | 535 private: |
| 528 // called when the 3D context state is unknown. Subclass should emit any | 536 // called when the 3D context state is unknown. Subclass should emit any |
| 529 // assumed 3D context state and dirty any state cache. | 537 // assumed 3D context state and dirty any state cache. |
| 530 virtual void onResetContext(uint32_t resetBits) = 0; | 538 virtual void onResetContext(uint32_t resetBits) = 0; |
| 531 | 539 |
| 532 // Called before certain draws in order to guarantee coherent results from d
st reads. | 540 // Called before certain draws in order to guarantee coherent results from d
st reads. |
| 533 virtual void xferBarrier(GrRenderTarget*, GrXferBarrierType) = 0; | 541 virtual void xferBarrier(GrRenderTarget*, GrXferBarrierType) = 0; |
| 534 | 542 |
| 535 // overridden by backend-specific derived class to create objects. | 543 // overridden by backend-specific derived class to create objects. |
| 536 // Texture size and sample size will have already been validated in base cla
ss before | 544 // Texture size and sample size will have already been validated in base cla
ss before |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 | 602 |
| 595 // overridden by backend-specific derived class to perform the resolve | 603 // overridden by backend-specific derived class to perform the resolve |
| 596 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; | 604 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; |
| 597 | 605 |
| 598 // overridden by backend specific derived class to perform the copy surface | 606 // overridden by backend specific derived class to perform the copy surface |
| 599 virtual bool onCopySurface(GrSurface* dst, | 607 virtual bool onCopySurface(GrSurface* dst, |
| 600 GrSurface* src, | 608 GrSurface* src, |
| 601 const SkIRect& srcRect, | 609 const SkIRect& srcRect, |
| 602 const SkIPoint& dstPoint) = 0; | 610 const SkIPoint& dstPoint) = 0; |
| 603 | 611 |
| 612 // overridden by backend specific derived class to perform the multisample q
ueries |
| 613 virtual void onGetMultisampleSpecs(GrRenderTarget*, |
| 614 const GrStencilSettings&, |
| 615 int* effectiveSampleCnt, |
| 616 SamplePattern*) = 0; |
| 617 |
| 604 void resetContext() { | 618 void resetContext() { |
| 605 this->onResetContext(fResetBits); | 619 this->onResetContext(fResetBits); |
| 606 fResetBits = 0; | 620 fResetBits = 0; |
| 607 ++fResetTimestamp; | 621 ++fResetTimestamp; |
| 608 } | 622 } |
| 609 | 623 |
| 610 ResetTimestamp fResetTi
mestamp; | 624 ResetTimestamp fResetTi
mestamp; |
| 611 uint32_t fResetBi
ts; | 625 uint32_t fResetBi
ts; |
| 612 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. | 626 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. |
| 613 GrContext* fContext
; | 627 GrContext* fContext
; |
| 614 | 628 |
| 629 struct SamplePatternComparator { |
| 630 bool operator()(const SamplePattern&, const SamplePattern&) const; |
| 631 }; |
| 632 |
| 633 std::map<SamplePattern, uint16_t, SamplePatternComparator> fKnownSa
mplePatterns; |
| 634 uint16_t fNextSam
plePatternID; |
| 635 SkTArray<skstd::unique_ptr<MultisampleSpecs> > fRasterM
ultisampleSpecs; |
| 636 |
| 615 friend class GrPathRendering; | 637 friend class GrPathRendering; |
| 616 typedef SkRefCnt INHERITED; | 638 typedef SkRefCnt INHERITED; |
| 617 }; | 639 }; |
| 618 | 640 |
| 619 #endif | 641 #endif |
| OLD | NEW |