}
void GrGpuGL::eraseColor(GrColor color) {
+ if (NULL == fCurrDrawState.fRenderTarget) {
+ return;
+ }
flushRenderTarget();
if (fHWBounds.fScissorEnabled) {
GR_GL(Disable(GL_SCISSOR_TEST));
+ fHWBounds.fScissorEnabled = false;
}
GR_GL(ColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE));
GR_GL(ClearColor(GrColorUnpackR(color)/255.f,
GrColorUnpackB(color)/255.f,
GrColorUnpackA(color)/255.f));
GR_GL(Clear(GL_COLOR_BUFFER_BIT));
- fHWBounds.fScissorEnabled = false;
fWriteMaskChanged = true;
}
void GrGpuGL::eraseStencil(uint32_t value, uint32_t mask) {
+ if (NULL == fCurrDrawState.fRenderTarget) {
+ return;
+ }
flushRenderTarget();
if (fHWBounds.fScissorEnabled) {
GR_GL(Disable(GL_SCISSOR_TEST));
+ fHWBounds.fScissorEnabled = false;
}
GR_GL(StencilMask(mask));
GR_GL(ClearStencil(value));
GR_GL(Clear(GL_STENCIL_BUFFER_BIT));
- fHWBounds.fScissorEnabled = false;
fWriteMaskChanged = true;
}
return (x >> 8) | (x << 24);
}
+static uint32_t rol(uint32_t x) {
+ return (x << 8) | (x >> 24);
+}
+
GrGpuGLShaders2::ProgramCache::HashKey::HashKey(const ProgramDesc& desc) {
fDesc = desc;
// if you change the size of the desc, need to update the hash function
- GR_STATIC_ASSERT(8 == sizeof(ProgramDesc));
+ GR_STATIC_ASSERT(12 == sizeof(ProgramDesc));
uint32_t* d = (uint32_t*) &fDesc;
- fHash = d[0] ^ ror(d[1]);
+ fHash = d[0] ^ ror(d[1]) ^ rol(d[2]);
}
bool GrGpuGLShaders2::ProgramCache::HashKey::EQ(const Entry& entry,
return fHash;
}
-
struct GrGpuGLShaders2::ShaderCodeSegments {
GrSStringBuilder<256> fVSUnis;
GrSStringBuilder<256> fVSAttrs;
#include "GrTextStrike_impl.h"
#include "GrFontScaler.h"
-static const GrVertexLayout VLAYOUT =
- GrDrawTarget::kTextFormat_VertexLayoutBit |
- GrDrawTarget::StageTexCoordVertexLayoutBit(0,0);
+static const int TEXT_STAGE = 1;
+
+static const GrVertexLayout BASE_VLAYOUT =
+ GrDrawTarget::kTextFormat_VertexLayoutBit |
+ GrDrawTarget::StageTexCoordVertexLayoutBit(TEXT_STAGE,0);
void GrTextContext::flushGlyphs() {
if (fCurrVertex > 0) {
GrSamplerState sampler(GrSamplerState::kRepeat_WrapMode,
GrSamplerState::kRepeat_WrapMode,
!fExtMatrix.isIdentity());
- fDrawTarget->setSamplerState(0, sampler);
+ fDrawTarget->setSamplerState(TEXT_STAGE, sampler);
GrAssert(GrIsALIGN4(fCurrVertex));
int nIndices = fCurrVertex + (fCurrVertex >> 1);
GrAssert(fCurrTexture);
- fDrawTarget->setTexture(0, fCurrTexture);
- fDrawTarget->setTextureMatrix(0, GrMatrix::I());
+ fDrawTarget->setTexture(TEXT_STAGE, fCurrTexture);
+ fDrawTarget->setTextureMatrix(TEXT_STAGE, GrMatrix::I());
fDrawTarget->setIndexSourceToBuffer(fContext->quadIndexBuffer());
fDrawTarget->drawIndexed(GrDrawTarget::kTriangles_PrimitiveType,
0, 0, fCurrVertex, nIndices);
-
fDrawTarget->releaseReservedGeometry();
fVertices = NULL;
fMaxVertices = 0;
}
}
+ // save the context's original matrix off and restore in destructor
+ // this must be done before getTextTarget.
fOrigViewMatrix = fContext->getMatrix();
fContext->setMatrix(fExtMatrix);
+ fVertexLayout = BASE_VLAYOUT;
+ if (NULL != paint.getTexture()) {
+ fVertexLayout |= GrDrawTarget::StagePosAsTexCoordVertexLayoutBit(0);
+ GrMatrix inverseViewMatrix;
+ if (fOrigViewMatrix.invert(&inverseViewMatrix)) {
+ fPaint.fTextureMatrix.preConcat(inverseViewMatrix);
+ }
+ }
+
fVertices = NULL;
fMaxVertices = 0;
fDrawTarget = fContext->getTextTarget(fPaint);
// If we need to reserve vertices allow the draw target to suggest
// a number of verts to reserve and whether to perform a flush.
fMaxVertices = kMinRequestedVerts;
- bool flush = fDrawTarget->geometryHints(VLAYOUT,
+ bool flush = fDrawTarget->geometryHints(fVertexLayout,
&fMaxVertices,
NULL);
if (flush) {
fDrawTarget = fContext->getTextTarget(fPaint);
fMaxVertices = kDefaultRequestedVerts;
// ignore return, no point in flushing again.
- fDrawTarget->geometryHints(VLAYOUT,
+ fDrawTarget->geometryHints(fVertexLayout,
&fMaxVertices,
NULL);
}
// don't exceed the limit of the index buffer
fMaxVertices = (fContext->maxQuadsInIndexBuffer() * 4);
}
- bool success = fDrawTarget->reserveAndLockGeometry(VLAYOUT,
+ bool success = fDrawTarget->reserveAndLockGeometry(fVertexLayout,
fMaxVertices, 0,
GrTCast<void**>(&fVertices),
NULL);