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