Chromium Code Reviews| 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 |
| 11 #include "GrClipData.h" | 11 #include "GrClipData.h" |
| 12 #include "GrContext.h" | 12 #include "GrContext.h" |
| 13 #include "GrDrawState.h" | 13 #include "GrDrawState.h" |
| 14 #include "GrIndexBuffer.h" | 14 #include "GrIndexBuffer.h" |
| 15 #include "GrTraceMarker.h" | 15 #include "GrTraceMarker.h" |
| 16 | 16 |
| 17 #include "SkClipStack.h" | 17 #include "SkClipStack.h" |
| 18 #include "SkMatrix.h" | 18 #include "SkMatrix.h" |
| 19 #include "SkPath.h" | 19 #include "SkPath.h" |
| 20 #include "SkStrokeRec.h" | 20 #include "SkStrokeRec.h" |
| 21 #include "SkTArray.h" | 21 #include "SkTArray.h" |
| 22 #include "SkTLazy.h" | 22 #include "SkTLazy.h" |
| 23 #include "SkTypes.h" | 23 #include "SkTypes.h" |
| 24 #include "SkXfermode.h" | 24 #include "SkXfermode.h" |
| 25 | 25 |
| 26 class GrClipData; | 26 class GrClipData; |
| 27 class GrDrawTargetCaps; | 27 class GrDrawTargetCaps; |
| 28 class GrPath; | 28 class GrPath; |
| 29 class GrPathRange; | |
| 29 class GrVertexBuffer; | 30 class GrVertexBuffer; |
| 30 | 31 |
| 31 class GrDrawTarget : public SkRefCnt { | 32 class GrDrawTarget : public SkRefCnt { |
| 32 protected: | 33 protected: |
| 33 class DrawInfo; | 34 class DrawInfo; |
| 34 | 35 |
| 35 public: | 36 public: |
| 36 SK_DECLARE_INST_COUNT(GrDrawTarget) | 37 SK_DECLARE_INST_COUNT(GrDrawTarget) |
| 37 | 38 |
| 38 /////////////////////////////////////////////////////////////////////////// | 39 /////////////////////////////////////////////////////////////////////////// |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 /** | 343 /** |
| 343 * Draws a path. Fill must not be a hairline. It will respect the HW | 344 * Draws a path. Fill must not be a hairline. It will respect the HW |
| 344 * antialias flag on the draw state (if possible in the 3D API). | 345 * antialias flag on the draw state (if possible in the 3D API). |
| 345 */ | 346 */ |
| 346 void drawPath(const GrPath*, SkPath::FillType fill); | 347 void drawPath(const GrPath*, SkPath::FillType fill); |
| 347 | 348 |
| 348 /** | 349 /** |
| 349 * Draws many paths. It will respect the HW | 350 * Draws many paths. It will respect the HW |
| 350 * antialias flag on the draw state (if possible in the 3D API). | 351 * antialias flag on the draw state (if possible in the 3D API). |
| 351 * | 352 * |
| 352 * @param transforms array of 2d affine transformations, one for each path. | 353 * @param pathRange Source of paths to draw from |
| 353 * @param fill the fill type for drawing all the paths. Fill must not be a | 354 * @param indices Array of indices into the the pathRange |
| 354 * hairline. | 355 * @param count Number of paths to draw (length of indices array) |
| 355 * @param stroke the stroke for drawing all the paths. | 356 * @param transforms Array of individual transforms, one for each path |
| 357 * @param transformsType Type of transformations in the array. Array contai ns | |
| 358 PathTransformSize(transformsType) × count elements | |
|
Nico
2014/08/12 04:20:21
Can you replace this with ascii please? On some lo
| |
| 359 * @param fill Fill type for drawing all the paths | |
| 356 */ | 360 */ |
| 357 void drawPaths(int pathCount, const GrPath** paths, | 361 enum PathTransformType { |
| 358 const SkMatrix* transforms, SkPath::FillType fill, | 362 kNone_PathTransformType, //!< [] |
| 359 SkStrokeRec::Style stroke); | 363 kTranslateX_PathTransformType, //!< [kMTransX] |
| 364 kTranslateY_PathTransformType, //!< [kMTransY] | |
| 365 kTranslate_PathTransformType, //!< [kMTransX, kMTransY] | |
| 366 kAffine_PathTransformType, //!< [kMScaleX, kMSkewX, kMTransX, kMSke wY, kMScaleY, kMTransY] | |
| 367 | |
| 368 kLast_PathTransformType = kAffine_PathTransformType | |
| 369 }; | |
| 370 void drawPaths(const GrPathRange* pathRange, | |
| 371 const uint32_t indices[], int count, | |
| 372 const float transforms[], PathTransformType transformsType, | |
| 373 SkPath::FillType fill); | |
| 374 | |
| 375 static inline int PathTransformSize(PathTransformType type) { | |
| 376 switch (type) { | |
| 377 case kNone_PathTransformType: | |
| 378 return 0; | |
| 379 case kTranslateX_PathTransformType: | |
| 380 case kTranslateY_PathTransformType: | |
| 381 return 1; | |
| 382 case kTranslate_PathTransformType: | |
| 383 return 2; | |
| 384 case kAffine_PathTransformType: | |
| 385 return 6; | |
| 386 | |
| 387 default: | |
| 388 SkFAIL("Unknown path transform type"); | |
| 389 return 0; | |
| 390 } | |
| 391 } | |
| 360 | 392 |
| 361 /** | 393 /** |
| 362 * Helper function for drawing rects. It performs a geometry src push and po p | 394 * Helper function for drawing rects. It performs a geometry src push and po p |
| 363 * and thus will finalize any reserved geometry. | 395 * and thus will finalize any reserved geometry. |
| 364 * | 396 * |
| 365 * @param rect the rect to draw | 397 * @param rect the rect to draw |
| 366 * @param matrix optional matrix applied to rect (before viewMatrix) | 398 * @param matrix optional matrix applied to rect (before viewMatrix) |
| 367 * @param localRect optional rect that specifies local coords to map onto | 399 * @param localRect optional rect that specifies local coords to map onto |
| 368 * rect. If NULL then rect serves as the local coords. | 400 * rect. If NULL then rect serves as the local coords. |
| 369 * @param localMatrix optional matrix applied to localRect. If | 401 * @param localMatrix optional matrix applied to localRect. If |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 509 * For subclass internal use to invoke a call to onDrawPath(). | 541 * For subclass internal use to invoke a call to onDrawPath(). |
| 510 */ | 542 */ |
| 511 void executeDrawPath(const GrPath* path, SkPath::FillType fill, | 543 void executeDrawPath(const GrPath* path, SkPath::FillType fill, |
| 512 const GrDeviceCoordTexture* dstCopy) { | 544 const GrDeviceCoordTexture* dstCopy) { |
| 513 this->onDrawPath(path, fill, dstCopy); | 545 this->onDrawPath(path, fill, dstCopy); |
| 514 } | 546 } |
| 515 | 547 |
| 516 /** | 548 /** |
| 517 * For subclass internal use to invoke a call to onDrawPaths(). | 549 * For subclass internal use to invoke a call to onDrawPaths(). |
| 518 */ | 550 */ |
| 519 void executeDrawPaths(int pathCount, const GrPath** paths, | 551 void executeDrawPaths(const GrPathRange* pathRange, |
| 520 const SkMatrix* transforms, SkPath::FillType fill, | 552 const uint32_t indices[], int count, |
| 521 SkStrokeRec::Style stroke, | 553 const float transforms[], PathTransformType transforms Type, |
| 554 SkPath::FillType fill, | |
| 522 const GrDeviceCoordTexture* dstCopy) { | 555 const GrDeviceCoordTexture* dstCopy) { |
| 523 this->onDrawPaths(pathCount, paths, transforms, fill, stroke, dstCopy); | 556 this->onDrawPaths(pathRange, indices, count, transforms, transformsType, fill, dstCopy); |
| 524 } | 557 } |
| 525 | 558 |
| 526 inline bool isGpuTracingEnabled() const { | 559 inline bool isGpuTracingEnabled() const { |
| 527 return this->getContext()->isGpuTracingEnabled(); | 560 return this->getContext()->isGpuTracingEnabled(); |
| 528 } | 561 } |
| 529 | 562 |
| 530 //////////////////////////////////////////////////////////////////////////// | 563 //////////////////////////////////////////////////////////////////////////// |
| 531 | 564 |
| 532 /** | 565 /** |
| 533 * See AutoStateRestore below. | 566 * See AutoStateRestore below. |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 902 // drawIndexedInstances, ...). The base class draws a two triangle fan using | 935 // drawIndexedInstances, ...). The base class draws a two triangle fan using |
| 903 // drawNonIndexed from reserved vertex space. | 936 // drawNonIndexed from reserved vertex space. |
| 904 virtual void onDrawRect(const SkRect& rect, | 937 virtual void onDrawRect(const SkRect& rect, |
| 905 const SkMatrix* matrix, | 938 const SkMatrix* matrix, |
| 906 const SkRect* localRect, | 939 const SkRect* localRect, |
| 907 const SkMatrix* localMatrix); | 940 const SkMatrix* localMatrix); |
| 908 | 941 |
| 909 virtual void onStencilPath(const GrPath*, SkPath::FillType) = 0; | 942 virtual void onStencilPath(const GrPath*, SkPath::FillType) = 0; |
| 910 virtual void onDrawPath(const GrPath*, SkPath::FillType, | 943 virtual void onDrawPath(const GrPath*, SkPath::FillType, |
| 911 const GrDeviceCoordTexture* dstCopy) = 0; | 944 const GrDeviceCoordTexture* dstCopy) = 0; |
| 912 virtual void onDrawPaths(int, const GrPath**, const SkMatrix*, | 945 virtual void onDrawPaths(const GrPathRange*, |
| 913 SkPath::FillType, SkStrokeRec::Style, | 946 const uint32_t indices[], int count, |
| 914 const GrDeviceCoordTexture* dstCopy) = 0; | 947 const float transforms[], PathTransformType, |
| 948 SkPath::FillType, const GrDeviceCoordTexture*) = 0; | |
| 915 | 949 |
| 916 virtual void didAddGpuTraceMarker() = 0; | 950 virtual void didAddGpuTraceMarker() = 0; |
| 917 virtual void didRemoveGpuTraceMarker() = 0; | 951 virtual void didRemoveGpuTraceMarker() = 0; |
| 918 | 952 |
| 919 // helpers for reserving vertex and index space. | 953 // helpers for reserving vertex and index space. |
| 920 bool reserveVertexSpace(size_t vertexSize, | 954 bool reserveVertexSpace(size_t vertexSize, |
| 921 int vertexCount, | 955 int vertexCount, |
| 922 void** vertices); | 956 void** vertices); |
| 923 bool reserveIndexSpace(int indexCount, void** indices); | 957 bool reserveIndexSpace(int indexCount, void** indices); |
| 924 | 958 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 952 GrContext* fContext; | 986 GrContext* fContext; |
| 953 // To keep track that we always have at least as many debug marker adds as r emoves | 987 // To keep track that we always have at least as many debug marker adds as r emoves |
| 954 int fGpuTraceMar kerCount; | 988 int fGpuTraceMar kerCount; |
| 955 GrTraceMarkerSet fActiveTrace Markers; | 989 GrTraceMarkerSet fActiveTrace Markers; |
| 956 GrTraceMarkerSet fStoredTrace Markers; | 990 GrTraceMarkerSet fStoredTrace Markers; |
| 957 | 991 |
| 958 typedef SkRefCnt INHERITED; | 992 typedef SkRefCnt INHERITED; |
| 959 }; | 993 }; |
| 960 | 994 |
| 961 #endif | 995 #endif |
| OLD | NEW |