diff options
author | 2012-10-05 15:37:00 +0000 | |
---|---|---|
committer | 2012-10-05 15:37:00 +0000 | |
commit | 8b129aa3379ece6c43d9ce2ad0cdeafb089b7eb5 (patch) | |
tree | d9f337d19895870dc76c05b5352e5b7799d0b129 /src/gpu/GrDrawTarget.cpp | |
parent | 3f5d682191c044005345e09bdd2fd14a4d0171c2 (diff) |
Moved paint color to vertex colors for batched rects
https://codereview.appspot.com/6620045/
git-svn-id: http://skia.googlecode.com/svn/trunk@5830 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/GrDrawTarget.cpp')
-rw-r--r-- | src/gpu/GrDrawTarget.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp index 0b61f6e531..ab345bc6cb 100644 --- a/src/gpu/GrDrawTarget.cpp +++ b/src/gpu/GrDrawTarget.cpp @@ -1039,8 +1039,8 @@ void GrDrawTarget::drawRect(const GrRect& rect, } SetRectVertices(rect, matrix, srcRects, - srcMatrices, layout, geo.vertices()); - + srcMatrices, SK_ColorBLACK, layout, geo.vertices()); + drawNonIndexed(kTriangleFan_GrPrimitiveType, 0, 4); } @@ -1060,10 +1060,20 @@ GrVertexLayout GrDrawTarget::GetRectVertexLayout(const GrRect* srcRects[]) { return layout; } +// This method fills int the four vertices for drawing 'rect'. +// matrix - is applied to each vertex +// srcRects - provide the uvs for each vertex +// srcMatrices - are applied to the corresponding 'srcRect' +// color - vertex color (replicated in each vertex) +// layout - specifies which uvs and/or color are present +// vertices - storage for the resulting vertices +// Note: the color parameter will only be used when kColor_VertexLayoutBit +// is present in 'layout' void GrDrawTarget::SetRectVertices(const GrRect& rect, const GrMatrix* matrix, const GrRect* srcRects[], const GrMatrix* srcMatrices[], + GrColor color, GrVertexLayout layout, void* vertices) { #if GR_DEBUG @@ -1077,9 +1087,9 @@ void GrDrawTarget::SetRectVertices(const GrRect& rect, } #endif - int stageOffsets[GrDrawState::kNumStages]; + int stageOffsets[GrDrawState::kNumStages], colorOffset; int vsize = VertexSizeAndOffsetsByStage(layout, stageOffsets, - NULL, NULL, NULL); + &colorOffset, NULL, NULL); GrTCast<GrPoint*>(vertices)->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, @@ -1100,6 +1110,16 @@ void GrDrawTarget::SetRectVertices(const GrRect& rect, } } } + + if (layout & kColor_VertexLayoutBit) { + + GrColor* vertCol = GrTCast<GrColor*>(GrTCast<intptr_t>(vertices) + colorOffset); + + for (int i = 0; i < 4; ++i) { + *vertCol = color; + vertCol = (GrColor*) ((intptr_t) vertCol + vsize); + } + } } //////////////////////////////////////////////////////////////////////////////// |