| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; } | 67 const GrCaps* caps() const { return fCaps; } |
| 68 | 68 |
| 69 void drawBatch(GrPipelineBuilder*, GrBatch*); | 69 void drawBatch(const 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(const GrPipelineBuilder&, const GrPathProcessor*, const GrP
ath*, |
| 78 GrPathRendering::FillType); | 78 GrPathRendering::FillType); |
| 79 | 79 |
| 80 /** | 80 /** |
| 81 * Draws a path. Fill must not be a hairline. It will respect the HW | 81 * Draws a path. Fill must not be a hairline. It will respect the HW |
| 82 * antialias flag on the GrPipelineBuilder (if possible in the 3D API). | 82 * antialias flag on the GrPipelineBuilder (if possible in the 3D API). |
| 83 */ | 83 */ |
| 84 void drawPath(GrPipelineBuilder*, const GrPathProcessor*, const GrPath*, | 84 void drawPath(const GrPipelineBuilder&, const GrPathProcessor*, const GrPath
*, |
| 85 GrPathRendering::FillType); | 85 GrPathRendering::FillType); |
| 86 | 86 |
| 87 /** | 87 /** |
| 88 * Draws the aggregate path from combining multiple. Note that this will not | 88 * Draws the aggregate path from combining multiple. Note that this will not |
| 89 * always be equivalent to back-to-back calls to drawPath(). It will respect | 89 * always be equivalent to back-to-back calls to drawPath(). It will respect |
| 90 * the HW antialias flag on the GrPipelineBuilder (if possible in the 3D API
). | 90 * the HW antialias flag on the GrPipelineBuilder (if possible in the 3D API
). |
| 91 * | 91 * |
| 92 * @param pathRange Source paths to draw from | 92 * @param pathRange Source paths to draw from |
| 93 * @param indices Array of path indices to draw | 93 * @param indices Array of path indices to draw |
| 94 * @param indexType Data type of the array elements in indexBuffer | 94 * @param indexType Data type of the array elements in indexBuffer |
| 95 * @param transformValues Array of transforms for the individual paths | 95 * @param transformValues Array of transforms for the individual paths |
| 96 * @param transformType Type of transforms in transformBuffer | 96 * @param transformType Type of transforms in transformBuffer |
| 97 * @param count Number of paths to draw | 97 * @param count Number of paths to draw |
| 98 * @param fill Fill type for drawing all the paths | 98 * @param fill Fill type for drawing all the paths |
| 99 */ | 99 */ |
| 100 void drawPaths(GrPipelineBuilder*, | 100 void drawPaths(const GrPipelineBuilder&, |
| 101 const GrPathProcessor*, | 101 const GrPathProcessor*, |
| 102 const GrPathRange* pathRange, | 102 const GrPathRange* pathRange, |
| 103 const void* indices, | 103 const void* indices, |
| 104 PathIndexType indexType, | 104 PathIndexType indexType, |
| 105 const float transformValues[], | 105 const float transformValues[], |
| 106 PathTransformType transformType, | 106 PathTransformType transformType, |
| 107 int count, | 107 int count, |
| 108 GrPathRendering::FillType fill); | 108 GrPathRendering::FillType fill); |
| 109 | 109 |
| 110 /** | 110 /** |
| 111 * Helper function for drawing rects. | 111 * Helper function for drawing rects. |
| 112 * | 112 * |
| 113 * @param rect the rect to draw | 113 * @param rect the rect to draw |
| 114 * @param localRect optional rect that specifies local coords to map onto | 114 * @param localRect optional rect that specifies local coords to map onto |
| 115 * rect. If NULL then rect serves as the local coords. | 115 * rect. If NULL then rect serves as the local coords. |
| 116 * @param localMatrix Optional local matrix. The local coordinates are speci
fied by localRect, | 116 * @param localMatrix Optional local matrix. The local coordinates are speci
fied by localRect, |
| 117 * or if it is NULL by rect. This matrix applies to the c
oordinate implied by | 117 * or if it is NULL by rect. This matrix applies to the c
oordinate implied by |
| 118 * that rectangle before it is input to GrCoordTransforms
that read local | 118 * that rectangle before it is input to GrCoordTransforms
that read local |
| 119 * coordinates | 119 * coordinates |
| 120 */ | 120 */ |
| 121 void drawBWRect(GrPipelineBuilder* pipelineBuilder, | 121 void drawBWRect(const GrPipelineBuilder& pipelineBuilder, |
| 122 GrColor color, | 122 GrColor color, |
| 123 const SkMatrix& viewMatrix, | 123 const SkMatrix& viewMatrix, |
| 124 const SkRect& rect, | 124 const SkRect& rect, |
| 125 const SkRect* localRect, | 125 const SkRect* localRect, |
| 126 const SkMatrix* localMatrix); | 126 const SkMatrix* localMatrix); |
| 127 | 127 |
| 128 /** | 128 /** |
| 129 * Helper for drawRect when the caller doesn't need separate local rects or
matrices. | 129 * Helper for drawRect when the caller doesn't need separate local rects or
matrices. |
| 130 */ | 130 */ |
| 131 void drawSimpleRect(GrPipelineBuilder* ds, GrColor color, const SkMatrix& vi
ewM, | 131 void drawSimpleRect(const GrPipelineBuilder& ds, GrColor color, const SkMatr
ix& viewM, |
| 132 const SkRect& rect) { | 132 const SkRect& rect) { |
| 133 this->drawBWRect(ds, color, viewM, rect, NULL, NULL); | 133 this->drawBWRect(ds, color, viewM, rect, NULL, NULL); |
| 134 } | 134 } |
| 135 void drawSimpleRect(GrPipelineBuilder* ds, GrColor color, const SkMatrix& vi
ewM, | 135 void drawSimpleRect(const GrPipelineBuilder& ds, GrColor color, const SkMatr
ix& viewM, |
| 136 const SkIRect& irect) { | 136 const SkIRect& irect) { |
| 137 SkRect rect = SkRect::Make(irect); | 137 SkRect rect = SkRect::Make(irect); |
| 138 this->drawBWRect(ds, color, viewM, rect, NULL, NULL); | 138 this->drawBWRect(ds, color, viewM, rect, NULL, NULL); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void drawAARect(GrPipelineBuilder* pipelineBuilder, | 141 void drawAARect(const GrPipelineBuilder& pipelineBuilder, |
| 142 GrColor color, | 142 GrColor color, |
| 143 const SkMatrix& viewMatrix, | 143 const SkMatrix& viewMatrix, |
| 144 const SkRect& rect, | 144 const SkRect& rect, |
| 145 const SkRect& devRect); | 145 const SkRect& devRect); |
| 146 | 146 |
| 147 /** | 147 /** |
| 148 * Clear the passed in render target. Ignores the GrPipelineBuilder and clip
. Clears the whole | 148 * Clear the passed in render target. Ignores the GrPipelineBuilder and clip
. Clears the whole |
| 149 * thing if rect is NULL, otherwise just the rect. If canIgnoreRect is set t
hen the entire | 149 * thing if rect is NULL, otherwise just the rect. If canIgnoreRect is set t
hen the entire |
| 150 * render target can be optionally cleared. | 150 * render target can be optionally cleared. |
| 151 */ | 151 */ |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 // Makes a copy of the dst if it is necessary for the draw. Returns false if
a copy is required | 214 // Makes a copy of the dst if it is necessary for the draw. Returns false if
a copy is required |
| 215 // but couldn't be made. Otherwise, returns true. This method needs to be p
rotected because it | 215 // but couldn't be made. Otherwise, returns true. This method needs to be p
rotected because it |
| 216 // needs to be accessed by GLPrograms to setup a correct drawstate | 216 // needs to be accessed by GLPrograms to setup a correct drawstate |
| 217 bool setupDstReadIfNecessary(const GrPipelineBuilder&, | 217 bool setupDstReadIfNecessary(const GrPipelineBuilder&, |
| 218 const GrProcOptInfo& colorPOI, | 218 const GrProcOptInfo& colorPOI, |
| 219 const GrProcOptInfo& coveragePOI, | 219 const GrProcOptInfo& coveragePOI, |
| 220 GrXferProcessor::DstTexture*, | 220 GrXferProcessor::DstTexture*, |
| 221 const SkRect* drawBounds); | 221 const SkRect* drawBounds); |
| 222 | 222 |
| 223 struct PipelineInfo { | 223 struct PipelineInfo { |
| 224 PipelineInfo(GrPipelineBuilder* pipelineBuilder, GrScissorState* scissor
, | 224 PipelineInfo(const GrPipelineBuilder& pipelineBuilder, GrScissorState* s
cissor, |
| 225 const GrPrimitiveProcessor* primProc, | 225 const GrPrimitiveProcessor* primProc, |
| 226 const SkRect* devBounds, GrDrawTarget* target); | 226 const SkRect* devBounds, GrDrawTarget* target); |
| 227 | 227 |
| 228 PipelineInfo(GrPipelineBuilder* pipelineBuilder, GrScissorState* scissor
, | 228 PipelineInfo(const GrPipelineBuilder& pipelineBuilder, GrScissorState* s
cissor, |
| 229 const GrBatch* batch, const SkRect* devBounds, | 229 const GrBatch* batch, const SkRect* devBounds, |
| 230 GrDrawTarget* target); | 230 GrDrawTarget* target); |
| 231 | 231 |
| 232 bool willColorBlendWithDst(const GrPrimitiveProcessor* primProc) const { | 232 bool willColorBlendWithDst(const GrPrimitiveProcessor* primProc) const { |
| 233 return fPipelineBuilder->willColorBlendWithDst(primProc); | 233 return fPipelineBuilder->willColorBlendWithDst(primProc); |
| 234 } | 234 } |
| 235 private: | 235 private: |
| 236 friend class GrDrawTarget; | 236 friend class GrDrawTarget; |
| 237 | 237 |
| 238 bool mustSkipDraw() const { return (NULL == fPipelineBuilder); } | 238 bool mustSkipDraw() const { return (NULL == fPipelineBuilder); } |
| 239 | 239 |
| 240 GrPipelineBuilder* fPipelineBuilder; | 240 const GrPipelineBuilder* fPipelineBuilder; |
| 241 GrScissorState* fScissor; | 241 GrScissorState* fScissor; |
| 242 GrProcOptInfo fColorPOI; | 242 GrProcOptInfo fColorPOI; |
| 243 GrProcOptInfo fCoveragePOI; | 243 GrProcOptInfo fCoveragePOI; |
| 244 GrXferProcessor::DstTexture fDstTexture; | 244 GrXferProcessor::DstTexture fDstTexture; |
| 245 }; | 245 }; |
| 246 | 246 |
| 247 void setupPipeline(const PipelineInfo& pipelineInfo, GrPipeline* pipeline); | 247 void setupPipeline(const PipelineInfo& pipelineInfo, GrPipeline* pipeline); |
| 248 | 248 |
| 249 private: | 249 private: |
| 250 virtual void onReset() = 0; | 250 virtual void onReset() = 0; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 280 GrSurface* src, | 280 GrSurface* src, |
| 281 const SkIRect& srcRect, | 281 const SkIRect& srcRect, |
| 282 const SkIPoint& dstPoint) = 0; | 282 const SkIPoint& dstPoint) = 0; |
| 283 | 283 |
| 284 // Check to see if this set of draw commands has been sent out | 284 // Check to see if this set of draw commands has been sent out |
| 285 virtual bool isIssued(uint32_t drawID) { return true; } | 285 virtual bool isIssued(uint32_t drawID) { return true; } |
| 286 void getPathStencilSettingsForFilltype(GrPathRendering::FillType, | 286 void getPathStencilSettingsForFilltype(GrPathRendering::FillType, |
| 287 const GrStencilAttachment*, | 287 const GrStencilAttachment*, |
| 288 GrStencilSettings*); | 288 GrStencilSettings*); |
| 289 virtual GrClipMaskManager* clipMaskManager() = 0; | 289 virtual GrClipMaskManager* clipMaskManager() = 0; |
| 290 virtual bool setupClip(GrPipelineBuilder*, | 290 virtual bool setupClip(const GrPipelineBuilder&, |
| 291 GrPipelineBuilder::AutoRestoreFragmentProcessors*, | 291 GrPipelineBuilder::AutoRestoreFragmentProcessors*, |
| 292 GrPipelineBuilder::AutoRestoreStencil*, | 292 GrPipelineBuilder::AutoRestoreStencil*, |
| 293 GrPipelineBuilder::AutoRestoreProcessorDataManager*, | 293 GrPipelineBuilder::AutoRestoreProcessorDataManager*, |
| 294 GrScissorState*, | 294 GrScissorState*, |
| 295 const SkRect* devBounds) = 0; | 295 const SkRect* devBounds) = 0; |
| 296 | 296 |
| 297 GrGpu* fGpu; | 297 GrGpu* fGpu; |
| 298 const GrCaps* fCaps; | 298 const GrCaps* fCaps; |
| 299 GrResourceProvider* fResourceProvider; | 299 GrResourceProvider* fResourceProvider; |
| 300 // To keep track that we always have at least as many debug marker adds as r
emoves | 300 // To keep track that we always have at least as many debug marker adds as r
emoves |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 */ | 333 */ |
| 334 void purgeResources() override; | 334 void purgeResources() override; |
| 335 | 335 |
| 336 protected: | 336 protected: |
| 337 SkAutoTDelete<GrClipMaskManager> fClipMaskManager; | 337 SkAutoTDelete<GrClipMaskManager> fClipMaskManager; |
| 338 GrContext* fContext; | 338 GrContext* fContext; |
| 339 | 339 |
| 340 private: | 340 private: |
| 341 GrClipMaskManager* clipMaskManager() override { return fClipMaskManager; } | 341 GrClipMaskManager* clipMaskManager() override { return fClipMaskManager; } |
| 342 | 342 |
| 343 bool setupClip(GrPipelineBuilder*, | 343 bool setupClip(const GrPipelineBuilder&, |
| 344 GrPipelineBuilder::AutoRestoreFragmentProcessors*, | 344 GrPipelineBuilder::AutoRestoreFragmentProcessors*, |
| 345 GrPipelineBuilder::AutoRestoreStencil*, | 345 GrPipelineBuilder::AutoRestoreStencil*, |
| 346 GrPipelineBuilder::AutoRestoreProcessorDataManager*, | 346 GrPipelineBuilder::AutoRestoreProcessorDataManager*, |
| 347 GrScissorState* scissorState, | 347 GrScissorState* scissorState, |
| 348 const SkRect* devBounds) override; | 348 const SkRect* devBounds) override; |
| 349 | 349 |
| 350 typedef GrDrawTarget INHERITED; | 350 typedef GrDrawTarget INHERITED; |
| 351 }; | 351 }; |
| 352 | 352 |
| 353 #endif | 353 #endif |
| OLD | NEW |