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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 SkFAIL("Unknown path transform type"); | 382 SkFAIL("Unknown path transform type"); |
383 return 0; | 383 return 0; |
384 } | 384 } |
385 } | 385 } |
386 | 386 |
387 /** | 387 /** |
388 * Helper function for drawing rects. It performs a geometry src push and po
p | 388 * Helper function for drawing rects. It performs a geometry src push and po
p |
389 * and thus will finalize any reserved geometry. | 389 * and thus will finalize any reserved geometry. |
390 * | 390 * |
391 * @param rect the rect to draw | 391 * @param rect the rect to draw |
392 * @param matrix optional matrix applied to rect (before viewMatrix) | |
393 * @param localRect optional rect that specifies local coords to map onto | 392 * @param localRect optional rect that specifies local coords to map onto |
394 * rect. If NULL then rect serves as the local coords. | 393 * rect. If NULL then rect serves as the local coords. |
395 * @param localMatrix optional matrix applied to localRect. If | 394 * @param localMatrix optional matrix applied to localRect. If |
396 * srcRect is non-NULL and srcMatrix is non-NULL | 395 * srcRect is non-NULL and srcMatrix is non-NULL |
397 * then srcRect will be transformed by srcMatrix. | 396 * then srcRect will be transformed by srcMatrix. |
398 * srcMatrix can be NULL when no srcMatrix is desired. | 397 * srcMatrix can be NULL when no srcMatrix is desired. |
399 */ | 398 */ |
400 void drawRect(const SkRect& rect, | 399 void drawRect(const SkRect& rect, |
401 const SkMatrix* matrix, | |
402 const SkRect* localRect, | 400 const SkRect* localRect, |
403 const SkMatrix* localMatrix) { | 401 const SkMatrix* localMatrix) { |
404 AutoGeometryPush agp(this); | 402 AutoGeometryPush agp(this); |
405 this->onDrawRect(rect, matrix, localRect, localMatrix); | 403 this->onDrawRect(rect, localRect, localMatrix); |
406 } | 404 } |
407 | 405 |
408 /** | 406 /** |
409 * Helper for drawRect when the caller doesn't need separate local rects or
matrices. | 407 * Helper for drawRect when the caller doesn't need separate local rects or
matrices. |
410 */ | 408 */ |
411 void drawSimpleRect(const SkRect& rect, const SkMatrix* matrix = NULL) { | 409 void drawSimpleRect(const SkRect& rect) { |
412 this->drawRect(rect, matrix, NULL, NULL); | 410 this->drawRect(rect, NULL, NULL); |
413 } | 411 } |
414 void drawSimpleRect(const SkIRect& irect, const SkMatrix* matrix = NULL) { | 412 void drawSimpleRect(const SkIRect& irect) { |
415 SkRect rect = SkRect::Make(irect); | 413 SkRect rect = SkRect::Make(irect); |
416 this->drawRect(rect, matrix, NULL, NULL); | 414 this->drawRect(rect, NULL, NULL); |
417 } | 415 } |
418 | 416 |
419 /** | 417 /** |
420 * This call is used to draw multiple instances of some geometry with a | 418 * This call is used to draw multiple instances of some geometry with a |
421 * given number of vertices (V) and indices (I) per-instance. The indices in | 419 * given number of vertices (V) and indices (I) per-instance. The indices in |
422 * the index source must have the form i[k+I] == i[k] + V. Also, all indices | 420 * the index source must have the form i[k+I] == i[k] + V. Also, all indices |
423 * i[kI] ... i[(k+1)I-1] must be elements of the range kV ... (k+1)V-1. As a | 421 * i[kI] ... i[(k+1)I-1] must be elements of the range kV ... (k+1)V-1. As a |
424 * concrete example, the following index buffer for drawing a series of | 422 * concrete example, the following index buffer for drawing a series of |
425 * quads each as two triangles each satisfies these conditions with V=4 and | 423 * quads each as two triangles each satisfies these conditions with V=4 and |
426 * I=6: | 424 * I=6: |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) =
0; | 920 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) =
0; |
923 // subclass called to perform drawing | 921 // subclass called to perform drawing |
924 virtual void onDraw(const DrawInfo&) = 0; | 922 virtual void onDraw(const DrawInfo&) = 0; |
925 // Implementation of drawRect. The geometry src and vertex attribs will alre
ady | 923 // Implementation of drawRect. The geometry src and vertex attribs will alre
ady |
926 // be saved before this is called and restored afterwards. A subclass may ov
erride | 924 // be saved before this is called and restored afterwards. A subclass may ov
erride |
927 // this to perform more optimal rect rendering. Its draws should be funneled
through | 925 // this to perform more optimal rect rendering. Its draws should be funneled
through |
928 // one of the public GrDrawTarget draw methods (e.g. drawNonIndexed, | 926 // one of the public GrDrawTarget draw methods (e.g. drawNonIndexed, |
929 // drawIndexedInstances, ...). The base class draws a two triangle fan using | 927 // drawIndexedInstances, ...). The base class draws a two triangle fan using |
930 // drawNonIndexed from reserved vertex space. | 928 // drawNonIndexed from reserved vertex space. |
931 virtual void onDrawRect(const SkRect& rect, | 929 virtual void onDrawRect(const SkRect& rect, |
932 const SkMatrix* matrix, | |
933 const SkRect* localRect, | 930 const SkRect* localRect, |
934 const SkMatrix* localMatrix); | 931 const SkMatrix* localMatrix); |
935 | 932 |
936 virtual void onStencilPath(const GrPath*, SkPath::FillType) = 0; | 933 virtual void onStencilPath(const GrPath*, SkPath::FillType) = 0; |
937 virtual void onDrawPath(const GrPath*, SkPath::FillType, | 934 virtual void onDrawPath(const GrPath*, SkPath::FillType, |
938 const GrDeviceCoordTexture* dstCopy) = 0; | 935 const GrDeviceCoordTexture* dstCopy) = 0; |
939 virtual void onDrawPaths(const GrPathRange*, | 936 virtual void onDrawPaths(const GrPathRange*, |
940 const uint32_t indices[], int count, | 937 const uint32_t indices[], int count, |
941 const float transforms[], PathTransformType, | 938 const float transforms[], PathTransformType, |
942 SkPath::FillType, const GrDeviceCoordTexture*) = 0; | 939 SkPath::FillType, const GrDeviceCoordTexture*) = 0; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 GrContext* fContext; | 977 GrContext* fContext; |
981 // To keep track that we always have at least as many debug marker adds as r
emoves | 978 // To keep track that we always have at least as many debug marker adds as r
emoves |
982 int fGpuTraceMar
kerCount; | 979 int fGpuTraceMar
kerCount; |
983 GrTraceMarkerSet fActiveTrace
Markers; | 980 GrTraceMarkerSet fActiveTrace
Markers; |
984 GrTraceMarkerSet fStoredTrace
Markers; | 981 GrTraceMarkerSet fStoredTrace
Markers; |
985 | 982 |
986 typedef SkRefCnt INHERITED; | 983 typedef SkRefCnt INHERITED; |
987 }; | 984 }; |
988 | 985 |
989 #endif | 986 #endif |
OLD | NEW |