OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef GrDrawPathBatch_DEFINED |
| 9 #define GrDrawPathBatch_DEFINED |
| 10 |
| 11 #include "GrDrawBatch.h" |
| 12 #include "GrGpu.h" |
| 13 #include "GrPath.h" |
| 14 #include "GrPathRendering.h" |
| 15 #include "GrPathProcessor.h" |
| 16 |
| 17 class GrDrawPathBatch final : public GrDrawBatch { |
| 18 public: |
| 19 // This must return the concrete type because we install the stencil setting
s late :( |
| 20 static GrDrawPathBatch* Create(const GrPathProcessor* primProc, const GrPath
* path) { |
| 21 return SkNEW_ARGS(GrDrawPathBatch, (primProc, path)); |
| 22 } |
| 23 |
| 24 const char* name() const override { return "DrawPath"; } |
| 25 |
| 26 SkString dumpInfo() const override { |
| 27 SkString string; |
| 28 string.printf("PATH: 0x%p", fPath.get()); |
| 29 return string; |
| 30 } |
| 31 |
| 32 virtual void getInvariantOutputColor(GrInitInvariantOutput* out) const { |
| 33 fPrimitiveProcessor->getInvariantOutputColor(out); |
| 34 } |
| 35 |
| 36 virtual void getInvariantOutputCoverage(GrInitInvariantOutput* out) const { |
| 37 fPrimitiveProcessor->getInvariantOutputCoverage(out); |
| 38 } |
| 39 |
| 40 void setStencilSettings(const GrStencilSettings& stencil) { fStencilSettings
= stencil; } |
| 41 |
| 42 private: |
| 43 GrBatchTracker* tracker() { return reinterpret_cast<GrBatchTracker*>(&fWhatc
hamacallit); } |
| 44 GrDrawPathBatch(const GrPathProcessor* primProc, const GrPath* path) |
| 45 : fPrimitiveProcessor(primProc) |
| 46 , fPath(path) { |
| 47 fBounds = path->getBounds(); |
| 48 primProc->viewMatrix().mapRect(&fBounds); |
| 49 this->initClassID<GrDrawPathBatch>(); |
| 50 } |
| 51 |
| 52 virtual void initBatchTracker(const GrPipelineOptimizations& opts) { |
| 53 fPrimitiveProcessor->initBatchTracker(this->tracker(), opts); |
| 54 } |
| 55 |
| 56 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return f
alse; } |
| 57 |
| 58 void onPrepare(GrBatchFlushState*) override {} |
| 59 |
| 60 void onDraw(GrBatchFlushState* state) override { |
| 61 GrProgramDesc desc; |
| 62 state->gpu()->buildProgramDesc(&desc, *fPrimitiveProcessor.get(), |
| 63 *this->pipeline(), *this->tracker()); |
| 64 GrPathRendering::DrawPathArgs args(fPrimitiveProcessor.get(), this->pipe
line(), |
| 65 &desc, this->tracker(), &fStencilSett
ings); |
| 66 state->gpu()->pathRendering()->drawPath(args, fPath.get()); |
| 67 } |
| 68 |
| 69 GrPendingProgramElement<const GrPathProcessor> fPrimitiveProcessor; |
| 70 PathBatchTracker fWhatchamacallit; // TOD
O: delete this |
| 71 GrStencilSettings fStencilSettings; |
| 72 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; |
| 73 }; |
| 74 |
| 75 #endif |
OLD | NEW |