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 28 matching lines...) Expand all Loading... |
39 public: | 39 public: |
40 SK_DECLARE_INST_COUNT(GrDrawTarget) | 40 SK_DECLARE_INST_COUNT(GrDrawTarget) |
41 | 41 |
42 typedef GrPathRange::PathIndexType PathIndexType; | 42 typedef GrPathRange::PathIndexType PathIndexType; |
43 typedef GrPathRendering::PathTransformType PathTransformType; | 43 typedef GrPathRendering::PathTransformType PathTransformType; |
44 | 44 |
45 /////////////////////////////////////////////////////////////////////////// | 45 /////////////////////////////////////////////////////////////////////////// |
46 | 46 |
47 // The context may not be fully constructed and should not be used during Gr
DrawTarget | 47 // The context may not be fully constructed and should not be used during Gr
DrawTarget |
48 // construction. | 48 // construction. |
49 GrDrawTarget(GrContext* context); | 49 GrDrawTarget(GrGpu* gpu, GrResourceProvider*); |
50 | 50 |
51 virtual ~GrDrawTarget() {} | 51 virtual ~GrDrawTarget(); |
52 | 52 |
53 /** | 53 /** |
54 * Empties the draw buffer of any queued up draws. | 54 * Empties the draw buffer of any queued up draws. |
55 */ | 55 */ |
56 void reset() { this->onReset(); } | 56 void reset() { this->onReset(); } |
57 | 57 |
58 /** | 58 /** |
59 * This plays any queued up draws to its GrGpu target. It also resets this o
bject (i.e. flushing | 59 * This plays any queued up draws to its GrGpu target. It also resets this o
bject (i.e. flushing |
60 * is destructive). | 60 * is destructive). |
61 */ | 61 */ |
62 void flush(); | 62 void flush(); |
63 | 63 |
64 /** | 64 /** |
65 * Gets the capabilities of the draw target. | 65 * Gets the capabilities of the draw target. |
66 */ | 66 */ |
67 const GrCaps* caps() const { return fCaps.get(); } | 67 const GrCaps* caps() const { return fCaps; } |
68 | 68 |
69 void drawBatch(GrPipelineBuilder*, GrBatch*); | 69 void drawBatch(GrPipelineBuilder*, GrBatch*); |
70 | 70 |
71 /** | 71 /** |
72 * Draws path into the stencil buffer. The fill must be either even/odd or | 72 * Draws path into the stencil buffer. The fill must be either even/odd or |
73 * winding (not inverse or hairline). It will respect the HW antialias flag | 73 * winding (not inverse or hairline). It will respect the HW antialias flag |
74 * on the GrPipelineBuilder (if possible in the 3D API). Note, we will neve
r have an inverse | 74 * on the GrPipelineBuilder (if possible in the 3D API). Note, we will neve
r have an inverse |
75 * fill with stencil path | 75 * fill with stencil path |
76 */ | 76 */ |
77 void stencilPath(GrPipelineBuilder*, const GrPathProcessor*, const GrPath*, | 77 void stencilPath(GrPipelineBuilder*, const GrPathProcessor*, const GrPath*, |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 const GrSurface* src, | 201 const GrSurface* src, |
202 const SkIRect& srcRect, | 202 const SkIRect& srcRect, |
203 const SkIPoint& dstPoint); | 203 const SkIPoint& dstPoint); |
204 | 204 |
205 /** | 205 /** |
206 * Release any resources that are cached but not currently in use. This | 206 * Release any resources that are cached but not currently in use. This |
207 * is intended to give an application some recourse when resources are low. | 207 * is intended to give an application some recourse when resources are low. |
208 */ | 208 */ |
209 virtual void purgeResources() {}; | 209 virtual void purgeResources() {}; |
210 | 210 |
211 bool programUnitTest(int maxStages); | 211 bool programUnitTest(GrContext* owner, int maxStages); |
212 | 212 |
213 protected: | 213 protected: |
214 friend class GrCommandBuilder; // for PipelineInfo | 214 friend class GrCommandBuilder; // for PipelineInfo |
215 friend class GrInOrderCommandBuilder; // for PipelineInfo | 215 friend class GrInOrderCommandBuilder; // for PipelineInfo |
216 friend class GrReorderCommandBuilder; // for PipelineInfo | 216 friend class GrReorderCommandBuilder; // for PipelineInfo |
217 friend class GrTargetCommands; // for PipelineInfo | 217 friend class GrTargetCommands; // for PipelineInfo |
218 | 218 |
219 GrContext* getContext() { return fContext; } | 219 GrGpu* getGpu() { return fGpu; } |
220 const GrContext* getContext() const { return fContext; } | 220 const GrGpu* getGpu() const { return fGpu; } |
221 | |
222 GrGpu* getGpu() { | |
223 SkASSERT(fContext && fContext->getGpu()); | |
224 return fContext->getGpu(); | |
225 } | |
226 const GrGpu* getGpu() const { | |
227 SkASSERT(fContext && fContext->getGpu()); | |
228 return fContext->getGpu(); | |
229 } | |
230 | 221 |
231 const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers
; } | 222 const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers
; } |
232 | 223 |
233 // Makes a copy of the dst if it is necessary for the draw. Returns false if
a copy is required | 224 // Makes a copy of the dst if it is necessary for the draw. Returns false if
a copy is required |
234 // but couldn't be made. Otherwise, returns true. This method needs to be p
rotected because it | 225 // but couldn't be made. Otherwise, returns true. This method needs to be p
rotected because it |
235 // needs to be accessed by GLPrograms to setup a correct drawstate | 226 // needs to be accessed by GLPrograms to setup a correct drawstate |
236 bool setupDstReadIfNecessary(const GrPipelineBuilder&, | 227 bool setupDstReadIfNecessary(const GrPipelineBuilder&, |
237 const GrProcOptInfo& colorPOI, | 228 const GrProcOptInfo& colorPOI, |
238 const GrProcOptInfo& coveragePOI, | 229 const GrProcOptInfo& coveragePOI, |
239 GrXferProcessor::DstTexture*, | 230 GrXferProcessor::DstTexture*, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 void getPathStencilSettingsForFilltype(GrPathRendering::FillType, | 296 void getPathStencilSettingsForFilltype(GrPathRendering::FillType, |
306 const GrStencilAttachment*, | 297 const GrStencilAttachment*, |
307 GrStencilSettings*); | 298 GrStencilSettings*); |
308 virtual GrClipMaskManager* clipMaskManager() = 0; | 299 virtual GrClipMaskManager* clipMaskManager() = 0; |
309 virtual bool setupClip(GrPipelineBuilder*, | 300 virtual bool setupClip(GrPipelineBuilder*, |
310 GrPipelineBuilder::AutoRestoreFragmentProcessors*, | 301 GrPipelineBuilder::AutoRestoreFragmentProcessors*, |
311 GrPipelineBuilder::AutoRestoreStencil*, | 302 GrPipelineBuilder::AutoRestoreStencil*, |
312 GrScissorState*, | 303 GrScissorState*, |
313 const SkRect* devBounds) = 0; | 304 const SkRect* devBounds) = 0; |
314 | 305 |
315 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar
get. | 306 GrGpu* fGpu; |
316 GrContext* fContext; | 307 const GrCaps* fCaps; |
317 SkAutoTUnref<const GrCaps> fCaps; | 308 GrResourceProvider* fResourceProvider; |
318 // To keep track that we always have at least as many debug marker adds as r
emoves | 309 // To keep track that we always have at least as many debug marker adds as r
emoves |
319 int fGpuTraceMar
kerCount; | 310 int fGpuTraceMarkerCount; |
320 GrTraceMarkerSet fActiveTrace
Markers; | 311 GrTraceMarkerSet fActiveTraceMarkers; |
321 GrTraceMarkerSet fStoredTrace
Markers; | 312 GrTraceMarkerSet fStoredTraceMarkers; |
322 bool fFlushing; | 313 bool fFlushing; |
323 | 314 |
324 typedef SkRefCnt INHERITED; | 315 typedef SkRefCnt INHERITED; |
325 }; | 316 }; |
326 | 317 |
327 /* | 318 /* |
328 * This class is JUST for clip mask manager. Everyone else should just use draw
target above. | 319 * This class is JUST for clip mask manager. Everyone else should just use draw
target above. |
329 */ | 320 */ |
330 class GrClipTarget : public GrDrawTarget { | 321 class GrClipTarget : public GrDrawTarget { |
331 public: | 322 public: |
332 GrClipTarget(GrContext*); | 323 GrClipTarget(GrContext*); |
333 | 324 |
334 /* Clip mask manager needs access to the context. | 325 /* Clip mask manager needs access to the context. |
335 * TODO we only need a very small subset of context in the CMM. | 326 * TODO we only need a very small subset of context in the CMM. |
336 */ | 327 */ |
337 GrContext* getContext() { return INHERITED::getContext(); } | 328 GrContext* getContext() { return fContext; } |
338 const GrContext* getContext() const { return INHERITED::getContext(); } | 329 const GrContext* getContext() const { return fContext; } |
339 | 330 |
340 /** | 331 /** |
341 * Clip Mask Manager(and no one else) needs to clear private stencil bits. | 332 * Clip Mask Manager(and no one else) needs to clear private stencil bits. |
342 * ClipTarget subclass sets clip bit in the stencil buffer. The subclass | 333 * ClipTarget subclass sets clip bit in the stencil buffer. The subclass |
343 * is free to clear the remaining bits to zero if masked clears are more | 334 * is free to clear the remaining bits to zero if masked clears are more |
344 * expensive than clearing all bits. | 335 * expensive than clearing all bits. |
345 */ | 336 */ |
346 virtual void clearStencilClip(const SkIRect& rect, bool insideClip, GrRender
Target* = NULL) = 0; | 337 virtual void clearStencilClip(const SkIRect& rect, bool insideClip, GrRender
Target* = NULL) = 0; |
347 | 338 |
348 /** | 339 /** |
349 * Release any resources that are cached but not currently in use. This | 340 * Release any resources that are cached but not currently in use. This |
350 * is intended to give an application some recourse when resources are low. | 341 * is intended to give an application some recourse when resources are low. |
351 */ | 342 */ |
352 void purgeResources() override; | 343 void purgeResources() override; |
353 | 344 |
354 protected: | 345 protected: |
355 SkAutoTDelete<GrClipMaskManager> fClipMaskManager; | 346 SkAutoTDelete<GrClipMaskManager> fClipMaskManager; |
| 347 GrContext* fContext; |
356 | 348 |
357 private: | 349 private: |
358 GrClipMaskManager* clipMaskManager() override { return fClipMaskManager; } | 350 GrClipMaskManager* clipMaskManager() override { return fClipMaskManager; } |
359 | 351 |
360 virtual bool setupClip(GrPipelineBuilder*, | 352 virtual bool setupClip(GrPipelineBuilder*, |
361 GrPipelineBuilder::AutoRestoreFragmentProcessors*, | 353 GrPipelineBuilder::AutoRestoreFragmentProcessors*, |
362 GrPipelineBuilder::AutoRestoreStencil*, | 354 GrPipelineBuilder::AutoRestoreStencil*, |
363 GrScissorState* scissorState, | 355 GrScissorState* scissorState, |
364 const SkRect* devBounds) override; | 356 const SkRect* devBounds) override; |
365 | 357 |
366 typedef GrDrawTarget INHERITED; | 358 typedef GrDrawTarget INHERITED; |
367 }; | 359 }; |
368 | 360 |
369 #endif | 361 #endif |
OLD | NEW |