| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // The context may not be fully constructed and should not be used during Gr
DrawTarget | 46 // The context may not be fully constructed and should not be used during Gr
DrawTarget |
| 47 // construction. | 47 // construction. |
| 48 GrDrawTarget(GrGpu* gpu, GrResourceProvider*); | 48 GrDrawTarget(GrGpu* gpu, GrResourceProvider*); |
| 49 | 49 |
| 50 ~GrDrawTarget() override; | 50 ~GrDrawTarget() override; |
| 51 | 51 |
| 52 void makeClosed() { | 52 void makeClosed() { |
| 53 // We only close drawTargets When MDB is enabled. When MDB is disabled t
here is only | 53 // We only close drawTargets When MDB is enabled. When MDB is disabled t
here is only |
| 54 // ever one drawTarget and all calls will be funnelled into it. | 54 // ever one drawTarget and all calls will be funnelled into it. |
| 55 #ifdef ENABLE_MDB | 55 #ifdef ENABLE_MDB |
| 56 fClosed = true; | 56 this->setFlag(kClosed_Flag); |
| 57 #endif | 57 #endif |
| 58 } | 58 } |
| 59 bool isClosed() const { return fClosed; } | 59 bool isClosed() const { return this->isSetFlag(kClosed_Flag); } |
| 60 |
| 61 /* |
| 62 * Notify this drawTarget that it relies on the contents of 'dependedOn' |
| 63 */ |
| 64 void addDependency(GrSurface* dependedOn); |
| 65 |
| 66 /* |
| 67 * Does this drawTarget depend on 'dependedOn'? |
| 68 */ |
| 69 bool dependsOn(GrDrawTarget* dependedOn) const { |
| 70 return fDependencies.find(dependedOn) >= 0; |
| 71 } |
| 60 | 72 |
| 61 /** | 73 /** |
| 62 * Empties the draw buffer of any queued up draws. | 74 * Empties the draw buffer of any queued up draws. |
| 63 */ | 75 */ |
| 64 void reset(); | 76 void reset(); |
| 65 | 77 |
| 66 /** | 78 /** |
| 67 * This plays any queued up draws to its GrGpu target. It also resets this o
bject (i.e. flushing | 79 * This plays any queued up draws to its GrGpu target. It also resets this o
bject (i.e. flushing |
| 68 * is destructive). | 80 * is destructive). |
| 69 */ | 81 */ |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 209 } |
| 198 | 210 |
| 199 GrContext* context() const { return fDrawTarget->fContext; } | 211 GrContext* context() const { return fDrawTarget->fContext; } |
| 200 GrResourceProvider* resourceProvider() const { return fDrawTarget->fReso
urceProvider; } | 212 GrResourceProvider* resourceProvider() const { return fDrawTarget->fReso
urceProvider; } |
| 201 GrDrawTarget* fDrawTarget; | 213 GrDrawTarget* fDrawTarget; |
| 202 friend class GrClipMaskManager; | 214 friend class GrClipMaskManager; |
| 203 }; | 215 }; |
| 204 | 216 |
| 205 const CMMAccess cmmAccess() { return CMMAccess(this); } | 217 const CMMAccess cmmAccess() { return CMMAccess(this); } |
| 206 | 218 |
| 219 |
| 207 private: | 220 private: |
| 221 friend class GrDrawingManager; // for resetFlag & TopoSortTraits |
| 222 |
| 223 enum Flags { |
| 224 kClosed_Flag = 0x01, //!< This drawTarget can't accept any more bat
ches |
| 225 |
| 226 kWasOutput_Flag = 0x02, //!< Flag for topological sorting |
| 227 kTempMark_Flag = 0x04, //!< Flag for topological sorting |
| 228 }; |
| 229 |
| 230 void setFlag(uint32_t flag) { |
| 231 fFlags |= flag; |
| 232 } |
| 233 |
| 234 void resetFlag(uint32_t flag) { |
| 235 fFlags &= ~flag; |
| 236 } |
| 237 |
| 238 bool isSetFlag(uint32_t flag) const { |
| 239 return SkToBool(fFlags & flag); |
| 240 } |
| 241 |
| 242 struct TopoSortTraits { |
| 243 static void Output(GrDrawTarget* dt, int /* index */) { |
| 244 dt->setFlag(GrDrawTarget::kWasOutput_Flag); |
| 245 } |
| 246 static bool WasOutput(const GrDrawTarget* dt) { |
| 247 return dt->isSetFlag(GrDrawTarget::kWasOutput_Flag); |
| 248 } |
| 249 static void SetTempMark(GrDrawTarget* dt) { |
| 250 dt->setFlag(GrDrawTarget::kTempMark_Flag); |
| 251 } |
| 252 static void ResetTempMark(GrDrawTarget* dt) { |
| 253 dt->resetFlag(GrDrawTarget::kTempMark_Flag); |
| 254 } |
| 255 static bool IsTempMarked(const GrDrawTarget* dt) { |
| 256 return dt->isSetFlag(GrDrawTarget::kTempMark_Flag); |
| 257 } |
| 258 static int NumDependencies(const GrDrawTarget* dt) { |
| 259 return dt->fDependencies.count(); |
| 260 } |
| 261 static GrDrawTarget* Dependency(GrDrawTarget* dt, int index) { |
| 262 return dt->fDependencies[index]; |
| 263 } |
| 264 }; |
| 265 |
| 208 void recordBatch(GrBatch*); | 266 void recordBatch(GrBatch*); |
| 209 bool installPipelineInDrawBatch(const GrPipelineBuilder* pipelineBuilder, | 267 bool installPipelineInDrawBatch(const GrPipelineBuilder* pipelineBuilder, |
| 210 const GrScissorState* scissor, | 268 const GrScissorState* scissor, |
| 211 GrDrawBatch* batch); | 269 GrDrawBatch* batch); |
| 212 | 270 |
| 213 // Makes a copy of the dst if it is necessary for the draw. Returns false if
a copy is required | 271 // Makes a copy of the dst if it is necessary for the draw. Returns false if
a copy is required |
| 214 // but couldn't be made. Otherwise, returns true. This method needs to be p
rotected because it | 272 // but couldn't be made. Otherwise, returns true. This method needs to be p
rotected because it |
| 215 // needs to be accessed by GLPrograms to setup a correct drawstate | 273 // needs to be accessed by GLPrograms to setup a correct drawstate |
| 216 bool setupDstReadIfNecessary(const GrPipelineBuilder&, | 274 bool setupDstReadIfNecessary(const GrPipelineBuilder&, |
| 217 const GrProcOptInfo& colorPOI, | 275 const GrProcOptInfo& colorPOI, |
| 218 const GrProcOptInfo& coveragePOI, | 276 const GrProcOptInfo& coveragePOI, |
| 219 GrXferProcessor::DstTexture*, | 277 GrXferProcessor::DstTexture*, |
| 220 const SkRect& batchBounds); | 278 const SkRect& batchBounds); |
| 221 | 279 |
| 222 void drawPathBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawPathBatch
Base* batch, | 280 void drawPathBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawPathBatch
Base* batch, |
| 223 GrPathRendering::FillType fill); | 281 GrPathRendering::FillType fill); |
| 224 // Check to see if this set of draw commands has been sent out | 282 // Check to see if this set of draw commands has been sent out |
| 225 void getPathStencilSettingsForFilltype(GrPathRendering::FillType, | 283 void getPathStencilSettingsForFilltype(GrPathRendering::FillType, |
| 226 const GrStencilAttachment*, | 284 const GrStencilAttachment*, |
| 227 GrStencilSettings*); | 285 GrStencilSettings*); |
| 228 bool setupClip(const GrPipelineBuilder&, | 286 bool setupClip(const GrPipelineBuilder&, |
| 229 GrPipelineBuilder::AutoRestoreFragmentProcessorState*
, | 287 GrPipelineBuilder::AutoRestoreFragmentProcessorState*
, |
| 230 GrPipelineBuilder::AutoRestoreStencil*, | 288 GrPipelineBuilder::AutoRestoreStencil*, |
| 231 GrScissorState*, | 289 GrScissorState*, |
| 232 const SkRect* devBounds); | 290 const SkRect* devBounds); |
| 233 | 291 |
| 292 void addDependency(GrDrawTarget* dependedOn); |
| 293 |
| 234 // Used only by CMM. | 294 // Used only by CMM. |
| 235 void clearStencilClip(const SkIRect&, bool insideClip, GrRenderTarget*); | 295 void clearStencilClip(const SkIRect&, bool insideClip, GrRenderTarget*); |
| 236 | 296 |
| 237 SkSTArray<256, SkAutoTUnref<GrBatch>, true> fBatches; | 297 SkSTArray<256, SkAutoTUnref<GrBatch>, true> fBatches; |
| 238 SkAutoTDelete<GrClipMaskManager> fClipMaskManager; | 298 SkAutoTDelete<GrClipMaskManager> fClipMaskManager; |
| 239 // The context is only in service of the clip mask manager, remove once CMM
doesn't need this. | 299 // The context is only in service of the clip mask manager, remove once CMM
doesn't need this. |
| 240 GrContext* fContext; | 300 GrContext* fContext; |
| 241 GrGpu* fGpu; | 301 GrGpu* fGpu; |
| 242 GrResourceProvider* fResourceProvider; | 302 GrResourceProvider* fResourceProvider; |
| 243 GrBatchFlushState fFlushState; | 303 GrBatchFlushState fFlushState; |
| 244 bool fFlushing; | 304 bool fFlushing; |
| 245 int fFirstUnpreparedBatch; | 305 int fFirstUnpreparedBatch; |
| 246 | 306 |
| 247 bool fClosed; | 307 uint32_t fFlags; |
| 308 |
| 309 // 'this' drawTarget relies on the output of the drawTargets in 'fDependenci
es' |
| 310 SkTDArray<GrDrawTarget*> fDependencies; |
| 248 | 311 |
| 249 typedef SkRefCnt INHERITED; | 312 typedef SkRefCnt INHERITED; |
| 250 }; | 313 }; |
| 251 | 314 |
| 252 #endif | 315 #endif |
| OLD | NEW |