diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-06-13 21:55:32 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-06-13 21:55:32 +0000 |
commit | 3914958a49ee089ddeb04acc16373aae8bc2eaf7 (patch) | |
tree | 86785f882cb8472c819b5123e862fef5e58109f7 /gpu | |
parent | 79d2dbed5a08e0d3f65646d52b4bb884cd0af9b5 (diff) |
Fix text-as-path with skshader on gpu
Review URL: http://codereview.appspot.com/4576057/
git-svn-id: http://skia.googlecode.com/svn/trunk@1575 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/include/GrTextContext.h | 1 | ||||
-rw-r--r-- | gpu/src/GrTextContext.cpp | 34 |
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() { |