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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 * 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 |
263 * 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 |
264 * with stencil path | 264 * with stencil path |
265 */ | 265 */ |
266 void stencilPath(GrDrawState*, const GrPath*, GrPathRendering::FillType fill
); | 266 void stencilPath(GrDrawState*, const GrPath*, GrPathRendering::FillType fill
); |
267 | 267 |
268 /** | 268 /** |
269 * 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 |
270 * 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). |
271 */ | 271 */ |
272 void drawPath(GrDrawState*, const GrPath*, GrPathRendering::FillType fill); | 272 void drawPath(GrDrawState*, GrColor, const GrPath*, GrPathRendering::FillTyp
e fill); |
273 | 273 |
274 /** | 274 /** |
275 * 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 |
276 * 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 |
277 * 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). |
278 * | 278 * |
279 * @param pathRange Source paths to draw from | 279 * @param pathRange Source paths to draw from |
280 * @param indices Array of path indices to draw | 280 * @param indices Array of path indices to draw |
281 * @param indexType Data type of the array elements in indexBuffer | 281 * @param indexType Data type of the array elements in indexBuffer |
282 * @param transformValues Array of transforms for the individual paths | 282 * @param transformValues Array of transforms for the individual paths |
283 * @param transformType Type of transforms in transformBuffer | 283 * @param transformType Type of transforms in transformBuffer |
284 * @param count Number of paths to draw | 284 * @param count Number of paths to draw |
285 * @param fill Fill type for drawing all the paths | 285 * @param fill Fill type for drawing all the paths |
286 */ | 286 */ |
287 void drawPaths(GrDrawState*, const GrPathRange* pathRange, | 287 void drawPaths(GrDrawState*, |
| 288 GrColor, |
| 289 const GrPathRange* pathRange, |
288 const void* indices, | 290 const void* indices, |
289 PathIndexType indexType, | 291 PathIndexType indexType, |
290 const float transformValues[], | 292 const float transformValues[], |
291 PathTransformType transformType, | 293 PathTransformType transformType, |
292 int count, | 294 int count, |
293 GrPathRendering::FillType fill); | 295 GrPathRendering::FillType fill); |
294 | 296 |
295 /** | 297 /** |
296 * 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 |
297 * and thus will finalize any reserved geometry. | 299 * and thus will finalize any reserved geometry. |
298 * | 300 * |
299 * @param rect the rect to draw | 301 * @param rect the rect to draw |
300 * @param localRect optional rect that specifies local coords to map onto | 302 * @param localRect optional rect that specifies local coords to map onto |
301 * rect. If NULL then rect serves as the local coords. | 303 * rect. If NULL then rect serves as the local coords. |
302 * @param localMatrix optional matrix applied to localRect. If | 304 * @param localMatrix optional matrix applied to localRect. If |
303 * srcRect is non-NULL and srcMatrix is non-NULL | 305 * srcRect is non-NULL and srcMatrix is non-NULL |
304 * then srcRect will be transformed by srcMatrix. | 306 * then srcRect will be transformed by srcMatrix. |
305 * srcMatrix can be NULL when no srcMatrix is desired. | 307 * srcMatrix can be NULL when no srcMatrix is desired. |
306 */ | 308 */ |
307 void drawRect(GrDrawState* ds, | 309 void drawRect(GrDrawState* ds, |
| 310 GrColor color, |
308 const SkRect& rect, | 311 const SkRect& rect, |
309 const SkRect* localRect, | 312 const SkRect* localRect, |
310 const SkMatrix* localMatrix) { | 313 const SkMatrix* localMatrix) { |
311 AutoGeometryPush agp(this); | 314 AutoGeometryPush agp(this); |
312 this->onDrawRect(ds, rect, localRect, localMatrix); | 315 this->onDrawRect(ds, color, rect, localRect, localMatrix); |
313 } | 316 } |
314 | 317 |
315 /** | 318 /** |
316 * Helper for drawRect when the caller doesn't need separate local rects or
matrices. | 319 * Helper for drawRect when the caller doesn't need separate local rects or
matrices. |
317 */ | 320 */ |
318 void drawSimpleRect(GrDrawState* ds, const SkRect& rect) { | 321 void drawSimpleRect(GrDrawState* ds, GrColor color, const SkRect& rect) { |
319 this->drawRect(ds, rect, NULL, NULL); | 322 this->drawRect(ds, color, rect, NULL, NULL); |
320 } | 323 } |
321 void drawSimpleRect(GrDrawState* ds, const SkIRect& irect) { | 324 void drawSimpleRect(GrDrawState* ds, GrColor color, const SkIRect& irect) { |
322 SkRect rect = SkRect::Make(irect); | 325 SkRect rect = SkRect::Make(irect); |
323 this->drawRect(ds, rect, NULL, NULL); | 326 this->drawRect(ds, color, rect, NULL, NULL); |
324 } | 327 } |
325 | 328 |
326 /** | 329 /** |
327 * This call is used to draw multiple instances of some geometry with a | 330 * This call is used to draw multiple instances of some geometry with a |
328 * given number of vertices (V) and indices (I) per-instance. The indices in | 331 * given number of vertices (V) and indices (I) per-instance. The indices in |
329 * the index source must have the form i[k+I] == i[k] + V. Also, all indices | 332 * the index source must have the form i[k+I] == i[k] + V. Also, all indices |
330 * i[kI] ... i[(k+1)I-1] must be elements of the range kV ... (k+1)V-1. As a | 333 * i[kI] ... i[(k+1)I-1] must be elements of the range kV ... (k+1)V-1. As a |
331 * concrete example, the following index buffer for drawing a series of | 334 * concrete example, the following index buffer for drawing a series of |
332 * quads each as two triangles each satisfies these conditions with V=4 and | 335 * quads each as two triangles each satisfies these conditions with V=4 and |
333 * I=6: | 336 * I=6: |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 | 649 |
647 // Subclass must initialize this in its constructor. | 650 // Subclass must initialize this in its constructor. |
648 SkAutoTUnref<const GrDrawTargetCaps> fCaps; | 651 SkAutoTUnref<const GrDrawTargetCaps> fCaps; |
649 | 652 |
650 const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers
; } | 653 const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers
; } |
651 | 654 |
652 // 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 |
653 // 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 |
654 // needs to be accessed by GLPrograms to setup a correct drawstate | 657 // needs to be accessed by GLPrograms to setup a correct drawstate |
655 bool setupDstReadIfNecessary(GrDrawState*, | 658 bool setupDstReadIfNecessary(GrDrawState*, |
| 659 GrColor, |
| 660 uint8_t, |
656 GrDeviceCoordTexture* dstCopy, | 661 GrDeviceCoordTexture* dstCopy, |
657 const SkRect* drawBounds); | 662 const SkRect* drawBounds); |
658 | 663 |
659 private: | 664 private: |
660 /** | 665 /** |
661 * 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 |
662 * 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 |
663 * success of the copySurface call. | 668 * success of the copySurface call. |
664 */ | 669 */ |
665 void initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* dstDesc) { | 670 void initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* dstDesc) { |
(...skipping 25 matching lines...) Expand all Loading... |
691 // 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. |
692 virtual void geometrySourceWillPush() = 0; | 697 virtual void geometrySourceWillPush() = 0; |
693 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) =
0; | 698 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) =
0; |
694 // subclass called to perform drawing | 699 // subclass called to perform drawing |
695 virtual void onDraw(const GrDrawState&, | 700 virtual void onDraw(const GrDrawState&, |
696 const DrawInfo&, | 701 const DrawInfo&, |
697 const GrClipMaskManager::ScissorState&, | 702 const GrClipMaskManager::ScissorState&, |
698 const GrDeviceCoordTexture* dstCopy) = 0; | 703 const GrDeviceCoordTexture* dstCopy) = 0; |
699 // TODO copy in order drawbuffer onDrawRect to here | 704 // TODO copy in order drawbuffer onDrawRect to here |
700 virtual void onDrawRect(GrDrawState*, | 705 virtual void onDrawRect(GrDrawState*, |
| 706 GrColor color, |
701 const SkRect& rect, | 707 const SkRect& rect, |
702 const SkRect* localRect, | 708 const SkRect* localRect, |
703 const SkMatrix* localMatrix) = 0; | 709 const SkMatrix* localMatrix) = 0; |
704 | 710 |
705 virtual void onStencilPath(const GrDrawState&, | 711 virtual void onStencilPath(const GrDrawState&, |
706 const GrPath*, | 712 const GrPath*, |
707 const GrClipMaskManager::ScissorState&, | 713 const GrClipMaskManager::ScissorState&, |
708 const GrStencilSettings&) = 0; | 714 const GrStencilSettings&) = 0; |
709 virtual void onDrawPath(const GrDrawState&, | 715 virtual void onDrawPath(const GrDrawState&, |
| 716 GrColor, |
710 const GrPath*, | 717 const GrPath*, |
711 const GrClipMaskManager::ScissorState&, | 718 const GrClipMaskManager::ScissorState&, |
712 const GrStencilSettings&, | 719 const GrStencilSettings&, |
713 const GrDeviceCoordTexture* dstCopy) = 0; | 720 const GrDeviceCoordTexture* dstCopy) = 0; |
714 virtual void onDrawPaths(const GrDrawState&, | 721 virtual void onDrawPaths(const GrDrawState&, |
| 722 GrColor, |
715 const GrPathRange*, | 723 const GrPathRange*, |
716 const void* indices, | 724 const void* indices, |
717 PathIndexType, | 725 PathIndexType, |
718 const float transformValues[], | 726 const float transformValues[], |
719 PathTransformType, | 727 PathTransformType, |
720 int count, | 728 int count, |
721 const GrClipMaskManager::ScissorState&, | 729 const GrClipMaskManager::ScissorState&, |
722 const GrStencilSettings&, | 730 const GrStencilSettings&, |
723 const GrDeviceCoordTexture*) = 0; | 731 const GrDeviceCoordTexture*) = 0; |
724 | 732 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 virtual bool setupClip(const SkRect* devBounds, | 844 virtual bool setupClip(const SkRect* devBounds, |
837 GrDrawState::AutoRestoreEffects* are, | 845 GrDrawState::AutoRestoreEffects* are, |
838 GrDrawState::AutoRestoreStencil* ars, | 846 GrDrawState::AutoRestoreStencil* ars, |
839 GrDrawState*, | 847 GrDrawState*, |
840 GrClipMaskManager::ScissorState* scissorState) SK_OVE
RRIDE; | 848 GrClipMaskManager::ScissorState* scissorState) SK_OVE
RRIDE; |
841 | 849 |
842 typedef GrDrawTarget INHERITED; | 850 typedef GrDrawTarget INHERITED; |
843 }; | 851 }; |
844 | 852 |
845 #endif | 853 #endif |
OLD | NEW |