aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-08-16 19:20:44 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-08-16 19:20:44 +0000
commit498776ad9f5ac78f4a6d0a4ef967921c42bc3e3f (patch)
treec0f49745032531cecca2d13f712e5721ef7168d4 /src
parent178d41e750b31248575752c8824c6035e234982f (diff)
Remove GrContext::drawCustomVertices
Review URL: http://codereview.appspot.com/4910042/ git-svn-id: http://skia.googlecode.com/svn/trunk@2124 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/gpu/SkGpuDevice.cpp99
1 files changed, 16 insertions, 83 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 761d6cc429..9fe54e5eeb 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -541,67 +541,6 @@ bool SkGpuDevice::skPaint2GrPaintShader(const SkPaint& skPaint,
///////////////////////////////////////////////////////////////////////////////
-class SkPositionSource {
-public:
- SkPositionSource(const SkPoint* points, int count)
- : fPoints(points), fCount(count) {}
-
- int count() const { return fCount; }
-
- void writeValue(int i, GrPoint* dstPosition) const {
- SkASSERT(i < fCount);
- dstPosition->fX = fPoints[i].fX;
- dstPosition->fY = fPoints[i].fY;
- }
-private:
- const SkPoint* fPoints;
- int fCount;
-};
-
-class SkTexCoordSource {
-public:
- SkTexCoordSource(const SkPoint* coords)
- : fCoords(coords) {}
-
- void writeValue(int i, GrPoint* dstCoord) const {
- dstCoord->fX = fCoords[i].fX;
- dstCoord->fY = fCoords[i].fY;
- }
-private:
- const SkPoint* fCoords;
-};
-
-class SkColorSource {
-public:
- SkColorSource(const SkColor* colors) : fColors(colors) {}
-
- void writeValue(int i, GrColor* dstColor) const {
- *dstColor = SkGr::SkColor2GrColor(fColors[i]);
- }
-private:
- const SkColor* fColors;
-};
-
-class SkIndexSource {
-public:
- SkIndexSource(const uint16_t* indices, int count)
- : fIndices(indices), fCount(count) {
- }
-
- int count() const { return fCount; }
-
- void writeValue(int i, uint16_t* dstIndex) const {
- *dstIndex = fIndices[i];
- }
-
-private:
- const uint16_t* fIndices;
- int fCount;
-};
-
-
-///////////////////////////////////////////////////////////////////////////////
-
void SkGpuDevice::clear(SkColor color) {
fContext->clear(NULL, color);
}
@@ -1464,29 +1403,23 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
}
}
- // even if GrColor and SkColor byte offsets match we need
- // to perform pre-multiply.
- if (NULL == colors) {
- fContext->drawVertices(grPaint,
- gVertexMode2PrimitiveType[vmode],
- vertexCount,
- (GrPoint*) vertices,
- (GrPoint*) texs,
- NULL,
- indices,
- indexCount);
- } else {
- SkTexCoordSource texSrc(texs);
- SkColorSource colSrc(colors);
- SkIndexSource idxSrc(indices, indexCount);
-
- fContext->drawCustomVertices(grPaint,
- gVertexMode2PrimitiveType[vmode],
- SkPositionSource(vertices, vertexCount),
- (NULL == texs) ? NULL : &texSrc,
- (NULL == colors) ? NULL : &colSrc,
- (NULL == indices) ? NULL : &idxSrc);
+ SkAutoSTMalloc<128, GrColor> convertedColors(0);
+ if (NULL != colors) {
+ // need to convert byte order and from non-PM to PM
+ convertedColors.realloc(vertexCount);
+ for (int i = 0; i < vertexCount; ++i) {
+ convertedColors[i] = SkGr::SkColor2GrColor(colors[i]);
+ }
+ colors = convertedColors.get();
}
+ fContext->drawVertices(grPaint,
+ gVertexMode2PrimitiveType[vmode],
+ vertexCount,
+ (GrPoint*) vertices,
+ (GrPoint*) texs,
+ colors,
+ indices,
+ indexCount);
}
///////////////////////////////////////////////////////////////////////////////