aboutsummaryrefslogtreecommitdiffhomepage
path: root/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'gpu')
-rw-r--r--gpu/include/GrTextContext.h1
-rw-r--r--gpu/src/GrTextContext.cpp34
2 files changed, 29 insertions, 6 deletions
diff --git a/gpu/include/GrTextContext.h b/gpu/include/GrTextContext.h
index b7a690e3fe..c4181c6f4c 100644
--- a/gpu/include/GrTextContext.h
+++ b/gpu/include/GrTextContext.h
@@ -51,6 +51,7 @@ private:
GrTextStrike* fStrike;
inline void flushGlyphs();
+ void setupDrawTarget();
enum {
kMinRequestedGlyphs = 1,
diff --git a/gpu/src/GrTextContext.cpp b/gpu/src/GrTextContext.cpp
index 2aacfa25ad..41e4a85fb6 100644
--- a/gpu/src/GrTextContext.cpp
+++ b/gpu/src/GrTextContext.cpp
@@ -115,6 +115,34 @@ GrTextContext::GrTextContext(GrContext* context,
fOrigViewMatrix = fContext->getMatrix();
fContext->setMatrix(fExtMatrix);
+ /*
+ We need to call preConcatMatrix with our viewmatrix's inverse, for each
+ texture and mask in the paint. However, computing the inverse can be
+ expensive, and its possible we may not have any textures or masks, so these
+ two loops are written such that we only compute the inverse (once) if we
+ need it. We do this on our copy of the paint rather than directly on the
+ draw target because we re-provide the paint to the context when we have
+ to flush our glyphs or draw a glyph as a path midstream.
+ */
+ bool invVMComputed = false;
+ GrMatrix invVM;
+ for (int t = 0; t < GrPaint::kMaxTextures; ++t) {
+ if (NULL != fPaint.getTexture(t)) {
+ if (invVMComputed || fOrigViewMatrix.invert(&invVM)) {
+ invVMComputed = true;
+ fPaint.getTextureSampler(t)->preConcatMatrix(invVM);
+ }
+ }
+ }
+ for (int m = 0; m < GrPaint::kMaxMasks; ++m) {
+ if (NULL != fPaint.getMask(m)) {
+ if (invVMComputed || fOrigViewMatrix.invert(&invVM)) {
+ invVMComputed = true;
+ fPaint.getMaskSampler(m)->preConcatMatrix(invVM);
+ }
+ }
+ }
+
fDrawTarget = fContext->getTextTarget(fPaint);
fVertices = NULL;
@@ -126,11 +154,6 @@ GrTextContext::GrTextContext(GrContext* context,
int stageMask = paint.getActiveStageMask();
if (stageMask) {
- GrMatrix inverseViewMatrix;
- if (fOrigViewMatrix.invert(&inverseViewMatrix)) {
- fDrawTarget->preConcatSamplerMatrices(stageMask,
- inverseViewMatrix);
- }
for (int i = 0; i < GrPaint::kTotalStages; ++i) {
if ((1 << i) & stageMask) {
fVertexLayout |=
@@ -139,7 +162,6 @@ GrTextContext::GrTextContext(GrContext* context,
}
}
}
-
}
GrTextContext::~GrTextContext() {