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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 * to index 0 | 226 * to index 0 |
227 * @param startIndex first index to read from index src. | 227 * @param startIndex first index to read from index src. |
228 * @param vertexCount one greater than the max index. | 228 * @param vertexCount one greater than the max index. |
229 * @param indexCount the number of index elements to read. The index count | 229 * @param indexCount the number of index elements to read. The index count |
230 * is effectively trimmed to the last completely | 230 * is effectively trimmed to the last completely |
231 * specified primitive. | 231 * specified primitive. |
232 * @param devBounds optional bounds hint. This is a promise from the call
er, | 232 * @param devBounds optional bounds hint. This is a promise from the call
er, |
233 * not a request for clipping. | 233 * not a request for clipping. |
234 */ | 234 */ |
235 void drawIndexed(GrDrawState*, | 235 void drawIndexed(GrDrawState*, |
| 236 const GrGeometryProcessor*, |
236 GrPrimitiveType type, | 237 GrPrimitiveType type, |
237 int startVertex, | 238 int startVertex, |
238 int startIndex, | 239 int startIndex, |
239 int vertexCount, | 240 int vertexCount, |
240 int indexCount, | 241 int indexCount, |
241 const SkRect* devBounds = NULL); | 242 const SkRect* devBounds = NULL); |
242 | 243 |
243 /** | 244 /** |
244 * Draws non-indexed geometry using the current state and current vertex | 245 * Draws non-indexed geometry using the current state and current vertex |
245 * sources. | 246 * sources. |
246 * | 247 * |
247 * @param type The type of primitives to draw. | 248 * @param type The type of primitives to draw. |
248 * @param startVertex the vertex in the vertex array/buffer corresponding | 249 * @param startVertex the vertex in the vertex array/buffer corresponding |
249 * to index 0 | 250 * to index 0 |
250 * @param vertexCount one greater than the max index. | 251 * @param vertexCount one greater than the max index. |
251 * @param devBounds optional bounds hint. This is a promise from the call
er, | 252 * @param devBounds optional bounds hint. This is a promise from the call
er, |
252 * not a request for clipping. | 253 * not a request for clipping. |
253 */ | 254 */ |
254 void drawNonIndexed(GrDrawState*, | 255 void drawNonIndexed(GrDrawState*, |
| 256 const GrGeometryProcessor*, |
255 GrPrimitiveType type, | 257 GrPrimitiveType type, |
256 int startVertex, | 258 int startVertex, |
257 int vertexCount, | 259 int vertexCount, |
258 const SkRect* devBounds = NULL); | 260 const SkRect* devBounds = NULL); |
259 | 261 |
260 /** | 262 /** |
261 * Draws path into the stencil buffer. The fill must be either even/odd or | 263 * Draws path into the stencil buffer. The fill must be either even/odd or |
262 * winding (not inverse or hairline). It will respect the HW antialias flag | 264 * winding (not inverse or hairline). It will respect the HW antialias flag |
263 * on the draw state (if possible in the 3D API). Note, we will never have
an inverse fill | 265 * on the draw state (if possible in the 3D API). Note, we will never have
an inverse fill |
264 * with stencil path | 266 * with stencil path |
265 */ | 267 */ |
266 void stencilPath(GrDrawState*, const GrPath*, GrPathRendering::FillType fill
); | 268 void stencilPath(GrDrawState*, const GrPathProcessor*, const GrPath*,GrPathR
endering::FillType); |
267 | 269 |
268 /** | 270 /** |
269 * Draws a path. Fill must not be a hairline. It will respect the HW | 271 * Draws a path. Fill must not be a hairline. It will respect the HW |
270 * antialias flag on the draw state (if possible in the 3D API). | 272 * antialias flag on the draw state (if possible in the 3D API). |
271 */ | 273 */ |
272 void drawPath(GrDrawState*, GrColor, const GrPath*, GrPathRendering::FillTyp
e fill); | 274 void drawPath(GrDrawState*, const GrPathProcessor*, const GrPath*, GrPathRen
dering::FillType); |
273 | 275 |
274 /** | 276 /** |
275 * Draws the aggregate path from combining multiple. Note that this will not | 277 * Draws the aggregate path from combining multiple. Note that this will not |
276 * always be equivalent to back-to-back calls to drawPath(). It will respect | 278 * always be equivalent to back-to-back calls to drawPath(). It will respect |
277 * the HW antialias flag on the draw state (if possible in the 3D API). | 279 * the HW antialias flag on the draw state (if possible in the 3D API). |
278 * | 280 * |
279 * @param pathRange Source paths to draw from | 281 * @param pathRange Source paths to draw from |
280 * @param indices Array of path indices to draw | 282 * @param indices Array of path indices to draw |
281 * @param indexType Data type of the array elements in indexBuffer | 283 * @param indexType Data type of the array elements in indexBuffer |
282 * @param transformValues Array of transforms for the individual paths | 284 * @param transformValues Array of transforms for the individual paths |
283 * @param transformType Type of transforms in transformBuffer | 285 * @param transformType Type of transforms in transformBuffer |
284 * @param count Number of paths to draw | 286 * @param count Number of paths to draw |
285 * @param fill Fill type for drawing all the paths | 287 * @param fill Fill type for drawing all the paths |
286 */ | 288 */ |
287 void drawPaths(GrDrawState*, | 289 void drawPaths(GrDrawState*, |
288 GrColor, | 290 const GrPathProcessor*, |
289 const GrPathRange* pathRange, | 291 const GrPathRange* pathRange, |
290 const void* indices, | 292 const void* indices, |
291 PathIndexType indexType, | 293 PathIndexType indexType, |
292 const float transformValues[], | 294 const float transformValues[], |
293 PathTransformType transformType, | 295 PathTransformType transformType, |
294 int count, | 296 int count, |
295 GrPathRendering::FillType fill); | 297 GrPathRendering::FillType fill); |
296 | 298 |
297 /** | 299 /** |
298 * Helper function for drawing rects. It performs a geometry src push and po
p | 300 * Helper function for drawing rects. It performs a geometry src push and po
p |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 * indicesPerInstance indices drawn as the primitive | 352 * indicesPerInstance indices drawn as the primitive |
351 * type specified by type. | 353 * type specified by type. |
352 * @param verticesPerInstance The number of vertices in each instance (V | 354 * @param verticesPerInstance The number of vertices in each instance (V |
353 * in the above description). | 355 * in the above description). |
354 * @param indicesPerInstance The number of indices in each instance (I | 356 * @param indicesPerInstance The number of indices in each instance (I |
355 * in the above description). | 357 * in the above description). |
356 * @param devBounds optional bounds hint. This is a promise from the call
er, | 358 * @param devBounds optional bounds hint. This is a promise from the call
er, |
357 * not a request for clipping. | 359 * not a request for clipping. |
358 */ | 360 */ |
359 void drawIndexedInstances(GrDrawState*, | 361 void drawIndexedInstances(GrDrawState*, |
| 362 const GrGeometryProcessor*, |
360 GrPrimitiveType type, | 363 GrPrimitiveType type, |
361 int instanceCount, | 364 int instanceCount, |
362 int verticesPerInstance, | 365 int verticesPerInstance, |
363 int indicesPerInstance, | 366 int indicesPerInstance, |
364 const SkRect* devBounds = NULL); | 367 const SkRect* devBounds = NULL); |
365 | 368 |
366 /** | 369 /** |
367 * Clear the passed in render target. Ignores the draw state and clip. Clear
s the whole thing if | 370 * Clear the passed in render target. Ignores the draw state and clip. Clear
s the whole thing if |
368 * rect is NULL, otherwise just the rect. If canIgnoreRect is set then the e
ntire render target | 371 * rect is NULL, otherwise just the rect. If canIgnoreRect is set then the e
ntire render target |
369 * can be optionally cleared. | 372 * can be optionally cleared. |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 | 652 |
650 // Subclass must initialize this in its constructor. | 653 // Subclass must initialize this in its constructor. |
651 SkAutoTUnref<const GrDrawTargetCaps> fCaps; | 654 SkAutoTUnref<const GrDrawTargetCaps> fCaps; |
652 | 655 |
653 const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers
; } | 656 const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers
; } |
654 | 657 |
655 // Makes a copy of the dst if it is necessary for the draw. Returns false if
a copy is required | 658 // Makes a copy of the dst if it is necessary for the draw. Returns false if
a copy is required |
656 // but couldn't be made. Otherwise, returns true. This method needs to be p
rotected because it | 659 // but couldn't be made. Otherwise, returns true. This method needs to be p
rotected because it |
657 // needs to be accessed by GLPrograms to setup a correct drawstate | 660 // needs to be accessed by GLPrograms to setup a correct drawstate |
658 bool setupDstReadIfNecessary(GrDrawState*, | 661 bool setupDstReadIfNecessary(GrDrawState*, |
659 GrColor, | 662 const GrPrimitiveProcessor*, |
660 uint8_t, | |
661 GrDeviceCoordTexture* dstCopy, | 663 GrDeviceCoordTexture* dstCopy, |
662 const SkRect* drawBounds); | 664 const SkRect* drawBounds); |
663 | 665 |
664 private: | 666 private: |
665 /** | 667 /** |
666 * This will be called before allocating a texture as a dst for copySurface.
This function | 668 * This will be called before allocating a texture as a dst for copySurface.
This function |
667 * populates the dstDesc's config, flags, and origin so as to maximize effic
iency and guarantee | 669 * populates the dstDesc's config, flags, and origin so as to maximize effic
iency and guarantee |
668 * success of the copySurface call. | 670 * success of the copySurface call. |
669 */ | 671 */ |
670 void initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* dstDesc) { | 672 void initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* dstDesc) { |
(...skipping 20 matching lines...) Expand all Loading... |
691 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void**
vertices) = 0; | 693 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void**
vertices) = 0; |
692 virtual bool onReserveIndexSpace(int indexCount, void** indices) = 0; | 694 virtual bool onReserveIndexSpace(int indexCount, void** indices) = 0; |
693 // implemented by subclass to handle release of reserved geom space | 695 // implemented by subclass to handle release of reserved geom space |
694 virtual void releaseReservedVertexSpace() = 0; | 696 virtual void releaseReservedVertexSpace() = 0; |
695 virtual void releaseReservedIndexSpace() = 0; | 697 virtual void releaseReservedIndexSpace() = 0; |
696 // subclass overrides to be notified just before geo src state is pushed/pop
ped. | 698 // subclass overrides to be notified just before geo src state is pushed/pop
ped. |
697 virtual void geometrySourceWillPush() = 0; | 699 virtual void geometrySourceWillPush() = 0; |
698 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) =
0; | 700 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) =
0; |
699 // subclass called to perform drawing | 701 // subclass called to perform drawing |
700 virtual void onDraw(const GrDrawState&, | 702 virtual void onDraw(const GrDrawState&, |
| 703 const GrGeometryProcessor*, |
701 const DrawInfo&, | 704 const DrawInfo&, |
702 const GrClipMaskManager::ScissorState&, | 705 const GrClipMaskManager::ScissorState&, |
703 const GrDeviceCoordTexture* dstCopy) = 0; | 706 const GrDeviceCoordTexture* dstCopy) = 0; |
704 // TODO copy in order drawbuffer onDrawRect to here | 707 // TODO copy in order drawbuffer onDrawRect to here |
705 virtual void onDrawRect(GrDrawState*, | 708 virtual void onDrawRect(GrDrawState*, |
706 GrColor color, | 709 GrColor color, |
707 const SkRect& rect, | 710 const SkRect& rect, |
708 const SkRect* localRect, | 711 const SkRect* localRect, |
709 const SkMatrix* localMatrix) = 0; | 712 const SkMatrix* localMatrix) = 0; |
710 | 713 |
711 virtual void onStencilPath(const GrDrawState&, | 714 virtual void onStencilPath(const GrDrawState&, |
| 715 const GrPathProcessor*, |
712 const GrPath*, | 716 const GrPath*, |
713 const GrClipMaskManager::ScissorState&, | 717 const GrClipMaskManager::ScissorState&, |
714 const GrStencilSettings&) = 0; | 718 const GrStencilSettings&) = 0; |
715 virtual void onDrawPath(const GrDrawState&, | 719 virtual void onDrawPath(const GrDrawState&, |
716 GrColor, | 720 const GrPathProcessor*, |
717 const GrPath*, | 721 const GrPath*, |
718 const GrClipMaskManager::ScissorState&, | 722 const GrClipMaskManager::ScissorState&, |
719 const GrStencilSettings&, | 723 const GrStencilSettings&, |
720 const GrDeviceCoordTexture* dstCopy) = 0; | 724 const GrDeviceCoordTexture* dstCopy) = 0; |
721 virtual void onDrawPaths(const GrDrawState&, | 725 virtual void onDrawPaths(const GrDrawState&, |
722 GrColor, | 726 const GrPathProcessor*, |
723 const GrPathRange*, | 727 const GrPathRange*, |
724 const void* indices, | 728 const void* indices, |
725 PathIndexType, | 729 PathIndexType, |
726 const float transformValues[], | 730 const float transformValues[], |
727 PathTransformType, | 731 PathTransformType, |
728 int count, | 732 int count, |
729 const GrClipMaskManager::ScissorState&, | 733 const GrClipMaskManager::ScissorState&, |
730 const GrStencilSettings&, | 734 const GrStencilSettings&, |
731 const GrDeviceCoordTexture*) = 0; | 735 const GrDeviceCoordTexture*) = 0; |
732 | 736 |
(...skipping 26 matching lines...) Expand all Loading... |
759 | 763 |
760 // helpers for reserving vertex and index space. | 764 // helpers for reserving vertex and index space. |
761 bool reserveVertexSpace(size_t vertexSize, | 765 bool reserveVertexSpace(size_t vertexSize, |
762 int vertexCount, | 766 int vertexCount, |
763 void** vertices); | 767 void** vertices); |
764 bool reserveIndexSpace(int indexCount, void** indices); | 768 bool reserveIndexSpace(int indexCount, void** indices); |
765 | 769 |
766 // called by drawIndexed and drawNonIndexed. Use a negative indexCount to | 770 // called by drawIndexed and drawNonIndexed. Use a negative indexCount to |
767 // indicate non-indexed drawing. | 771 // indicate non-indexed drawing. |
768 bool checkDraw(const GrDrawState&, | 772 bool checkDraw(const GrDrawState&, |
| 773 const GrGeometryProcessor*, |
769 GrPrimitiveType type, | 774 GrPrimitiveType type, |
770 int startVertex, | 775 int startVertex, |
771 int startIndex, | 776 int startIndex, |
772 int vertexCount, | 777 int vertexCount, |
773 int indexCount) const; | 778 int indexCount) const; |
774 // called when setting a new vert/idx source to unref prev vb/ib | 779 // called when setting a new vert/idx source to unref prev vb/ib |
775 void releasePreviousVertexSource(); | 780 void releasePreviousVertexSource(); |
776 void releasePreviousIndexSource(); | 781 void releasePreviousIndexSource(); |
777 | 782 |
778 // Check to see if this set of draw commands has been sent out | 783 // Check to see if this set of draw commands has been sent out |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 virtual bool setupClip(const SkRect* devBounds, | 849 virtual bool setupClip(const SkRect* devBounds, |
845 GrDrawState::AutoRestoreEffects* are, | 850 GrDrawState::AutoRestoreEffects* are, |
846 GrDrawState::AutoRestoreStencil* ars, | 851 GrDrawState::AutoRestoreStencil* ars, |
847 GrDrawState*, | 852 GrDrawState*, |
848 GrClipMaskManager::ScissorState* scissorState) SK_OVE
RRIDE; | 853 GrClipMaskManager::ScissorState* scissorState) SK_OVE
RRIDE; |
849 | 854 |
850 typedef GrDrawTarget INHERITED; | 855 typedef GrDrawTarget INHERITED; |
851 }; | 856 }; |
852 | 857 |
853 #endif | 858 #endif |
OLD | NEW |