Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(608)

Side by Side Diff: src/gpu/GrAADistanceFieldPathRenderer.cpp

Issue 920333003: Revert of Use uint16s for texture coordinates when rendering text. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/gpu/GrTypesPriv.h ('k') | src/gpu/GrBitmapTextContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrAADistanceFieldPathRenderer.h" 9 #include "GrAADistanceFieldPathRenderer.h"
10 10
11 #include "GrAtlas.h" 11 #include "GrAtlas.h"
12 #include "GrContext.h" 12 #include "GrContext.h"
13 #include "GrPipelineBuilder.h" 13 #include "GrPipelineBuilder.h"
14 #include "GrSurfacePriv.h" 14 #include "GrSurfacePriv.h"
15 #include "GrSWMaskHelper.h" 15 #include "GrSWMaskHelper.h"
16 #include "GrTexturePriv.h" 16 #include "GrTexturePriv.h"
17 #include "effects/GrDistanceFieldTextureEffect.h" 17 #include "effects/GrDistanceFieldTextureEffect.h"
18 18
19 #include "SkDistanceFieldGen.h" 19 #include "SkDistanceFieldGen.h"
20 #include "SkRTConf.h" 20 #include "SkRTConf.h"
21 21
22 #define ATLAS_TEXTURE_WIDTH 1024 22 #define ATLAS_TEXTURE_WIDTH 1024
23 #define ATLAS_TEXTURE_HEIGHT 2048 23 #define ATLAS_TEXTURE_HEIGHT 2048
24 #define PLOT_WIDTH 256 24 #define PLOT_WIDTH 256
25 #define PLOT_HEIGHT 256 25 #define PLOT_HEIGHT 256
26 26
27 #define NUM_PLOTS_X (ATLAS_TEXTURE_WIDTH / PLOT_WIDTH) 27 #define NUM_PLOTS_X (ATLAS_TEXTURE_WIDTH / PLOT_WIDTH)
28 #define NUM_PLOTS_Y (ATLAS_TEXTURE_HEIGHT / PLOT_HEIGHT) 28 #define NUM_PLOTS_Y (ATLAS_TEXTURE_HEIGHT / PLOT_HEIGHT)
29 29
30 SK_CONF_DECLARE(bool, c_DumpPathCache, "gpu.dumpPathCache", false, 30 SK_CONF_DECLARE(bool, c_DumpPathCache, "gpu.dumpPathCache", false,
31 "Dump the contents of the path cache before every purge."); 31 "Dump the contents of the path cache before every purge.");
32 32
33 #ifdef DF_PATH_TRACKING 33 #ifdef DF_PATH_TRACKING
34 static int g_NumCachedPaths = 0; 34 static int g_NumCachedPaths = 0;
35 static int g_NumFreedPaths = 0; 35 static int g_NumFreedPaths = 0;
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 params, 335 params,
336 flags, 336 flags,
337 false)); 337 false));
338 fEffectFlags = flags; 338 fEffectFlags = flags;
339 } 339 }
340 340
341 void* vertices = NULL; 341 void* vertices = NULL;
342 bool success = target->reserveVertexAndIndexSpace(4, 342 bool success = target->reserveVertexAndIndexSpace(4,
343 fCachedGeometryProcessor-> getVertexStride(), 343 fCachedGeometryProcessor-> getVertexStride(),
344 0, &vertices, NULL); 344 0, &vertices, NULL);
345 SkASSERT(fCachedGeometryProcessor->getVertexStride() == sizeof(SkPoint) + si zeof(SkIPoint16)); 345 SkASSERT(fCachedGeometryProcessor->getVertexStride() == 2 * sizeof(SkPoint)) ;
346 GrAlwaysAssert(success); 346 GrAlwaysAssert(success);
347 347
348 SkScalar dx = pathData->fBounds.fLeft; 348 SkScalar dx = pathData->fBounds.fLeft;
349 SkScalar dy = pathData->fBounds.fTop; 349 SkScalar dy = pathData->fBounds.fTop;
350 // need to compute integer sizes for the glyph because we're using 350 SkScalar width = pathData->fBounds.width();
351 // uint16_t tex coords and they need to lie on integer texel bounds 351 SkScalar height = pathData->fBounds.height();
352 int iwidth = SkScalarCeilToInt(pathData->fBounds.width());
353 int iheight = SkScalarCeilToInt(pathData->fBounds.height());
354 // the quad rect before we scale needs to be the same size as the path data in the atlas
355 SkScalar width = SkIntToScalar(iwidth);
356 SkScalar height = SkIntToScalar(iheight);
357 352
358 SkScalar invScale = 1.0f/pathData->fScale; 353 SkScalar invScale = 1.0f/pathData->fScale;
359 dx *= invScale; 354 dx *= invScale;
360 dy *= invScale; 355 dy *= invScale;
361 width *= invScale; 356 width *= invScale;
362 height *= invScale; 357 height *= invScale;
363 358
364 int u0 = pathData->fAtlasLocation.fX; 359 SkFixed tx = SkIntToFixed(pathData->fAtlasLocation.fX);
365 int v0 = pathData->fAtlasLocation.fY; 360 SkFixed ty = SkIntToFixed(pathData->fAtlasLocation.fY);
366 int u1 = u0 + iwidth; 361 SkFixed tw = SkScalarToFixed(pathData->fBounds.width());
367 int v1 = v0 + iheight; 362 SkFixed th = SkScalarToFixed(pathData->fBounds.height());
363
368 // vertex positions 364 // vertex positions
369 SkRect r = SkRect::MakeXYWH(dx, dy, width, height); 365 SkRect r = SkRect::MakeXYWH(dx, dy, width, height);
370 size_t vertSize = sizeof(SkPoint) + sizeof(SkIPoint16); 366 size_t vertSize = 2 * sizeof(SkPoint);
371 SkPoint* positions = reinterpret_cast<SkPoint*>(vertices); 367 SkPoint* positions = reinterpret_cast<SkPoint*>(vertices);
372 positions->setRectFan(r.left(), r.top(), r.right(), r.bottom(), vertSize); 368 positions->setRectFan(r.left(), r.top(), r.right(), r.bottom(), vertSize);
373 369
374 // vertex texture coords 370 // vertex texture coords
375 intptr_t textureCoords = reinterpret_cast<intptr_t>(positions) + vertSize - sizeof(SkIPoint16); 371 intptr_t intPtr = reinterpret_cast<intptr_t>(positions);
376 ((SkIPoint16*)(textureCoords + 0 * vertSize))->set(u0, v0); 372 SkPoint* textureCoords = reinterpret_cast<SkPoint*>(intPtr + vertSize - size of(SkPoint));
377 ((SkIPoint16*)(textureCoords + 1 * vertSize))->set(u0, v1); 373 textureCoords->setRectFan(SkFixedToFloat(texture->texturePriv().normalizeFix edX(tx)),
378 ((SkIPoint16*)(textureCoords + 2 * vertSize))->set(u1, v1); 374 SkFixedToFloat(texture->texturePriv().normalizeFix edY(ty)),
379 ((SkIPoint16*)(textureCoords + 3 * vertSize))->set(u1, v0); 375 SkFixedToFloat(texture->texturePriv().normalizeFix edX(tx + tw)),
376 SkFixedToFloat(texture->texturePriv().normalizeFix edY(ty + th)),
377 vertSize);
380 378
381 viewMatrix.mapRect(&r); 379 viewMatrix.mapRect(&r);
382 target->setIndexSourceToBuffer(fContext->getQuadIndexBuffer()); 380 target->setIndexSourceToBuffer(fContext->getQuadIndexBuffer());
383 target->drawIndexedInstances(pipelineBuilder, fCachedGeometryProcessor.get() , 381 target->drawIndexedInstances(pipelineBuilder, fCachedGeometryProcessor.get() ,
384 kTriangles_GrPrimitiveType, 1, 4, 6, &r); 382 kTriangles_GrPrimitiveType, 1, 4, 6, &r);
385 target->resetVertexSource(); 383 target->resetVertexSource();
386 384
387 return true; 385 return true;
388 } 386 }
389 387
OLDNEW
« no previous file with comments | « include/gpu/GrTypesPriv.h ('k') | src/gpu/GrBitmapTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698