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

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

Issue 787873002: Use threshold of 1 texture coord value per pixel w/ nearest neighbor. (Closed) Base URL: https://skia.googlesource.com/skia.git@matrix_prec
Patch Set: update comments Created 6 years 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 | « src/effects/gradients/SkGradientShader.cpp ('k') | src/gpu/effects/GrSingleTextureEffect.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 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrCoordTransform.h" 8 #include "GrCoordTransform.h"
9 #include "GrContext.h" 9 #include "GrContext.h"
10 #include "GrDrawTargetCaps.h" 10 #include "GrDrawTargetCaps.h"
11 #include "GrGpu.h" 11 #include "GrGpu.h"
12 12
13 void GrCoordTransform::reset(GrCoordSet sourceCoords, const SkMatrix& m, const G rTexture* texture) { 13 void GrCoordTransform::reset(GrCoordSet sourceCoords, const SkMatrix& m, const G rTexture* texture,
14 GrTextureParams::FilterMode filter) {
14 SkASSERT(texture); 15 SkASSERT(texture);
15 SkASSERT(!fInProcessor); 16 SkASSERT(!fInProcessor);
16 17
17 fSourceCoords = sourceCoords; 18 fSourceCoords = sourceCoords;
18 fMatrix = m; 19 fMatrix = m;
19 fReverseY = kBottomLeft_GrSurfaceOrigin == texture->origin(); 20 fReverseY = kBottomLeft_GrSurfaceOrigin == texture->origin();
20 21
21 // Always start at kDefault. Then if precisions differ we see if the precisi on needs to be 22 // Always start at kDefault. Then if precisions differ we see if the precisi on needs to be
22 // increased. Our rule is that we want at least 4 subpixel values in the rep resentation for 23 // increased. Our rule is that we want at least 4 subpixel values in the rep resentation for
23 // coords between 0 to 1. Note that this still might not be enough when draw ing with repeat 24 // coords between 0 to 1 when bi- or tri-lerping and 1 value when nearest fi ltering. Note that
24 // or mirror-repeat modes but that case can be arbitrarily bad. 25 // this still might not be enough when drawing with repeat or mirror-repeat modes but that case
26 // can be arbitrarily bad.
27 int subPixelThresh = filter > GrTextureParams::kNone_FilterMode ? 4 : 1;
25 fPrecision = kDefault_GrSLPrecision; 28 fPrecision = kDefault_GrSLPrecision;
26 if (texture->getContext()) { 29 if (texture->getContext()) {
27 const GrDrawTargetCaps* caps = texture->getContext()->getGpu()->caps(); 30 const GrDrawTargetCaps* caps = texture->getContext()->getGpu()->caps();
28 if (caps->floatPrecisionVaries()) { 31 if (caps->floatPrecisionVaries()) {
29 int maxD = SkTMax(texture->width(), texture->height()); 32 int maxD = SkTMax(texture->width(), texture->height());
30 const GrDrawTargetCaps::PrecisionInfo* info; 33 const GrDrawTargetCaps::PrecisionInfo* info;
31 info = &caps->getFloatShaderPrecisionInfo(kFragment_GrShaderType, fP recision); 34 info = &caps->getFloatShaderPrecisionInfo(kFragment_GrShaderType, fP recision);
32 do { 35 do {
33 SkASSERT(info->supported()); 36 SkASSERT(info->supported());
34 // Make sure there is at least 2 bits of subpixel precision in t he range of 37 // Make sure there is at least 2 bits of subpixel precision in t he range of
35 // texture coords from 0.5 to 1.0. 38 // texture coords from 0.5 to 1.0.
36 if ((2 << info->fBits) / maxD > 4) { 39 if ((2 << info->fBits) / maxD > subPixelThresh) {
37 break; 40 break;
38 } 41 }
39 if (kHigh_GrSLPrecision == fPrecision) { 42 if (kHigh_GrSLPrecision == fPrecision) {
40 break; 43 break;
41 } 44 }
42 GrSLPrecision nextP = static_cast<GrSLPrecision>(fPrecision + 1) ; 45 GrSLPrecision nextP = static_cast<GrSLPrecision>(fPrecision + 1) ;
43 info = &caps->getFloatShaderPrecisionInfo(kFragment_GrShaderType , nextP); 46 info = &caps->getFloatShaderPrecisionInfo(kFragment_GrShaderType , nextP);
44 if (!info->supported()) { 47 if (!info->supported()) {
45 break; 48 break;
46 } 49 }
47 fPrecision = nextP; 50 fPrecision = nextP;
48 } while (true); 51 } while (true);
49 } 52 }
50 } 53 }
51 } 54 }
52 55
53 void GrCoordTransform::reset(GrCoordSet sourceCoords, 56 void GrCoordTransform::reset(GrCoordSet sourceCoords,
54 const SkMatrix& m, 57 const SkMatrix& m,
55 GrSLPrecision precision) { 58 GrSLPrecision precision) {
56 SkASSERT(!fInProcessor); 59 SkASSERT(!fInProcessor);
57 fSourceCoords = sourceCoords; 60 fSourceCoords = sourceCoords;
58 fMatrix = m; 61 fMatrix = m;
59 fReverseY = false; 62 fReverseY = false;
60 fPrecision = precision; 63 fPrecision = precision;
61 } 64 }
OLDNEW
« no previous file with comments | « src/effects/gradients/SkGradientShader.cpp ('k') | src/gpu/effects/GrSingleTextureEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698