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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 * @param rect the rect to draw | 303 * @param rect the rect to draw |
304 * @param localRect optional rect that specifies local coords to map onto | 304 * @param localRect optional rect that specifies local coords to map onto |
305 * rect. If NULL then rect serves as the local coords. | 305 * rect. If NULL then rect serves as the local coords. |
306 * @param localMatrix Optional local matrix. The local coordinates are speci
fied by localRect, | 306 * @param localMatrix Optional local matrix. The local coordinates are speci
fied by localRect, |
307 * or if it is NULL by rect. This matrix applies to the c
oordinate implied by | 307 * or if it is NULL by rect. This matrix applies to the c
oordinate implied by |
308 * that rectangle before it is input to GrCoordTransforms
that read local | 308 * that rectangle before it is input to GrCoordTransforms
that read local |
309 * coordinates | 309 * coordinates |
310 */ | 310 */ |
311 void drawRect(GrDrawState* ds, | 311 void drawRect(GrDrawState* ds, |
312 GrColor color, | 312 GrColor color, |
| 313 const SkMatrix& viewMatrix, |
313 const SkRect& rect, | 314 const SkRect& rect, |
314 const SkRect* localRect, | 315 const SkRect* localRect, |
315 const SkMatrix* localMatrix) { | 316 const SkMatrix* localMatrix) { |
316 AutoGeometryPush agp(this); | 317 AutoGeometryPush agp(this); |
317 this->onDrawRect(ds, color, rect, localRect, localMatrix); | 318 this->onDrawRect(ds, color, viewMatrix, rect, localRect, localMatrix); |
318 } | 319 } |
319 | 320 |
320 /** | 321 /** |
321 * Helper for drawRect when the caller doesn't need separate local rects or
matrices. | 322 * Helper for drawRect when the caller doesn't need separate local rects or
matrices. |
322 */ | 323 */ |
323 void drawSimpleRect(GrDrawState* ds, GrColor color, const SkRect& rect) { | 324 void drawSimpleRect(GrDrawState* ds, GrColor color, const SkMatrix& viewM, c
onst SkRect& rect) { |
324 this->drawRect(ds, color, rect, NULL, NULL); | 325 this->drawRect(ds, color, viewM, rect, NULL, NULL); |
325 } | 326 } |
326 void drawSimpleRect(GrDrawState* ds, GrColor color, const SkIRect& irect) { | 327 void drawSimpleRect(GrDrawState* ds, GrColor color, const SkMatrix& viewM, |
| 328 const SkIRect& irect) { |
327 SkRect rect = SkRect::Make(irect); | 329 SkRect rect = SkRect::Make(irect); |
328 this->drawRect(ds, color, rect, NULL, NULL); | 330 this->drawRect(ds, color, viewM, rect, NULL, NULL); |
329 } | 331 } |
330 | 332 |
331 /** | 333 /** |
332 * This call is used to draw multiple instances of some geometry with a | 334 * This call is used to draw multiple instances of some geometry with a |
333 * given number of vertices (V) and indices (I) per-instance. The indices in | 335 * given number of vertices (V) and indices (I) per-instance. The indices in |
334 * the index source must have the form i[k+I] == i[k] + V. Also, all indices | 336 * the index source must have the form i[k+I] == i[k] + V. Also, all indices |
335 * i[kI] ... i[(k+1)I-1] must be elements of the range kV ... (k+1)V-1. As a | 337 * i[kI] ... i[(k+1)I-1] must be elements of the range kV ... (k+1)V-1. As a |
336 * concrete example, the following index buffer for drawing a series of | 338 * concrete example, the following index buffer for drawing a series of |
337 * quads each as two triangles each satisfies these conditions with V=4 and | 339 * quads each as two triangles each satisfies these conditions with V=4 and |
338 * I=6: | 340 * I=6: |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) =
0; | 702 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) =
0; |
701 // subclass called to perform drawing | 703 // subclass called to perform drawing |
702 virtual void onDraw(const GrDrawState&, | 704 virtual void onDraw(const GrDrawState&, |
703 const GrGeometryProcessor*, | 705 const GrGeometryProcessor*, |
704 const DrawInfo&, | 706 const DrawInfo&, |
705 const GrScissorState&, | 707 const GrScissorState&, |
706 const GrDeviceCoordTexture* dstCopy) = 0; | 708 const GrDeviceCoordTexture* dstCopy) = 0; |
707 // TODO copy in order drawbuffer onDrawRect to here | 709 // TODO copy in order drawbuffer onDrawRect to here |
708 virtual void onDrawRect(GrDrawState*, | 710 virtual void onDrawRect(GrDrawState*, |
709 GrColor color, | 711 GrColor color, |
| 712 const SkMatrix& viewMatrix, |
710 const SkRect& rect, | 713 const SkRect& rect, |
711 const SkRect* localRect, | 714 const SkRect* localRect, |
712 const SkMatrix* localMatrix) = 0; | 715 const SkMatrix* localMatrix) = 0; |
713 | 716 |
714 virtual void onStencilPath(const GrDrawState&, | 717 virtual void onStencilPath(const GrDrawState&, |
715 const GrPathProcessor*, | 718 const GrPathProcessor*, |
716 const GrPath*, | 719 const GrPath*, |
717 const GrScissorState&, | 720 const GrScissorState&, |
718 const GrStencilSettings&) = 0; | 721 const GrStencilSettings&) = 0; |
719 virtual void onDrawPath(const GrDrawState&, | 722 virtual void onDrawPath(const GrDrawState&, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 // called when setting a new vert/idx source to unref prev vb/ib | 782 // called when setting a new vert/idx source to unref prev vb/ib |
780 void releasePreviousVertexSource(); | 783 void releasePreviousVertexSource(); |
781 void releasePreviousIndexSource(); | 784 void releasePreviousIndexSource(); |
782 | 785 |
783 // Check to see if this set of draw commands has been sent out | 786 // Check to see if this set of draw commands has been sent out |
784 virtual bool isIssued(uint32_t drawID) { return true; } | 787 virtual bool isIssued(uint32_t drawID) { return true; } |
785 void getPathStencilSettingsForFilltype(GrPathRendering::FillType, | 788 void getPathStencilSettingsForFilltype(GrPathRendering::FillType, |
786 const GrStencilBuffer*, | 789 const GrStencilBuffer*, |
787 GrStencilSettings*); | 790 GrStencilSettings*); |
788 virtual GrClipMaskManager* clipMaskManager() = 0; | 791 virtual GrClipMaskManager* clipMaskManager() = 0; |
789 virtual bool setupClip(const SkRect* devBounds, | 792 virtual bool setupClip(GrDrawState*, |
790 GrDrawState::AutoRestoreEffects* are, | 793 GrDrawState::AutoRestoreEffects* are, |
791 GrDrawState::AutoRestoreStencil* ars, | 794 GrDrawState::AutoRestoreStencil* ars, |
792 GrDrawState*, | 795 GrScissorState* scissorState, |
793 GrScissorState* scissorState) = 0; | 796 const SkRect* devBounds) = 0; |
794 | 797 |
795 enum { | 798 enum { |
796 kPreallocGeoSrcStateStackCnt = 4, | 799 kPreallocGeoSrcStateStackCnt = 4, |
797 }; | 800 }; |
798 SkSTArray<kPreallocGeoSrcStateStackCnt, GeometrySrcState, true> fGeoSrcState
Stack; | 801 SkSTArray<kPreallocGeoSrcStateStackCnt, GeometrySrcState, true> fGeoSrcState
Stack; |
799 const GrClipData* fClip; | 802 const GrClipData* fClip; |
800 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar
get. | 803 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar
get. |
801 GrContext* fContext; | 804 GrContext* fContext; |
802 // To keep track that we always have at least as many debug marker adds as r
emoves | 805 // To keep track that we always have at least as many debug marker adds as r
emoves |
803 int fGpuTraceMar
kerCount; | 806 int fGpuTraceMar
kerCount; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 // get rid of them all. | 842 // get rid of them all. |
840 fClipMaskManager.purgeResources(); | 843 fClipMaskManager.purgeResources(); |
841 }; | 844 }; |
842 | 845 |
843 protected: | 846 protected: |
844 GrClipMaskManager fClipMaskManager; | 847 GrClipMaskManager fClipMaskManager; |
845 | 848 |
846 private: | 849 private: |
847 GrClipMaskManager* clipMaskManager() SK_OVERRIDE { return &fClipMaskManager;
} | 850 GrClipMaskManager* clipMaskManager() SK_OVERRIDE { return &fClipMaskManager;
} |
848 | 851 |
849 virtual bool setupClip(const SkRect* devBounds, | 852 virtual bool setupClip(GrDrawState*, |
850 GrDrawState::AutoRestoreEffects* are, | 853 GrDrawState::AutoRestoreEffects* are, |
851 GrDrawState::AutoRestoreStencil* ars, | 854 GrDrawState::AutoRestoreStencil* ars, |
852 GrDrawState*, | 855 GrScissorState* scissorState, |
853 GrScissorState* scissorState) SK_OVERRIDE; | 856 const SkRect* devBounds) SK_OVERRIDE; |
854 | 857 |
855 typedef GrDrawTarget INHERITED; | 858 typedef GrDrawTarget INHERITED; |
856 }; | 859 }; |
857 | 860 |
858 #endif | 861 #endif |
OLD | NEW |