| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 GrDrawTarget_DEFINED | 8 #ifndef GrDrawTarget_DEFINED |
| 9 #define GrDrawTarget_DEFINED | 9 #define GrDrawTarget_DEFINED |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "SkStrokeRec.h" | 24 #include "SkStrokeRec.h" |
| 25 #include "SkTArray.h" | 25 #include "SkTArray.h" |
| 26 #include "SkTLazy.h" | 26 #include "SkTLazy.h" |
| 27 #include "SkTypes.h" | 27 #include "SkTypes.h" |
| 28 #include "SkXfermode.h" | 28 #include "SkXfermode.h" |
| 29 | 29 |
| 30 //#define ENABLE_MDB 1 | 30 //#define ENABLE_MDB 1 |
| 31 | 31 |
| 32 class GrAuditTrail; | 32 class GrAuditTrail; |
| 33 class GrBatch; | 33 class GrBatch; |
| 34 class GrClearBatch; |
| 34 class GrClip; | 35 class GrClip; |
| 35 class GrCaps; | 36 class GrCaps; |
| 36 class GrPath; | 37 class GrPath; |
| 37 class GrDrawPathBatchBase; | 38 class GrDrawPathBatchBase; |
| 38 class GrPipelineBuilder; | 39 class GrPipelineBuilder; |
| 39 | 40 |
| 40 class GrDrawTarget final : public SkRefCnt { | 41 class GrDrawTarget final : public SkRefCnt { |
| 41 public: | 42 public: |
| 42 /** Options for GrDrawTarget behavior. */ | 43 /** Options for GrDrawTarget behavior. */ |
| 43 struct Options { | 44 struct Options { |
| 44 Options () | 45 Options () |
| 45 : fClipBatchToBounds(false) | 46 : fClipBatchToBounds(false) |
| 46 , fDrawBatchBounds(false) | 47 , fDrawBatchBounds(false) |
| 47 , fMaxBatchLookback(-1) | 48 , fMaxBatchLookback(-1) |
| 48 , fMaxBatchLookahead(-1) {} | 49 , fMaxBatchLookahead(-1) {} |
| 49 bool fClipBatchToBounds; | 50 bool fClipBatchToBounds; |
| 50 bool fDrawBatchBounds; | 51 bool fDrawBatchBounds; |
| 51 int fMaxBatchLookback; | 52 int fMaxBatchLookback; |
| 52 int fMaxBatchLookahead; | 53 int fMaxBatchLookahead; |
| 53 }; | 54 }; |
| 54 | 55 |
| 55 GrDrawTarget(GrRenderTarget*, GrGpu*, GrResourceProvider*, GrAuditTrail*, co
nst Options&); | 56 GrDrawTarget(GrRenderTarget*, GrGpu*, GrResourceProvider*, GrAuditTrail*, co
nst Options&); |
| 56 | 57 |
| 57 ~GrDrawTarget() override; | 58 ~GrDrawTarget() override; |
| 58 | 59 |
| 59 void makeClosed() { | 60 void makeClosed() { |
| 61 fLastFullClearBatch = nullptr; |
| 60 // We only close drawTargets When MDB is enabled. When MDB is disabled t
here is only | 62 // We only close drawTargets When MDB is enabled. When MDB is disabled t
here is only |
| 61 // ever one drawTarget and all calls will be funnelled into it. | 63 // ever one drawTarget and all calls will be funnelled into it. |
| 62 #ifdef ENABLE_MDB | 64 #ifdef ENABLE_MDB |
| 63 this->setFlag(kClosed_Flag); | 65 this->setFlag(kClosed_Flag); |
| 64 #endif | 66 #endif |
| 65 this->forwardCombine(); | 67 this->forwardCombine(); |
| 66 } | 68 } |
| 67 | 69 |
| 68 bool isClosed() const { return this->isSetFlag(kClosed_Flag); } | 70 bool isClosed() const { return this->isSetFlag(kClosed_Flag); } |
| 69 | 71 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 return dt->isSetFlag(GrDrawTarget::kTempMark_Flag); | 189 return dt->isSetFlag(GrDrawTarget::kTempMark_Flag); |
| 188 } | 190 } |
| 189 static int NumDependencies(const GrDrawTarget* dt) { | 191 static int NumDependencies(const GrDrawTarget* dt) { |
| 190 return dt->fDependencies.count(); | 192 return dt->fDependencies.count(); |
| 191 } | 193 } |
| 192 static GrDrawTarget* Dependency(GrDrawTarget* dt, int index) { | 194 static GrDrawTarget* Dependency(GrDrawTarget* dt, int index) { |
| 193 return dt->fDependencies[index]; | 195 return dt->fDependencies[index]; |
| 194 } | 196 } |
| 195 }; | 197 }; |
| 196 | 198 |
| 197 void recordBatch(GrBatch*, const SkRect& clippedBounds); | 199 // Returns the batch that the input batch was combined with or the input bat
ch if it wasn't |
| 200 // combined. |
| 201 GrBatch* recordBatch(GrBatch*, const SkRect& clippedBounds); |
| 198 void forwardCombine(); | 202 void forwardCombine(); |
| 199 | 203 |
| 200 // Makes a copy of the dst if it is necessary for the draw. Returns false if
a copy is required | 204 // Makes a copy of the dst if it is necessary for the draw. Returns false if
a copy is required |
| 201 // but couldn't be made. Otherwise, returns true. This method needs to be p
rotected because it | 205 // but couldn't be made. Otherwise, returns true. This method needs to be p
rotected because it |
| 202 // needs to be accessed by GLPrograms to setup a correct drawstate | 206 // needs to be accessed by GLPrograms to setup a correct drawstate |
| 203 bool setupDstReadIfNecessary(const GrPipelineBuilder&, | 207 bool setupDstReadIfNecessary(const GrPipelineBuilder&, |
| 204 GrRenderTarget*, | 208 GrRenderTarget*, |
| 205 const GrClip&, | 209 const GrClip&, |
| 206 const GrPipelineOptimizations& optimizations, | 210 const GrPipelineOptimizations& optimizations, |
| 207 GrXferProcessor::DstTexture*, | 211 GrXferProcessor::DstTexture*, |
| 208 const SkRect& batchBounds); | 212 const SkRect& batchBounds); |
| 209 | 213 |
| 210 void addDependency(GrDrawTarget* dependedOn); | 214 void addDependency(GrDrawTarget* dependedOn); |
| 211 | 215 |
| 212 // Used only by drawContextPriv. | 216 // Used only by drawContextPriv. |
| 213 void clearStencilClip(const SkIRect&, bool insideClip, GrRenderTarget*); | 217 void clearStencilClip(const SkIRect&, bool insideClip, GrRenderTarget*); |
| 214 | 218 |
| 215 struct RecordedBatch { | 219 struct RecordedBatch { |
| 216 sk_sp<GrBatch> fBatch; | 220 sk_sp<GrBatch> fBatch; |
| 217 SkRect fClippedBounds; | 221 SkRect fClippedBounds; |
| 218 }; | 222 }; |
| 219 SkSTArray<256, RecordedBatch, true> fRecordedBatches; | 223 SkSTArray<256, RecordedBatch, true> fRecordedBatches; |
| 224 GrClearBatch* fLastFullClearBatch; |
| 220 // The context is only in service of the GrClip, remove once it doesn't need
this. | 225 // The context is only in service of the GrClip, remove once it doesn't need
this. |
| 221 GrContext* fContext; | 226 GrContext* fContext; |
| 222 GrGpu* fGpu; | 227 GrGpu* fGpu; |
| 223 GrResourceProvider* fResourceProvider; | 228 GrResourceProvider* fResourceProvider; |
| 224 GrAuditTrail* fAuditTrail; | 229 GrAuditTrail* fAuditTrail; |
| 225 | 230 |
| 226 SkDEBUGCODE(int fDebugID;) | 231 SkDEBUGCODE(int fDebugID;) |
| 227 uint32_t fFlags; | 232 uint32_t fFlags; |
| 228 | 233 |
| 229 // 'this' drawTarget relies on the output of the drawTargets in 'fDependenci
es' | 234 // 'this' drawTarget relies on the output of the drawTargets in 'fDependenci
es' |
| 230 SkTDArray<GrDrawTarget*> fDependencies; | 235 SkTDArray<GrDrawTarget*> fDependencies; |
| 231 GrRenderTarget* fRenderTarget; | 236 GrRenderTarget* fRenderTarget; |
| 232 | 237 |
| 233 bool fClipBatchToBounds; | 238 bool fClipBatchToBounds; |
| 234 bool fDrawBatchBounds; | 239 bool fDrawBatchBounds; |
| 235 int fMaxBatchLookback; | 240 int fMaxBatchLookback; |
| 236 int fMaxBatchLookahead; | 241 int fMaxBatchLookahead; |
| 237 | 242 |
| 238 SkAutoTDelete<gr_instanced::InstancedRendering> fInstancedRendering; | 243 SkAutoTDelete<gr_instanced::InstancedRendering> fInstancedRendering; |
| 239 | 244 |
| 240 typedef SkRefCnt INHERITED; | 245 typedef SkRefCnt INHERITED; |
| 241 }; | 246 }; |
| 242 | 247 |
| 243 #endif | 248 #endif |
| OLD | NEW |