diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-01-21 21:03:59 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-01-21 21:03:59 +0000 |
commit | 5782d712ffc31557d0cb12d5a220cebb783f6895 (patch) | |
tree | cdc0b2fb6d9b60ddca81eb7fb6a3906035d29875 /gpu/src | |
parent | 70915f0210a8749553cbb93b12b2963cf350fff6 (diff) |
Rev the GrContext interface. Context has draw* functions that take a new GrPaint object. Removed many of the lower-level GrGpu function call-throughs on context.
Remove unused/unsupported point size (we don't draw non-hairline points using GL points).
Change current* getter functions to get* for consistency.
Fix bounds when drawing inverse-filled paths.
git-svn-id: http://skia.googlecode.com/svn/trunk@718 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gpu/src')
-rw-r--r-- | gpu/src/GrContext.cpp | 388 | ||||
-rw-r--r-- | gpu/src/GrDrawTarget.cpp | 66 | ||||
-rw-r--r-- | gpu/src/GrGpuGL.cpp | 5 | ||||
-rw-r--r-- | gpu/src/GrGpuGL.h | 8 | ||||
-rw-r--r-- | gpu/src/GrGpuGLFixed.cpp | 119 | ||||
-rw-r--r-- | gpu/src/GrTextContext.cpp | 21 |
6 files changed, 328 insertions, 279 deletions
diff --git a/gpu/src/GrContext.cpp b/gpu/src/GrContext.cpp index ee788483eb..5e6b824c9b 100644 --- a/gpu/src/GrContext.cpp +++ b/gpu/src/GrContext.cpp @@ -138,17 +138,17 @@ GrTextureEntry* GrContext::createAndLockTexture(GrTextureKey* key, GrTexture* texture = fGpu->createTexture(rtDesc, NULL, 0);
if (NULL != texture) {
- GrGpu::AutoStateRestore asr(fGpu);
+ GrDrawTarget::AutoStateRestore asr(fGpu);
fGpu->setRenderTarget(texture->asRenderTarget());
fGpu->setTexture(0, clampEntry->texture());
- fGpu->setStencilPass(GrGpu::kNone_StencilPass);
+ fGpu->setStencilPass(GrDrawTarget::kNone_StencilPass);
fGpu->setTextureMatrix(0, GrMatrix::I());
fGpu->setViewMatrix(GrMatrix::I());
fGpu->setAlpha(0xff);
- fGpu->setBlendFunc(GrGpu::kOne_BlendCoeff, GrGpu::kZero_BlendCoeff);
- fGpu->disableState(GrGpu::kDither_StateBit |
- GrGpu::kClip_StateBit |
- GrGpu::kAntialias_StateBit);
+ fGpu->setBlendFunc(GrDrawTarget::kOne_BlendCoeff, GrDrawTarget::kZero_BlendCoeff);
+ fGpu->disableState(GrDrawTarget::kDither_StateBit |
+ GrDrawTarget::kClip_StateBit |
+ GrDrawTarget::kAntialias_StateBit);
GrSamplerState stretchSampler(GrSamplerState::kClamp_WrapMode,
GrSamplerState::kClamp_WrapMode,
sampler.isFilter());
@@ -171,7 +171,7 @@ GrTextureEntry* GrContext::createAndLockTexture(GrTextureKey* key, clampTexture->contentHeight() /
clampTexture->allocHeight());
verts[1].setRectFan(0, 0, tw, th, 2*sizeof(GrPoint));
- fGpu->drawNonIndexed(GrGpu::kTriangleFan_PrimitiveType,
+ fGpu->drawNonIndexed(GrDrawTarget::kTriangleFan_PrimitiveType,
0, 4);
entry = fTextureCache->createAndLock(*key, texture);
}
@@ -275,11 +275,24 @@ bool GrContext::supportsIndex8PixelConfig(const GrSamplerState& sampler, ////////////////////////////////////////////////////////////////////////////////
+void GrContext::setClip(const GrClip& clip) {
+ fGpu->setClip(clip);
+ fGpu->enableState(GrDrawTarget::kClip_StateBit);
+}
+
+void GrContext::setClip(const GrIRect& rect) {
+ GrClip clip;
+ clip.setRect(rect);
+ fGpu->setClip(clip);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
void GrContext::eraseColor(GrColor color) {
fGpu->eraseColor(color);
}
-void GrContext::drawFull(bool useTexture) {
+void GrContext::drawPaint(const GrPaint& paint) {
// set rect to be big enough to fill the space, but not super-huge, so we
// don't overflow fixed-point implementations
GrRect r(fGpu->getClip().getBounds());
@@ -289,8 +302,7 @@ void GrContext::drawFull(bool useTexture) { } else {
GrPrintf("---- fGpu->getViewInverse failed\n");
}
-
- this->fillRect(r, useTexture);
+ this->drawRect(paint, r);
}
/* create a triangle strip that strokes the specified triangle. There are 8
@@ -314,8 +326,11 @@ static void setStrokeRectStrip(GrPoint verts[10], const GrRect& rect, verts[9] = verts[1];
}
-void GrContext::drawRect(const GrRect& rect, bool useTexture, GrScalar width) {
- GrVertexLayout layout = useTexture ?
+void GrContext::drawRect(const GrPaint& paint,
+ const GrRect& rect,
+ GrScalar width) {
+
+ GrVertexLayout layout = (NULL != paint.getTexture()) ?
GrDrawTarget::StagePosAsTexCoordVertexLayoutBit(0) :
0;
@@ -325,21 +340,21 @@ void GrContext::drawRect(const GrRect& rect, bool useTexture, GrScalar width) { return;
}
- this->flushText();
+ this->prepareToDraw(paint);
int vertCount;
- GrGpu::PrimitiveType primType;
+ GrDrawTarget::PrimitiveType primType;
GrPoint* vertex = geo.positions();
if (width >= 0) {
if (width > 0) {
vertCount = 10;
- primType = GrGpu::kTriangleStrip_PrimitiveType;
+ primType = GrDrawTarget::kTriangleStrip_PrimitiveType;
setStrokeRectStrip(vertex, rect, width);
} else {
// hairline
vertCount = 5;
- primType = GrGpu::kLineStrip_PrimitiveType;
+ primType = GrDrawTarget::kLineStrip_PrimitiveType;
vertex[0].set(rect.fLeft, rect.fTop);
vertex[1].set(rect.fRight, rect.fTop);
vertex[2].set(rect.fRight, rect.fBottom);
@@ -348,13 +363,111 @@ void GrContext::drawRect(const GrRect& rect, bool useTexture, GrScalar width) { }
} else {
vertCount = 4;
- primType = GrGpu::kTriangleFan_PrimitiveType;
+ primType = GrDrawTarget::kTriangleFan_PrimitiveType;
vertex->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
}
fGpu->drawNonIndexed(primType, 0, vertCount);
}
+void GrContext::drawRectToRect(const GrPaint& paint,
+ const GrRect& dstRect,
+ const GrRect& srcRect) {
+
+ if (NULL == paint.getTexture()) {
+ drawRect(paint, dstRect);
+ return;
+ }
+
+ GrVertexLayout layout = GrDrawTarget::StageTexCoordVertexLayoutBit(0,0);
+ static const int VCOUNT = 4;
+
+ GrDrawTarget::AutoReleaseGeometry geo(fGpu, layout, VCOUNT, 0);
+ if (!geo.succeeded()) {
+ return;
+ }
+
+ this->prepareToDraw(paint);
+
+ GrPoint* vertex = (GrPoint*) geo.vertices();
+
+ vertex[0].setRectFan(dstRect.fLeft, dstRect.fTop,
+ dstRect.fRight, dstRect.fBottom,
+ 2 * sizeof(GrPoint));
+ vertex[1].setRectFan(srcRect.fLeft, srcRect.fTop,
+ srcRect.fRight, srcRect.fBottom,
+ 2 * sizeof(GrPoint));
+
+ fGpu->drawNonIndexed(GrDrawTarget::kTriangleFan_PrimitiveType, 0, VCOUNT);
+}
+
+void GrContext::drawVertices(const GrPaint& paint,
+ GrDrawTarget::PrimitiveType primitiveType,
+ int vertexCount,
+ const GrPoint positions[],
+ const GrPoint texCoords[],
+ const GrColor colors[],
+ const uint16_t indices[],
+ int indexCount) {
+ GrVertexLayout layout = 0;
+ bool interLeave = false;
+
+ GrDrawTarget::AutoReleaseGeometry geo;
+
+ this->prepareToDraw(paint);
+
+ if (NULL != paint.getTexture()) {
+ if (NULL == texCoords) {
+ layout |= GrDrawTarget::StagePosAsTexCoordVertexLayoutBit(0);
+ } else {
+ layout |= GrDrawTarget::StageTexCoordVertexLayoutBit(0,0);
+ interLeave = true;
+ }
+ }
+
+ if (NULL != colors) {
+ layout |= GrDrawTarget::kColor_VertexLayoutBit;
+ }
+
+ static const GrVertexLayout interleaveMask =
+ (GrDrawTarget::StageTexCoordVertexLayoutBit(0,0) |
+ GrDrawTarget::kColor_VertexLayoutBit);
+ if (interleaveMask & layout) {
+ if (!geo.set(fGpu, layout, vertexCount, 0)) {
+ GrPrintf("Failed to get space for vertices!");
+ return;
+ }
+ int texOffsets[GrDrawTarget::kMaxTexCoords];
+ int colorOffset;
+ int vsize = GrDrawTarget::VertexSizeAndOffsetsByIdx(layout,
+ texOffsets,
+ &colorOffset);
+ void* curVertex = geo.vertices();
+
+ for (int i = 0; i < vertexCount; ++i) {
+ *((GrPoint*)curVertex) = positions[i];
+
+ if (texOffsets[0] > 0) {
+ *(GrPoint*)((intptr_t)curVertex + texOffsets[0]) = texCoords[i];
+ }
+ if (colorOffset > 0) {
+ *(GrColor*)((intptr_t)curVertex + colorOffset) = colors[i];
+ }
+ curVertex = (void*)((intptr_t)curVertex + vsize);
+ }
+ } else {
+ fGpu->setVertexSourceToArray(positions, layout);
+ }
+
+ if (NULL != indices) {
+ fGpu->setIndexSourceToArray(indices);
+ fGpu->drawIndexed(primitiveType, 0, 0, vertexCount, indexCount);
+ } else {
+ fGpu->drawNonIndexed(primitiveType, 0, vertexCount);
+ }
+}
+
+
////////////////////////////////////////////////////////////////////////////////
#define NEW_EVAL 1 // Use adaptive path tesselation
@@ -533,7 +646,6 @@ static int worst_case_point_count(GrPathIter* path, static inline bool single_pass_path(const GrPathIter& path,
GrContext::PathFills fill,
- bool useTex,
const GrGpu& gpu) {
#if STENCIL_OFF
return true;
@@ -554,16 +666,18 @@ static inline bool single_pass_path(const GrPathIter& path, #endif
}
-void GrContext::drawPath(GrPathIter* path, PathFills fill,
- bool useTexture, const GrPoint* translate) {
+void GrContext::drawPath(const GrPaint& paint,
+ GrPathIter* path,
+ PathFills fill,
+ const GrPoint* translate) {
- flushText();
- GrGpu::AutoStateRestore asr(fGpu);
+ this->prepareToDraw(paint);
+
+ GrDrawTarget::AutoStateRestore asr(fGpu);
#if NEW_EVAL
- GrMatrix viewM;
- fGpu->getViewMatrix(&viewM);
+ GrMatrix viewM = fGpu->getViewMatrix();
// In order to tesselate the path we get a bound on how much the matrix can
// stretch when mapping to screen coordinates.
GrScalar stretch = viewM.getMaxStretch();
@@ -594,7 +708,8 @@ void GrContext::drawPath(GrPathIter* path, PathFills fill, #endif
tol);
GrVertexLayout layout = 0;
- if (useTexture) {
+
+ if (NULL != paint.getTexture()) {
layout = GrDrawTarget::StagePosAsTexCoordVertexLayoutBit(0);
}
// add 4 to hold the bounding rect
@@ -609,20 +724,20 @@ void GrContext::drawPath(GrPathIter* path, PathFills fill, path->rewind();
// TODO: use primitve restart if available rather than multiple draws
- GrGpu::PrimitiveType type;
+ GrDrawTarget::PrimitiveType type;
int passCount = 0;
- GrGpu::StencilPass passes[3];
+ GrDrawTarget::StencilPass passes[3];
bool reverse = false;
if (kHairLine_PathFill == fill) {
- type = GrGpu::kLineStrip_PrimitiveType;
+ type = GrDrawTarget::kLineStrip_PrimitiveType;
passCount = 1;
- passes[0] = GrGpu::kNone_StencilPass;
+ passes[0] = GrDrawTarget::kNone_StencilPass;
} else {
- type = GrGpu::kTriangleFan_PrimitiveType;
- if (single_pass_path(*path, fill, useTexture, *fGpu)) {
+ type = GrDrawTarget::kTriangleFan_PrimitiveType;
+ if (single_pass_path(*path, fill, *fGpu)) {
passCount = 1;
- passes[0] = GrGpu::kNone_StencilPass;
+ passes[0] = GrDrawTarget::kNone_StencilPass;
} else {
switch (fill) {
case kInverseEvenOdd_PathFill:
@@ -630,21 +745,21 @@ void GrContext::drawPath(GrPathIter* path, PathFills fill, // fallthrough
case kEvenOdd_PathFill:
passCount = 2;
- passes[0] = GrGpu::kEvenOddStencil_StencilPass;
- passes[1] = GrGpu::kEvenOddColor_StencilPass;
+ passes[0] = GrDrawTarget::kEvenOddStencil_StencilPass;
+ passes[1] = GrDrawTarget::kEvenOddColor_StencilPass;
break;
case kInverseWinding_PathFill:
reverse = true;
// fallthrough
case kWinding_PathFill:
- passes[0] = GrGpu::kWindingStencil1_StencilPass;
+ passes[0] = GrDrawTarget::kWindingStencil1_StencilPass;
if (fGpu->supportsSingleStencilPassWinding()) {
- passes[1] = GrGpu::kWindingColor_StencilPass;
+ passes[1] = GrDrawTarget::kWindingColor_StencilPass;
passCount = 2;
} else {
- passes[1] = GrGpu::kWindingStencil2_StencilPass;
- passes[2] = GrGpu::kWindingColor_StencilPass;
+ passes[1] = GrDrawTarget::kWindingStencil2_StencilPass;
+ passes[2] = GrDrawTarget::kWindingColor_StencilPass;
passCount = 3;
}
break;
@@ -752,11 +867,15 @@ FINISHED: if (useBounds) {
GrRect bounds;
if (reverse) {
- GrAssert(NULL != fGpu->currentRenderTarget());
+ GrAssert(NULL != fGpu->getRenderTarget());
// draw over the whole world.
bounds.setLTRB(0, 0,
- GrIntToScalar(fGpu->currentRenderTarget()->width()),
- GrIntToScalar(fGpu->currentRenderTarget()->height()));
+ GrIntToScalar(fGpu->getRenderTarget()->width()),
+ GrIntToScalar(fGpu->getRenderTarget()->height()));
+ GrMatrix vmi;
+ if (fGpu->getViewInverse(&vmi)) {
+ vmi.mapRect(&bounds);
+ }
} else {
bounds.setBounds((GrPoint*)base, vert - base);
}
@@ -766,10 +885,11 @@ FINISHED: for (int p = 0; p < passCount; ++p) {
fGpu->setStencilPass(passes[p]);
- if (useBounds && (GrGpu::kEvenOddColor_StencilPass == passes[p] ||
- GrGpu::kWindingColor_StencilPass == passes[p])) {
- fGpu->drawNonIndexed(GrGpu::kTriangleFan_PrimitiveType,
+ if (useBounds && (GrDrawTarget::kEvenOddColor_StencilPass == passes[p] ||
+ GrDrawTarget::kWindingColor_StencilPass == passes[p])) {
+ fGpu->drawNonIndexed(GrDrawTarget::kTriangleFan_PrimitiveType,
maxPts, 4);
+
} else {
int baseVertex = 0;
for (int sp = 0; sp < subpathCnt; ++sp) {
@@ -782,6 +902,8 @@ FINISHED: }
}
+////////////////////////////////////////////////////////////////////////////////
+
void GrContext::flush(bool flushRenderTarget) {
flushText();
if (flushRenderTarget) {
@@ -803,6 +925,10 @@ bool GrContext::readPixels(int left, int top, int width, int height, void GrContext::writePixels(int left, int top, int width, int height,
GrTexture::PixelConfig config, const void* buffer,
size_t stride) {
+
+ // TODO: when underlying api has a direct way to do this we should use it
+ // (e.g. glDrawPixels on desktop GL).
+
const GrGpu::TextureDesc desc = {
0, GrGpu::kNone_AALevel, width, height, config
};
@@ -830,32 +956,47 @@ void GrContext::writePixels(int left, int top, int width, int height, fGpu->setTexture(0, texture);
fGpu->setSamplerState(0, GrSamplerState::ClampNoFilter());
- this->fillRect(GrRect(0, 0, GrIntToScalar(width), GrIntToScalar(height)),
- true);
-}
+ GrVertexLayout layout = GrDrawTarget::StagePosAsTexCoordVertexLayoutBit(0);
+ static const int VCOUNT = 4;
+ GrDrawTarget::AutoReleaseGeometry geo(fGpu, layout, VCOUNT, 0);
+ if (!geo.succeeded()) {
+ return;
+ }
+ ((GrPoint*)geo.vertices())->setIRectFan(0, 0, width, height);
+ fGpu->drawNonIndexed(GrDrawTarget::kTriangleFan_PrimitiveType, 0, VCOUNT);
+}
////////////////////////////////////////////////////////////////////////////////
+void GrContext::SetPaint(const GrPaint& paint, GrDrawTarget* target) {
+ target->setTexture(0, paint.getTexture());
+ target->setTextureMatrix(0, paint.fTextureMatrix);
+ target->setSamplerState(0, paint.fSampler);
+ target->setColor(paint.fColor);
-/* -------------------------------------------------------
- * Mimicking the GrGpu interface for now
- * TODO: define appropriate higher-level API for context
- */
-
-void GrContext::resetContext() {
- fGpu->resetContext();
+ if (paint.fDither) {
+ target->enableState(GrDrawTarget::kDither_StateBit);
+ } else {
+ target->disableState(GrDrawTarget::kDither_StateBit);
+ }
+ if (paint.fAntiAlias) {
+ target->enableState(GrDrawTarget::kAntialias_StateBit);
+ } else {
+ target->disableState(GrDrawTarget::kAntialias_StateBit);
+ }
+ target->setBlendFunc(paint.fSrcBlendCoeff, paint.fDstBlendCoeff);
}
-GrVertexBuffer* GrContext::createVertexBuffer(uint32_t size, bool dynamic) {
- return fGpu->createVertexBuffer(size, dynamic);
-}
+void GrContext::prepareToDraw(const GrPaint& paint) {
-GrIndexBuffer* GrContext::createIndexBuffer(uint32_t size, bool dynamic) {
- return fGpu->createIndexBuffer(size, dynamic);
+ flushText();
+ SetPaint(paint, fGpu);
}
-void GrContext::setTexture(int stage, GrTexture* texture) {
- fGpu->setTexture(stage, texture);
+////////////////////////////////////////////////////////////////////////////////
+
+void GrContext::resetContext() {
+ fGpu->resetContext();
}
void GrContext::setRenderTarget(GrRenderTarget* target) {
@@ -863,93 +1004,24 @@ void GrContext::setRenderTarget(GrRenderTarget* target) { fGpu->setRenderTarget(target);
}
-GrRenderTarget* GrContext::currentRenderTarget() const {
- return fGpu->currentRenderTarget();
-}
-
-void GrContext::setSamplerState(int stage, const GrSamplerState& samplerState) {
- fGpu->setSamplerState(stage, samplerState);
+GrRenderTarget* GrContext::getRenderTarget() {
+ return fGpu->getRenderTarget();
}
-void GrContext::setTextureMatrix(int stage, const GrMatrix& m) {
- fGpu->setTextureMatrix(stage, m);
+const GrRenderTarget* GrContext::getRenderTarget() const {
+ return fGpu->getRenderTarget();
}
-void GrContext::getViewMatrix(GrMatrix* m) const {
- fGpu->getViewMatrix(m);
+const GrMatrix& GrContext::getMatrix() const {
+ return fGpu->getViewMatrix();
}
-void GrContext::setViewMatrix(const GrMatrix& m) {
+void GrContext::setMatrix(const GrMatrix& m) {
fGpu->setViewMatrix(m);
}
-bool GrContext::reserveAndLockGeometry(GrVertexLayout vertexLayout,
- uint32_t vertexCount,
- uint32_t indexCount,
- void** vertices,
- void** indices) {
- return fGpu->reserveAndLockGeometry(vertexLayout,
- vertexCount,
- indexCount,
- vertices,
- indices);
-}
-
-void GrContext::drawIndexed(GrGpu::PrimitiveType type,
- uint32_t startVertex,
- uint32_t startIndex,
- uint32_t vertexCount,
- uint32_t indexCount) {
- flushText();
- fGpu->drawIndexed(type,
- startVertex,
- startIndex,
- vertexCount,
- indexCount);
-}
-
-void GrContext::drawNonIndexed(GrGpu::PrimitiveType type,
- uint32_t startVertex,
- uint32_t vertexCount) {
- flushText();
- fGpu->drawNonIndexed(type,
- startVertex,
- vertexCount);
-}
-
-void GrContext::setVertexSourceToArray(const void* array,
- GrVertexLayout vertexLayout) {
- fGpu->setVertexSourceToArray(array, vertexLayout);
-}
-
-void GrContext::setIndexSourceToArray(const void* array) {
- fGpu->setIndexSourceToArray(array);
-}
-
-void GrContext::setVertexSourceToBuffer(GrVertexBuffer* buffer,
- GrVertexLayout vertexLayout) {
- fGpu->setVertexSourceToBuffer(buffer, vertexLayout);
-}
-
-void GrContext::setIndexSourceToBuffer(GrIndexBuffer* buffer) {
- fGpu->setIndexSourceToBuffer(buffer);
-}
-
-void GrContext::releaseReservedGeometry() {
- fGpu->releaseReservedGeometry();
-}
-
-void GrContext::setClip(const GrClip& clip) {
- fGpu->setClip(clip);
- fGpu->enableState(GrDrawTarget::kClip_StateBit);
-}
-
-void GrContext::setAlpha(uint8_t alpha) {
- fGpu->setAlpha(alpha);
-}
-
-void GrContext::setColor(GrColor color) {
- fGpu->setColor(color);
+void GrContext::concatMatrix(const GrMatrix& m) const {
+ fGpu->concatViewMatrix(m);
}
static inline intptr_t setOrClear(intptr_t bits, int shift, intptr_t pred) {
@@ -962,34 +1034,6 @@ static inline intptr_t setOrClear(intptr_t bits, int shift, intptr_t pred) { return bits;
}
-void GrContext::setAntiAlias(bool aa) {
- if (aa) {
- fGpu->enableState(GrGpu::kAntialias_StateBit);
- } else {
- fGpu->disableState(GrGpu::kAntialias_StateBit);
- }
-}
-
-void GrContext::setDither(bool dither) {
- // hack for now, since iPad dither is hella-slow
- dither = false;
-
- if (dither) {
- fGpu->enableState(GrGpu::kDither_StateBit);
- } else {
- fGpu->disableState(GrGpu::kDither_StateBit);
- }
-}
-
-void GrContext::setPointSize(float size) {
- fGpu->setPointSize(size);
-}
-
-void GrContext::setBlendFunc(GrGpu::BlendCoeff srcCoef,
- GrGpu::BlendCoeff dstCoef) {
- fGpu->setBlendFunc(srcCoef, dstCoef);
-}
-
void GrContext::resetStats() {
fGpu->resetStats();
}
@@ -1031,13 +1075,16 @@ bool GrContext::finalizeTextureKey(GrTextureKey* key, return 0 != bits;
}
-GrDrawTarget* GrContext::getTextTarget() {
+GrDrawTarget* GrContext::getTextTarget(const GrPaint& paint) {
+ GrDrawTarget* target;
#if DEFER_TEXT_RENDERING
fTextDrawBuffer.initializeDrawStateAndClip(*fGpu);
- return &fTextDrawBuffer;
+ target = &fTextDrawBuffer;
#else
- return fGpu;
+ target = fGpu;
#endif
+ SetPaint(paint, target);
+ return target;
}
const GrIndexBuffer* GrContext::quadIndexBuffer() const {
@@ -1050,4 +1097,3 @@ int GrContext::maxQuadsInIndexBuffer() const { -
diff --git a/gpu/src/GrDrawTarget.cpp b/gpu/src/GrDrawTarget.cpp index df0f0be23b..abc9fb4257 100644 --- a/gpu/src/GrDrawTarget.cpp +++ b/gpu/src/GrDrawTarget.cpp @@ -22,7 +22,7 @@ // one stage template <int N> static int stage_mask_recur(int stage) { - return GrDrawTarget::StageTexCoordVertexLayoutBit(stage, N) | + return GrDrawTarget::StageTexCoordVertexLayoutBit(stage, N) | stage_mask_recur<N+1>(stage); } template<> // linux build doesn't like static on specializations @@ -35,7 +35,7 @@ static int stage_tex_coord_mask(int stage) { // mask of all bits relevant to one stage static int stage_mask(int stage) { - return stage_tex_coord_mask(stage) | + return stage_tex_coord_mask(stage) | GrDrawTarget::StagePosAsTexCoordVertexLayoutBit(stage); } @@ -43,7 +43,7 @@ static int stage_mask(int stage) { // texture coordinate index template <int N> static int tex_coord_mask_recur(int texCoordIdx) { - return GrDrawTarget::StageTexCoordVertexLayoutBit(N, texCoordIdx) | + return GrDrawTarget::StageTexCoordVertexLayoutBit(N, texCoordIdx) | tex_coord_mask_recur<N+1>(texCoordIdx); } template<> // linux build doesn't like static on specializations @@ -67,8 +67,8 @@ bool check_layout(GrVertexLayout layout) { size_t GrDrawTarget::VertexSize(GrVertexLayout vertexLayout) { GrAssert(check_layout(vertexLayout)); - - size_t vecSize = (vertexLayout & kTextFormat_VertexLayoutBit) ? + + size_t vecSize = (vertexLayout & kTextFormat_VertexLayoutBit) ? sizeof(GrGpuTextVertex) : sizeof(GrPoint); @@ -91,8 +91,8 @@ int GrDrawTarget::VertexStageCoordOffset(int stage, GrVertexLayout vertexLayout) } int tcIdx = VertexTexCoordsForStage(stage, vertexLayout); if (tcIdx >= 0) { - - int vecSize = (vertexLayout & kTextFormat_VertexLayoutBit) ? + + int vecSize = (vertexLayout & kTextFormat_VertexLayoutBit) ? sizeof(GrGpuTextVertex) : sizeof(GrPoint); int offset = vecSize; // position @@ -110,9 +110,9 @@ int GrDrawTarget::VertexStageCoordOffset(int stage, GrVertexLayout vertexLayout) int GrDrawTarget::VertexColorOffset(GrVertexLayout vertexLayout) { GrAssert(check_layout(vertexLayout)); - + if (vertexLayout & kColor_VertexLayoutBit) { - int vecSize = (vertexLayout & kTextFormat_VertexLayoutBit) ? + int vecSize = (vertexLayout & kTextFormat_VertexLayoutBit) ? sizeof(GrGpuTextVertex) : sizeof(GrPoint); int offset = vecSize; // position @@ -131,15 +131,15 @@ int GrDrawTarget::VertexSizeAndOffsetsByIdx(GrVertexLayout vertexLayout, int texCoordOffsetsByIdx[kMaxTexCoords], int* colorOffset) { GrAssert(check_layout(vertexLayout)); - + GrAssert(NULL != texCoordOffsetsByIdx); GrAssert(NULL != colorOffset); - int vecSize = (vertexLayout & kTextFormat_VertexLayoutBit) ? + int vecSize = (vertexLayout & kTextFormat_VertexLayoutBit) ? sizeof(GrGpuTextVertex) : sizeof(GrPoint); int size = vecSize; // position - + for (int t = 0; t < kMaxTexCoords; ++t) { if (tex_coord_idx_mask(t) & vertexLayout) { texCoordOffsetsByIdx[t] = size; @@ -164,10 +164,10 @@ int GrDrawTarget::VertexSizeAndOffsetsByStage(GrVertexLayout vertexLayout, GrAssert(NULL != texCoordOffsetsByStage); GrAssert(NULL != colorOffset); - + int texCoordOffsetsByIdx[kMaxTexCoords]; - int size = VertexSizeAndOffsetsByIdx(vertexLayout, - texCoordOffsetsByIdx, + int size = VertexSizeAndOffsetsByIdx(vertexLayout, + texCoordOffsetsByIdx, colorOffset); for (int s = 0; s < kNumStages; ++s) { int tcIdx; @@ -179,7 +179,7 @@ int GrDrawTarget::VertexSizeAndOffsetsByStage(GrVertexLayout vertexLayout, texCoordOffsetsByStage[s] = -1; } } - return size; + return size; } bool GrDrawTarget::VertexUsesStage(int stage, GrVertexLayout vertexLayout) { @@ -188,9 +188,9 @@ bool GrDrawTarget::VertexUsesStage(int stage, GrVertexLayout vertexLayout) { return !!(stage_mask(stage) & vertexLayout); } -bool GrDrawTarget::VertexUsesTexCoordIdx(int coordIndex, +bool GrDrawTarget::VertexUsesTexCoordIdx(int coordIndex, GrVertexLayout vertexLayout) { - GrAssert(coordIndex < kMaxTexCoords); + GrAssert(coordIndex < kMaxTexCoords); GrAssert(check_layout(vertexLayout)); return !!(tex_coord_idx_mask(coordIndex) & vertexLayout); } @@ -222,7 +222,7 @@ void GrDrawTarget::VertexLayoutUnitTest() { for (int t = 0; t < kMaxTexCoords; ++t) { stageMask |= StageTexCoordVertexLayoutBit(s,t); } - GrAssert(1 == kMaxTexCoords || !check_layout(stageMask)); + GrAssert(1 == kMaxTexCoords || !check_layout(stageMask)); GrAssert(stage_tex_coord_mask(s) == stageMask); stageMask |= StagePosAsTexCoordVertexLayoutBit(s); GrAssert(stage_mask(s) == stageMask); @@ -242,7 +242,7 @@ void GrDrawTarget::VertexLayoutUnitTest() { GrAssert(-1 == VertexStageCoordOffset(s2, tcMask)); GrAssert(!VertexUsesStage(s2, tcMask)); GrAssert(-1 == VertexTexCoordsForStage(s2, tcMask)); - + GrVertexLayout posAsTex = tcMask | StagePosAsTexCoordVertexLayoutBit(s2); GrAssert(0 == VertexStageCoordOffset(s2, posAsTex)); GrAssert(VertexUsesStage(s2, posAsTex)); @@ -255,7 +255,7 @@ void GrDrawTarget::VertexLayoutUnitTest() { } GrAssert(tex_coord_idx_mask(t) == tcMask); GrAssert(check_layout(tcMask)); - + int stageOffsets[kNumStages]; int colorOffset; int size; @@ -300,7 +300,12 @@ void GrDrawTarget::setTexture(int stage, GrTexture* tex) { fCurrDrawState.fTextures[stage] = tex; } -GrTexture* GrDrawTarget::currentTexture(int stage) const { +const GrTexture* GrDrawTarget::getTexture(int stage) const { + GrAssert(stage >= 0 && stage < kNumStages); + return fCurrDrawState.fTextures[stage]; +} + +GrTexture* GrDrawTarget::getTexture(int stage) { GrAssert(stage >= 0 && stage < kNumStages); return fCurrDrawState.fTextures[stage]; } @@ -309,7 +314,11 @@ void GrDrawTarget::setRenderTarget(GrRenderTarget* target) { fCurrDrawState.fRenderTarget = target; } -GrRenderTarget* GrDrawTarget::currentRenderTarget() const { +const GrRenderTarget* GrDrawTarget::getRenderTarget() const { + return fCurrDrawState.fRenderTarget; +} + +GrRenderTarget* GrDrawTarget::getRenderTarget() { return fCurrDrawState.fRenderTarget; } @@ -321,13 +330,12 @@ void GrDrawTarget::concatViewMatrix(const GrMatrix& matrix) { fCurrDrawState.fViewMatrix.preConcat(matrix); } -// Can't this just return a const& -void GrDrawTarget::getViewMatrix(GrMatrix* matrix) const { - *matrix = fCurrDrawState.fViewMatrix; +const GrMatrix& GrDrawTarget::getViewMatrix() const { + return fCurrDrawState.fViewMatrix; } bool GrDrawTarget::getViewInverse(GrMatrix* matrix) const { - // Mike: Can we cache this somewhere? + // Mike: Can we cache this somewhere? // Brian: Sure, do we use it often? GrMatrix inverse; @@ -366,10 +374,6 @@ void GrDrawTarget::disableState(uint32_t bits) { fCurrDrawState.fFlagBits &= ~(bits); } -void GrDrawTarget::setPointSize(float size) { - fCurrDrawState.fPointSize = size; -} - void GrDrawTarget::setBlendFunc(BlendCoeff srcCoef, BlendCoeff dstCoef) { fCurrDrawState.fSrcBlend = srcCoef; diff --git a/gpu/src/GrGpuGL.cpp b/gpu/src/GrGpuGL.cpp index 63cf237080..1dbc5fbb7e 100644 --- a/gpu/src/GrGpuGL.cpp +++ b/gpu/src/GrGpuGL.cpp @@ -415,7 +415,6 @@ void GrGpuGL::resetContextHelper() { fHWDrawState.fSrcBlend = (BlendCoeff)-1; fHWDrawState.fDstBlend = (BlendCoeff)-1; fHWDrawState.fColor = GrColor_ILLEGAL; - fHWDrawState.fPointSize = -1; fHWDrawState.fViewMatrix.setScale(GR_ScalarMax, GR_ScalarMax); // illegal @@ -501,6 +500,8 @@ GrRenderTarget* GrGpuGL::createRenderTargetFrom3DApiState() { this); } +/////////////////////////////////////////////////////////////////////////////// + // defines stencil formats from more to less preferred GLenum GR_GL_STENCIL_FORMAT_ARRAY[] = { GR_STENCIL_INDEX8, @@ -852,7 +853,7 @@ GrTexture* GrGpuGL::createTexture(const TextureDesc& desc, // bind the stencil to rt fbo if present, othewise the tex fbo GR_GLEXT(fExts, FramebufferRenderbuffer(GR_FRAMEBUFFER, GR_STENCIL_ATTACHMENT, - GR_RENDERBUFFER, + GR_RENDERBUFFER, rtIDs.fStencilRenderbufferID)); } status = GR_GLEXT(fExts, CheckFramebufferStatus(GR_FRAMEBUFFER)); diff --git a/gpu/src/GrGpuGL.h b/gpu/src/GrGpuGL.h index 611485df1d..dbc5de3acb 100644 --- a/gpu/src/GrGpuGL.h +++ b/gpu/src/GrGpuGL.h @@ -85,7 +85,7 @@ protected: void eraseStencil(uint32_t value, uint32_t mask); virtual void eraseStencilClip(); - + void setTextureUnit(int unitIdx); // flushes state that is common to fixed and programmable GL @@ -123,7 +123,7 @@ private: void notifyTextureDelete(GrGLTexture* texture); void notifyRenderTargetDelete(GrRenderTarget* renderTarget); void notifyTextureRemoveRenderTarget(GrGLTexture* texture); - + void setSpareTextureUnit(); void flushRenderTarget(); @@ -156,9 +156,9 @@ private: // ES requires an extension to support RGBA8 in RenderBufferStorage bool fRGBA8Renderbuffer; - + int fActiveTextureUnitIdx; - + typedef GrGpu INHERITED; }; diff --git a/gpu/src/GrGpuGLFixed.cpp b/gpu/src/GrGpuGLFixed.cpp index 99a593daaa..3fd8d5c866 100644 --- a/gpu/src/GrGpuGLFixed.cpp +++ b/gpu/src/GrGpuGLFixed.cpp @@ -26,26 +26,26 @@ struct GrGpuMatrix { GrScalar fMat[16]; - + void reset() { Gr_bzero(fMat, sizeof(fMat)); fMat[0] = fMat[5] = fMat[10] = fMat[15] = GR_Scalar1; } - + void set(const GrMatrix& m) { Gr_bzero(fMat, sizeof(fMat)); fMat[0] = m[GrMatrix::kScaleX]; fMat[4] = m[GrMatrix::kSkewX]; fMat[12] = m[GrMatrix::kTransX]; - + fMat[1] = m[GrMatrix::kSkewY]; fMat[5] = m[GrMatrix::kScaleY]; fMat[13] = m[GrMatrix::kTransY]; - + fMat[3] = m[GrMatrix::kPersp0]; fMat[7] = m[GrMatrix::kPersp1]; fMat[15] = m[GrMatrix::kPersp2]; - + fMat[10] = GR_Scalar1; // z-scale } }; @@ -74,7 +74,7 @@ void GrGpuGLFixed::resetContextHelper() { for (int s = 0; s < kNumStages; ++s) { setTextureUnit(s); - GR_GL(EnableClientState(GL_VERTEX_ARRAY)); + GR_GL(EnableClientState(GL_VERTEX_ARRAY)); GR_GL(TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE)); GR_GL(TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE)); GR_GL(TexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE0+s)); @@ -86,12 +86,12 @@ void GrGpuGLFixed::resetContextHelper() { GR_GL(TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA)); GR_GL(TexEnvi(GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_PREVIOUS)); GR_GL(TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA)); - - // color oprand0 changes between GL_SRC_COLR and GL_SRC_ALPHA depending - // upon whether we have a (premultiplied) RGBA texture or just an ALPHA + + // color oprand0 changes between GL_SRC_COLR and GL_SRC_ALPHA depending + // upon whether we have a (premultiplied) RGBA texture or just an ALPHA // texture, e.g.: //glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); - fHWRGBOperand0[s] = (TextureEnvRGBOperands) -1; + fHWRGBOperand0[s] = (TextureEnvRGBOperands) -1; } fHWGeometryState.fVertexLayout = 0; @@ -100,11 +100,13 @@ void GrGpuGLFixed::resetContextHelper() { GR_GL(DisableClientState(GL_TEXTURE_COORD_ARRAY)); GR_GL(ShadeModel(GL_FLAT)); GR_GL(DisableClientState(GL_COLOR_ARRAY)); - + + GR_GL(PointSize(1.f)); + GrGLClearErr(); fTextVerts = false; - fHWTextureOrientation = (GrGLTexture::Orientation)-1; // illegal + fHWTextureOrientation = (GrGLTexture::Orientation)-1; // illegal fBaseVertex = 0xffffffff; } @@ -112,25 +114,25 @@ void GrGpuGLFixed::resetContextHelper() { void GrGpuGLFixed::flushProjectionMatrix() { float mat[16]; Gr_bzero(mat, sizeof(mat)); - + GrAssert(NULL != fCurrDrawState.fRenderTarget); - + mat[0] = 2.f / fCurrDrawState.fRenderTarget->width(); mat[5] = -2.f / fCurrDrawState.fRenderTarget->height(); mat[10] = -1.f; mat[15] = 1; - + mat[12] = -1.f; mat[13] = 1.f; - + GR_GL(MatrixMode(GL_PROJECTION)); GR_GL(LoadMatrixf(mat)); } bool GrGpuGLFixed::flushGraphicsState(PrimitiveType type) { - + bool usingTextures[kNumStages]; - + for (int s = 0; s < kNumStages; ++s) { usingTextures[s] = VertexUsesStage(s, fGeometrySrc.fVertexLayout); @@ -139,16 +141,16 @@ bool GrGpuGLFixed::flushGraphicsState(PrimitiveType type) { return false; } } - + if (!flushGLStateCommon(type)) { return false; } - if (fRenderTargetChanged) { + if (fRenderTargetChanged) { flushProjectionMatrix(); fRenderTargetChanged = false; } - + for (int s = 0; s < kNumStages; ++s) { bool wasUsingTexture = VertexUsesStage(s, fHWGeometryState.fVertexLayout); if (usingTextures[s] != wasUsingTexture) { @@ -160,11 +162,11 @@ bool GrGpuGLFixed::flushGraphicsState(PrimitiveType type) { } } } - + uint32_t vertColor = (fGeometrySrc.fVertexLayout & kColor_VertexLayoutBit); - uint32_t prevVertColor = (fHWGeometryState.fVertexLayout & + uint32_t prevVertColor = (fHWGeometryState.fVertexLayout & kColor_VertexLayoutBit); - + if (vertColor != prevVertColor) { if (vertColor) { GR_GL(ShadeModel(GL_SMOOTH)); @@ -175,12 +177,7 @@ bool GrGpuGLFixed::flushGraphicsState(PrimitiveType type) { } } - if (kPoints_PrimitiveType == type && - fHWDrawState.fPointSize != fCurrDrawState.fPointSize) { - GR_GL(PointSize(fCurrDrawState.fPointSize)); - fHWDrawState.fPointSize = fCurrDrawState.fPointSize; - } - + if (!vertColor && fHWDrawState.fColor != fCurrDrawState.fColor) { GR_GL(Color4ub(GrColorUnpackR(fCurrDrawState.fColor), GrColorUnpackG(fCurrDrawState.fColor), @@ -194,25 +191,25 @@ bool GrGpuGLFixed::flushGraphicsState(PrimitiveType type) { if (usingTextures[s]) { GrGLTexture* texture = (GrGLTexture*)fCurrDrawState.fTextures[s]; if (NULL != texture) { - TextureEnvRGBOperands nextRGBOperand0 = - (texture->config() == GrTexture::kAlpha_8_PixelConfig) ? - kAlpha_TextureEnvRGBOperand : + TextureEnvRGBOperands nextRGBOperand0 = + (texture->config() == GrTexture::kAlpha_8_PixelConfig) ? + kAlpha_TextureEnvRGBOperand : kColor_TextureEnvRGBOperand; if (fHWRGBOperand0[s] != nextRGBOperand0) { setTextureUnit(s); - GR_GL(TexEnvi(GL_TEXTURE_ENV, + GR_GL(TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, - (nextRGBOperand0==kAlpha_TextureEnvRGBOperand) ? - GL_SRC_ALPHA : + (nextRGBOperand0==kAlpha_TextureEnvRGBOperand) ? + GL_SRC_ALPHA : GL_SRC_COLOR)); fHWRGBOperand0[s] = nextRGBOperand0; } - + if (fHWTextureOrientation != texture->orientation() || - fHWDrawState.fTextureMatrices[s] != + fHWDrawState.fTextureMatrices[s] != fCurrDrawState.fTextureMatrices[s]) { GrGpuMatrix glm; - if (GrGLTexture::kBottomUp_Orientation == + if (GrGLTexture::kBottomUp_Orientation == texture->orientation()) { GrMatrix m( GR_Scalar1, 0, 0, @@ -227,7 +224,7 @@ bool GrGpuGLFixed::flushGraphicsState(PrimitiveType type) { setTextureUnit(s); GR_GL(MatrixMode(GL_TEXTURE)); GR_GL(LoadMatrixf(glm.fMat)); - fHWDrawState.fTextureMatrices[s] = + fHWDrawState.fTextureMatrices[s] = fCurrDrawState.fTextureMatrices[s]; fHWTextureOrientation = texture->orientation(); } @@ -243,7 +240,7 @@ bool GrGpuGLFixed::flushGraphicsState(PrimitiveType type) { glm.set(fCurrDrawState.fViewMatrix); GR_GL(MatrixMode(GL_MODELVIEW)); GR_GL(LoadMatrixf(glm.fMat)); - fHWDrawState.fViewMatrix = + fHWDrawState.fViewMatrix = fCurrDrawState.fViewMatrix; } return true; @@ -253,49 +250,49 @@ void GrGpuGLFixed::setupGeometry(uint32_t startVertex, uint32_t startIndex, uint32_t vertexCount, uint32_t indexCount) { - + int newColorOffset; int newTexCoordOffsets[kNumStages]; - + GLsizei newStride = VertexSizeAndOffsetsByStage(fGeometrySrc.fVertexLayout, - newTexCoordOffsets, + newTexCoordOffsets, &newColorOffset); int oldColorOffset; int oldTexCoordOffsets[kNumStages]; GLsizei oldStride = VertexSizeAndOffsetsByStage(fHWGeometryState.fVertexLayout, - oldTexCoordOffsets, + oldTexCoordOffsets, &oldColorOffset); - + const GLvoid* posPtr = (GLvoid*)(newStride * startVertex); - + if (kBuffer_GeometrySrcType == fGeometrySrc.fVertexSrc) { GrAssert(NULL != fGeometrySrc.fVertexBuffer); GrAssert(!fGeometrySrc.fVertexBuffer->isLocked()); if (fHWGeometryState.fVertexBuffer != fGeometrySrc.fVertexBuffer) { - GrGLVertexBuffer* buf = + GrGLVertexBuffer* buf = (GrGLVertexBuffer*)fGeometrySrc.fVertexBuffer; GR_GL(BindBuffer(GL_ARRAY_BUFFER, buf->bufferID())); fHWGeometryState.fVertexBuffer = fGeometrySrc.fVertexBuffer; } - } else { + } else { if (kArray_GeometrySrcType == fGeometrySrc.fVertexSrc) { - posPtr = (void*)((intptr_t)fGeometrySrc.fVertexArray + + posPtr = (void*)((intptr_t)fGeometrySrc.fVertexArray + (intptr_t)posPtr); } else { GrAssert(kReserved_GeometrySrcType == fGeometrySrc.fVertexSrc); - posPtr = (void*)((intptr_t)fVertices.get() + (intptr_t)posPtr); + posPtr = (void*)((intptr_t)fVertices.get() + (intptr_t)posPtr); } if (NULL != fHWGeometryState.fVertexBuffer) { GR_GL(BindBuffer(GL_ARRAY_BUFFER, 0)); fHWGeometryState.fVertexBuffer = NULL; } } - + if (kBuffer_GeometrySrcType == fGeometrySrc.fIndexSrc) { GrAssert(NULL != fGeometrySrc.fIndexBuffer); GrAssert(!fGeometrySrc.fIndexBuffer->isLocked()); if (fHWGeometryState.fIndexBuffer != fGeometrySrc.fIndexBuffer) { - GrGLIndexBuffer* buf = + GrGLIndexBuffer* buf = (GrGLIndexBuffer*)fGeometrySrc.fIndexBuffer; GR_GL(BindBuffer(GL_ELEMENT_ARRAY_BUFFER, buf->bufferID())); fHWGeometryState.fIndexBuffer = fGeometrySrc.fIndexBuffer; @@ -304,29 +301,29 @@ void GrGpuGLFixed::setupGeometry(uint32_t startVertex, GR_GL(BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)); fHWGeometryState.fIndexBuffer = NULL; } - + GLenum scalarType; if (fGeometrySrc.fVertexLayout & kTextFormat_VertexLayoutBit) { scalarType = GrGLTextType; } else { scalarType = GrGLType; } - + bool baseChange = posPtr != fHWGeometryState.fPositionPtr; - bool scalarChange = + bool scalarChange = (GrGLTextType != GrGLType) && (kTextFormat_VertexLayoutBit & (fHWGeometryState.fVertexLayout ^ fGeometrySrc.fVertexLayout)); bool strideChange = newStride != oldStride; bool posChange = baseChange || scalarChange || strideChange; - + if (posChange) { GR_GL(VertexPointer(2, scalarType, newStride, posPtr)); fHWGeometryState.fPositionPtr = posPtr; } - + for (int s = 0; s < kNumStages; ++s) { - // need to enable array if tex coord offset is 0 + // need to enable array if tex coord offset is 0 // (using positions as coords) if (newTexCoordOffsets[s] >= 0) { GLvoid* texCoordPtr = (int8_t*)posPtr + newTexCoordOffsets[s]; @@ -343,7 +340,7 @@ void GrGpuGLFixed::setupGeometry(uint32_t startVertex, GR_GL(DisableClientState(GL_TEXTURE_COORD_ARRAY)); } } - + if (newColorOffset > 0) { GLvoid* colorPtr = (int8_t*)posPtr + newColorOffset; if (oldColorOffset <= 0) { @@ -355,7 +352,7 @@ void GrGpuGLFixed::setupGeometry(uint32_t startVertex, } else if (oldColorOffset > 0) { GR_GL(DisableClientState(GL_COLOR_ARRAY)); } - + fHWGeometryState.fVertexLayout = fGeometrySrc.fVertexLayout; } diff --git a/gpu/src/GrTextContext.cpp b/gpu/src/GrTextContext.cpp index 0a777d6cd8..59a907e49d 100644 --- a/gpu/src/GrTextContext.cpp +++ b/gpu/src/GrTextContext.cpp @@ -23,7 +23,7 @@ #include "GrTextStrike_impl.h" #include "GrFontScaler.h" -static const GrVertexLayout VLAYOUT = +static const GrVertexLayout VLAYOUT = GrDrawTarget::kTextFormat_VertexLayoutBit | GrDrawTarget::StageTexCoordVertexLayoutBit(0,0); @@ -57,7 +57,9 @@ void GrTextContext::flushGlyphs() { } } -GrTextContext::GrTextContext(GrContext* context, const GrMatrix* extMatrix) { +GrTextContext::GrTextContext(GrContext* context, + const GrPaint& paint, + const GrMatrix* extMatrix) : fPaint(paint) { fContext = context; fStrike = NULL; @@ -80,17 +82,17 @@ GrTextContext::GrTextContext(GrContext* context, const GrMatrix* extMatrix) { } } - fContext->getViewMatrix(&fOrigViewMatrix); - fContext->setViewMatrix(fExtMatrix); + fOrigViewMatrix = fContext->getMatrix(); + fContext->setMatrix(fExtMatrix); fVertices = NULL; fMaxVertices = 0; - fDrawTarget = fContext->getTextTarget(); + fDrawTarget = fContext->getTextTarget(fPaint); } GrTextContext::~GrTextContext() { this->flushGlyphs(); - fContext->setViewMatrix(fOrigViewMatrix); + fContext->setMatrix(fOrigViewMatrix); } void GrTextContext::flush() { @@ -161,12 +163,11 @@ void GrTextContext::drawPackedGlyph(GrGlyph::PackedID packed, glyph->fPath = path; } GrPath::Iter iter(*glyph->fPath); - bool useTexture = false; GrPoint translate; translate.set(GrFixedToScalar(vx - GrIntToFixed(glyph->fBounds.fLeft)), GrFixedToScalar(vy - GrIntToFixed(glyph->fBounds.fTop))); - fContext->drawPath(&iter, GrContext::kWinding_PathFill, - useTexture, &translate); + fContext->drawPath(fPaint, &iter, GrContext::kWinding_PathFill, + &translate); return; } @@ -196,7 +197,7 @@ HAS_ATLAS: if (flush) { this->flushGlyphs(); fContext->flushText(); - fDrawTarget = fContext->getTextTarget(); + fDrawTarget = fContext->getTextTarget(fPaint); fMaxVertices = kDefaultRequestedVerts; // ignore return, no point in flushing again. fDrawTarget->geometryHints(VLAYOUT, |