reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2010 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 10 | #include "GrTextContext.h" |
bsalomon@google.com | 86afc2a | 2011-02-16 16:12:19 +0000 | [diff] [blame] | 11 | #include "GrAtlas.h" |
| 12 | #include "GrContext.h" |
bsalomon@google.com | f4a9c82 | 2012-03-16 14:02:46 +0000 | [diff] [blame] | 13 | #include "GrDrawTarget.h" |
| 14 | #include "GrFontScaler.h" |
| 15 | #include "GrGpuVertex.h" |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 16 | #include "GrIndexBuffer.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 17 | #include "GrTextStrike.h" |
| 18 | #include "GrTextStrike_impl.h" |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 19 | #include "SkPath.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 20 | |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 21 | enum { |
bsalomon@google.com | 1ce49fc | 2012-09-18 14:14:49 +0000 | [diff] [blame] | 22 | |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 23 | kGlyphMaskStage = GrPaint::kTotalStages, |
| 24 | }; |
| 25 | |
| 26 | void GrTextContext::flushGlyphs() { |
tomhudson@google.com | cb325ce | 2012-07-11 14:41:19 +0000 | [diff] [blame] | 27 | if (NULL == fDrawTarget) { |
| 28 | return; |
| 29 | } |
| 30 | GrDrawState* drawState = fDrawTarget->drawState(); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 31 | if (fCurrVertex > 0) { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 32 | // setup our sampler state for our text texture/atlas |
bsalomon@google.com | 1ce49fc | 2012-09-18 14:14:49 +0000 | [diff] [blame] | 33 | drawState->sampler(kGlyphMaskStage)->reset(); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 34 | |
| 35 | GrAssert(GrIsALIGN4(fCurrVertex)); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 36 | GrAssert(fCurrTexture); |
bsalomon@google.com | 0e354aa | 2012-10-08 20:44:25 +0000 | [diff] [blame] | 37 | GrTextureParams params(SkShader::kRepeat_TileMode, false); |
bsalomon@google.com | 1ce49fc | 2012-09-18 14:14:49 +0000 | [diff] [blame] | 38 | drawState->createTextureEffect(kGlyphMaskStage, fCurrTexture, params); |
bsalomon@google.com | 080773c | 2011-03-15 19:09:25 +0000 | [diff] [blame] | 39 | |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 40 | if (!GrPixelConfigIsAlphaOnly(fCurrTexture->config())) { |
bsalomon@google.com | c7448ce | 2012-10-05 19:04:13 +0000 | [diff] [blame] | 41 | if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() || |
| 42 | kISA_GrBlendCoeff != fPaint.getDstBlendCoeff() || |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 43 | fPaint.hasColorStage()) { |
bsalomon@google.com | 080773c | 2011-03-15 19:09:25 +0000 | [diff] [blame] | 44 | GrPrintf("LCD Text will not draw correctly.\n"); |
| 45 | } |
| 46 | // setup blend so that we get mask * paintColor + (1-mask)*dstColor |
bsalomon@google.com | c7448ce | 2012-10-05 19:04:13 +0000 | [diff] [blame] | 47 | drawState->setBlendConstant(fPaint.getColor()); |
bsalomon@google.com | 4705954 | 2012-06-06 20:51:20 +0000 | [diff] [blame] | 48 | drawState->setBlendFunc(kConstC_GrBlendCoeff, kISC_GrBlendCoeff); |
bsalomon@google.com | 080773c | 2011-03-15 19:09:25 +0000 | [diff] [blame] | 49 | // don't modulate by the paint's color in the frag since we're |
| 50 | // already doing it via the blend const. |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 51 | drawState->setColor(0xffffffff); |
bsalomon@google.com | 080773c | 2011-03-15 19:09:25 +0000 | [diff] [blame] | 52 | } else { |
| 53 | // set back to normal in case we took LCD path previously. |
bsalomon@google.com | c7448ce | 2012-10-05 19:04:13 +0000 | [diff] [blame] | 54 | drawState->setBlendFunc(fPaint.getSrcBlendCoeff(), fPaint.getDstBlendCoeff()); |
| 55 | drawState->setColor(fPaint.getColor()); |
bsalomon@google.com | 080773c | 2011-03-15 19:09:25 +0000 | [diff] [blame] | 56 | } |
| 57 | |
bsalomon@google.com | 934c570 | 2012-03-20 21:17:58 +0000 | [diff] [blame] | 58 | int nGlyphs = fCurrVertex / 4; |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 59 | fDrawTarget->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); |
bsalomon@google.com | 4705954 | 2012-06-06 20:51:20 +0000 | [diff] [blame] | 60 | fDrawTarget->drawIndexedInstances(kTriangles_GrPrimitiveType, |
bsalomon@google.com | 934c570 | 2012-03-20 21:17:58 +0000 | [diff] [blame] | 61 | nGlyphs, |
| 62 | 4, 6); |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 63 | fDrawTarget->resetVertexSource(); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 64 | fVertices = NULL; |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 65 | fMaxVertices = 0; |
| 66 | fCurrVertex = 0; |
| 67 | GrSafeSetNull(fCurrTexture); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 68 | } |
tomhudson@google.com | cb325ce | 2012-07-11 14:41:19 +0000 | [diff] [blame] | 69 | drawState->disableStages(); |
| 70 | fDrawTarget = NULL; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 71 | } |
| 72 | |
bsalomon@google.com | 0e354aa | 2012-10-08 20:44:25 +0000 | [diff] [blame] | 73 | GrTextContext::GrTextContext(GrContext* context, const GrPaint& paint) : fPaint(paint) { |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 74 | fContext = context; |
bsalomon@google.com | f4a9c82 | 2012-03-16 14:02:46 +0000 | [diff] [blame] | 75 | fStrike = NULL; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 76 | |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 77 | fCurrTexture = NULL; |
| 78 | fCurrVertex = 0; |
| 79 | |
robertphillips@google.com | beb1af7 | 2012-07-26 18:52:16 +0000 | [diff] [blame] | 80 | const GrClipData* clipData = context->getClip(); |
| 81 | |
robertphillips@google.com | 641f8b1 | 2012-07-31 19:15:58 +0000 | [diff] [blame] | 82 | GrRect devConservativeBound; |
| 83 | clipData->fClipStack->getConservativeBounds( |
| 84 | -clipData->fOrigin.fX, |
| 85 | -clipData->fOrigin.fY, |
| 86 | context->getRenderTarget()->width(), |
| 87 | context->getRenderTarget()->height(), |
| 88 | &devConservativeBound); |
robertphillips@google.com | beb1af7 | 2012-07-26 18:52:16 +0000 | [diff] [blame] | 89 | |
robertphillips@google.com | 641f8b1 | 2012-07-31 19:15:58 +0000 | [diff] [blame] | 90 | devConservativeBound.roundOut(&fClipRect); |
robertphillips@google.com | beb1af7 | 2012-07-26 18:52:16 +0000 | [diff] [blame] | 91 | |
bsalomon@google.com | 7d34d2e | 2011-01-24 17:41:47 +0000 | [diff] [blame] | 92 | // save the context's original matrix off and restore in destructor |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 93 | // this must be done before getTextTarget. |
bsalomon@google.com | 5782d71 | 2011-01-21 21:03:59 +0000 | [diff] [blame] | 94 | fOrigViewMatrix = fContext->getMatrix(); |
bsalomon@google.com | 0e354aa | 2012-10-08 20:44:25 +0000 | [diff] [blame] | 95 | fContext->setIdentityMatrix(); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 96 | |
bsalomon@google.com | 3914958 | 2011-06-13 21:55:32 +0000 | [diff] [blame] | 97 | /* |
| 98 | We need to call preConcatMatrix with our viewmatrix's inverse, for each |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 99 | texture and mask in the paint. However, computing the inverse can be |
bsalomon@google.com | 3914958 | 2011-06-13 21:55:32 +0000 | [diff] [blame] | 100 | expensive, and its possible we may not have any textures or masks, so these |
| 101 | two loops are written such that we only compute the inverse (once) if we |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 102 | need it. We do this on our copy of the paint rather than directly on the |
bsalomon@google.com | 3914958 | 2011-06-13 21:55:32 +0000 | [diff] [blame] | 103 | draw target because we re-provide the paint to the context when we have |
| 104 | to flush our glyphs or draw a glyph as a path midstream. |
| 105 | */ |
| 106 | bool invVMComputed = false; |
| 107 | GrMatrix invVM; |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 108 | for (int t = 0; t < GrPaint::kMaxColorStages; ++t) { |
| 109 | if (fPaint.isColorStageEnabled(t)) { |
bsalomon@google.com | 3914958 | 2011-06-13 21:55:32 +0000 | [diff] [blame] | 110 | if (invVMComputed || fOrigViewMatrix.invert(&invVM)) { |
| 111 | invVMComputed = true; |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 112 | fPaint.colorSampler(t)->preConcatMatrix(invVM); |
bsalomon@google.com | 3914958 | 2011-06-13 21:55:32 +0000 | [diff] [blame] | 113 | } |
| 114 | } |
| 115 | } |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 116 | for (int m = 0; m < GrPaint::kMaxCoverageStages; ++m) { |
| 117 | if (fPaint.isCoverageStageEnabled(m)) { |
bsalomon@google.com | 3914958 | 2011-06-13 21:55:32 +0000 | [diff] [blame] | 118 | if (invVMComputed || fOrigViewMatrix.invert(&invVM)) { |
| 119 | invVMComputed = true; |
bsalomon@google.com | 88becf4 | 2012-10-05 14:54:42 +0000 | [diff] [blame] | 120 | fPaint.coverageSampler(m)->preConcatMatrix(invVM); |
bsalomon@google.com | 3914958 | 2011-06-13 21:55:32 +0000 | [diff] [blame] | 121 | } |
| 122 | } |
| 123 | } |
| 124 | |
tomhudson@google.com | cb325ce | 2012-07-11 14:41:19 +0000 | [diff] [blame] | 125 | fDrawTarget = NULL; |
bsalomon@google.com | 7d34d2e | 2011-01-24 17:41:47 +0000 | [diff] [blame] | 126 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 127 | fVertices = NULL; |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 128 | fMaxVertices = 0; |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 129 | |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 130 | fVertexLayout = |
bsalomon@google.com | 26c2d0a | 2011-05-17 20:15:30 +0000 | [diff] [blame] | 131 | GrDrawTarget::kTextFormat_VertexLayoutBit | |
| 132 | GrDrawTarget::StageTexCoordVertexLayoutBit(kGlyphMaskStage, 0); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 133 | } |
| 134 | |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 135 | GrTextContext::~GrTextContext() { |
| 136 | this->flushGlyphs(); |
| 137 | if (fDrawTarget) { |
| 138 | fDrawTarget->drawState()->disableStages(); |
| 139 | } |
bsalomon@google.com | 5782d71 | 2011-01-21 21:03:59 +0000 | [diff] [blame] | 140 | fContext->setMatrix(fOrigViewMatrix); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 141 | } |
| 142 | |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 143 | void GrTextContext::flush() { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 144 | this->flushGlyphs(); |
| 145 | } |
| 146 | |
| 147 | static inline void setRectFan(GrGpuTextVertex v[4], int l, int t, int r, int b, |
| 148 | int stride) { |
| 149 | v[0 * stride].setI(l, t); |
| 150 | v[1 * stride].setI(l, b); |
| 151 | v[2 * stride].setI(r, b); |
| 152 | v[3 * stride].setI(r, t); |
| 153 | } |
| 154 | |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 155 | void GrTextContext::drawPackedGlyph(GrGlyph::PackedID packed, |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 156 | GrFixed vx, GrFixed vy, |
| 157 | GrFontScaler* scaler) { |
| 158 | if (NULL == fStrike) { |
| 159 | fStrike = fContext->getFontCache()->getStrike(scaler); |
| 160 | } |
| 161 | |
| 162 | GrGlyph* glyph = fStrike->getGlyph(packed, scaler); |
| 163 | if (NULL == glyph || glyph->fBounds.isEmpty()) { |
| 164 | return; |
| 165 | } |
| 166 | |
| 167 | vx += GrIntToFixed(glyph->fBounds.fLeft); |
| 168 | vy += GrIntToFixed(glyph->fBounds.fTop); |
| 169 | |
| 170 | // keep them as ints until we've done the clip-test |
| 171 | GrFixed width = glyph->fBounds.width(); |
| 172 | GrFixed height = glyph->fBounds.height(); |
| 173 | |
| 174 | // check if we clipped out |
| 175 | if (true || NULL == glyph->fAtlas) { |
| 176 | int x = vx >> 16; |
| 177 | int y = vy >> 16; |
| 178 | if (fClipRect.quickReject(x, y, x + width, y + height)) { |
| 179 | // Gr_clz(3); // so we can set a break-point in the debugger |
| 180 | return; |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | if (NULL == glyph->fAtlas) { |
| 185 | if (fStrike->getGlyphAtlas(glyph, scaler)) { |
| 186 | goto HAS_ATLAS; |
| 187 | } |
reed@google.com | 0ebe81a | 2011-04-04 20:06:59 +0000 | [diff] [blame] | 188 | |
| 189 | // before we purge the cache, we must flush any accumulated draws |
| 190 | this->flushGlyphs(); |
bsalomon@google.com | 193395c | 2012-03-30 17:35:12 +0000 | [diff] [blame] | 191 | fContext->flush(); |
reed@google.com | 313e403 | 2010-12-22 22:16:59 +0000 | [diff] [blame] | 192 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 193 | // try to purge |
| 194 | fContext->getFontCache()->purgeExceptFor(fStrike); |
| 195 | if (fStrike->getGlyphAtlas(glyph, scaler)) { |
| 196 | goto HAS_ATLAS; |
| 197 | } |
| 198 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 199 | if (NULL == glyph->fPath) { |
tomhudson@google.com | c377baf | 2012-07-09 20:17:56 +0000 | [diff] [blame] | 200 | SkPath* path = SkNEW(SkPath); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 201 | if (!scaler->getGlyphPath(glyph->glyphID(), path)) { |
| 202 | // flag the glyph as being dead? |
| 203 | delete path; |
| 204 | return; |
| 205 | } |
| 206 | glyph->fPath = path; |
| 207 | } |
reed@google.com | 07f3ee1 | 2011-05-16 17:21:57 +0000 | [diff] [blame] | 208 | |
bsalomon@google.com | 3cbaa2d | 2012-10-12 14:51:52 +0000 | [diff] [blame] | 209 | GrContext::AutoMatrix am; |
bsalomon@google.com | 0f11e1a | 2012-10-08 14:48:36 +0000 | [diff] [blame] | 210 | GrMatrix translate; |
| 211 | translate.setTranslate(GrFixedToScalar(vx - GrIntToFixed(glyph->fBounds.fLeft)), |
| 212 | GrFixedToScalar(vy - GrIntToFixed(glyph->fBounds.fTop))); |
bsalomon@google.com | 3cbaa2d | 2012-10-12 14:51:52 +0000 | [diff] [blame] | 213 | GrPaint tmpPaint(fPaint); |
| 214 | am.setPreConcat(fContext, translate, &tmpPaint); |
| 215 | fContext->drawPath(tmpPaint, *glyph->fPath, kWinding_GrPathFill); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 216 | return; |
| 217 | } |
| 218 | |
| 219 | HAS_ATLAS: |
| 220 | GrAssert(glyph->fAtlas); |
| 221 | |
| 222 | // now promote them to fixed |
| 223 | width = GrIntToFixed(width); |
| 224 | height = GrIntToFixed(height); |
| 225 | |
| 226 | GrTexture* texture = glyph->fAtlas->texture(); |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 227 | GrAssert(texture); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 228 | |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 229 | if (fCurrTexture != texture || fCurrVertex + 4 > fMaxVertices) { |
| 230 | this->flushGlyphs(); |
| 231 | fCurrTexture = texture; |
| 232 | fCurrTexture->ref(); |
| 233 | } |
| 234 | |
| 235 | if (NULL == fVertices) { |
| 236 | // If we need to reserve vertices allow the draw target to suggest |
| 237 | // a number of verts to reserve and whether to perform a flush. |
| 238 | fMaxVertices = kMinRequestedVerts; |
tomhudson@google.com | cb325ce | 2012-07-11 14:41:19 +0000 | [diff] [blame] | 239 | bool flush = (NULL != fDrawTarget) && |
| 240 | fDrawTarget->geometryHints(fVertexLayout, |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 241 | &fMaxVertices, |
| 242 | NULL); |
| 243 | if (flush) { |
| 244 | this->flushGlyphs(); |
| 245 | fContext->flush(); |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 246 | } |
tomhudson@google.com | cb325ce | 2012-07-11 14:41:19 +0000 | [diff] [blame] | 247 | fDrawTarget = fContext->getTextTarget(fPaint); |
| 248 | fMaxVertices = kDefaultRequestedVerts; |
| 249 | // ignore return, no point in flushing again. |
| 250 | fDrawTarget->geometryHints(fVertexLayout, |
| 251 | &fMaxVertices, |
| 252 | NULL); |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 253 | |
| 254 | int maxQuadVertices = 4 * fContext->getQuadIndexBuffer()->maxQuads(); |
| 255 | if (fMaxVertices < kMinRequestedVerts) { |
| 256 | fMaxVertices = kDefaultRequestedVerts; |
| 257 | } else if (fMaxVertices > maxQuadVertices) { |
| 258 | // don't exceed the limit of the index buffer |
| 259 | fMaxVertices = maxQuadVertices; |
| 260 | } |
| 261 | bool success = fDrawTarget->reserveVertexAndIndexSpace( |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 262 | fVertexLayout, |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 263 | fMaxVertices, |
| 264 | 0, |
| 265 | GrTCast<void**>(&fVertices), |
| 266 | NULL); |
| 267 | GrAlwaysAssert(success); |
| 268 | } |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 269 | |
| 270 | GrFixed tx = GrIntToFixed(glyph->fAtlasLocation.fX); |
| 271 | GrFixed ty = GrIntToFixed(glyph->fAtlasLocation.fY); |
| 272 | |
bsalomon@google.com | 2717d56 | 2012-05-07 19:10:52 +0000 | [diff] [blame] | 273 | #if GR_TEXT_SCALAR_IS_USHORT |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 274 | int x = vx >> 16; |
| 275 | int y = vy >> 16; |
| 276 | int w = width >> 16; |
| 277 | int h = height >> 16; |
| 278 | |
| 279 | setRectFan(&fVertices[2*fCurrVertex], x, y, x + w, y + h, 2); |
| 280 | setRectFan(&fVertices[2*fCurrVertex+1], |
| 281 | texture->normalizeFixedX(tx), |
| 282 | texture->normalizeFixedY(ty), |
| 283 | texture->normalizeFixedX(tx + width), |
| 284 | texture->normalizeFixedY(ty + height), |
| 285 | 2); |
| 286 | #else |
| 287 | fVertices[2*fCurrVertex].setXRectFan(vx, vy, vx + width, vy + height, |
| 288 | 2 * sizeof(GrGpuTextVertex)); |
| 289 | fVertices[2*fCurrVertex+1].setXRectFan(texture->normalizeFixedX(tx), |
| 290 | texture->normalizeFixedY(ty), |
| 291 | texture->normalizeFixedX(tx + width), |
| 292 | texture->normalizeFixedY(ty + height), |
| 293 | 2 * sizeof(GrGpuTextVertex)); |
| 294 | #endif |
| 295 | fCurrVertex += 4; |
| 296 | } |
tomhudson@google.com | 375ff85 | 2012-06-29 18:37:57 +0000 | [diff] [blame] | 297 | |