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

Side by Side Diff: src/image/SkImageShader.cpp

Issue 2175563003: Bundle SkShader::asFragmentProcessor arguments in a struct (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix indentation to be less arbitrary Created 4 years, 5 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 | « src/image/SkImageShader.h ('k') | no next file » | 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 2015 Google Inc. 2 * Copyright 2015 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 "SkBitmapProcShader.h" 8 #include "SkBitmapProcShader.h"
9 #include "SkBitmapProvider.h" 9 #include "SkBitmapProvider.h"
10 #include "SkImage_Base.h" 10 #include "SkImage_Base.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 #if SK_SUPPORT_GPU 77 #if SK_SUPPORT_GPU
78 78
79 #include "GrTextureAccess.h" 79 #include "GrTextureAccess.h"
80 #include "SkGr.h" 80 #include "SkGr.h"
81 #include "SkGrPriv.h" 81 #include "SkGrPriv.h"
82 #include "effects/GrSimpleTextureEffect.h" 82 #include "effects/GrSimpleTextureEffect.h"
83 #include "effects/GrBicubicEffect.h" 83 #include "effects/GrBicubicEffect.h"
84 #include "effects/GrSimpleTextureEffect.h" 84 #include "effects/GrSimpleTextureEffect.h"
85 85
86 sk_sp<GrFragmentProcessor> SkImageShader::asFragmentProcessor( 86 sk_sp<GrFragmentProcessor> SkImageShader::asFragmentProcessor(const AsFPArgs& ar gs) const {
87 GrContext* context,
88 const SkMatrix& viewM,
89 const SkMatrix* localMatrix ,
90 SkFilterQuality filterQuali ty,
91 SkSourceGammaTreatment gamm aTreatment) const {
92 SkMatrix matrix; 87 SkMatrix matrix;
93 matrix.setIDiv(fImage->width(), fImage->height()); 88 matrix.setIDiv(fImage->width(), fImage->height());
94 89
95 SkMatrix lmInverse; 90 SkMatrix lmInverse;
96 if (!this->getLocalMatrix().invert(&lmInverse)) { 91 if (!this->getLocalMatrix().invert(&lmInverse)) {
97 return nullptr; 92 return nullptr;
98 } 93 }
99 if (localMatrix) { 94 if (args.fLocalMatrix) {
100 SkMatrix inv; 95 SkMatrix inv;
101 if (!localMatrix->invert(&inv)) { 96 if (!args.fLocalMatrix->invert(&inv)) {
102 return nullptr; 97 return nullptr;
103 } 98 }
104 lmInverse.postConcat(inv); 99 lmInverse.postConcat(inv);
105 } 100 }
106 matrix.preConcat(lmInverse); 101 matrix.preConcat(lmInverse);
107 102
108 SkShader::TileMode tm[] = { fTileModeX, fTileModeY }; 103 SkShader::TileMode tm[] = { fTileModeX, fTileModeY };
109 104
110 // Must set wrap and filter on the sampler before requesting a texture. In t wo places below 105 // Must set wrap and filter on the sampler before requesting a texture. In t wo places below
111 // we check the matrix scale factors to determine how to interpret the filte r quality setting. 106 // we check the matrix scale factors to determine how to interpret the filte r quality setting.
112 // This completely ignores the complexity of the drawVertices case where exp licit local coords 107 // This completely ignores the complexity of the drawVertices case where exp licit local coords
113 // are provided by the caller. 108 // are provided by the caller.
114 bool doBicubic; 109 bool doBicubic;
115 GrTextureParams::FilterMode textureFilterMode = 110 GrTextureParams::FilterMode textureFilterMode =
116 GrSkFilterQualityToGrFilterMode(filterQuality, viewM, this->getLocalMatrix() , &doBicubic); 111 GrSkFilterQualityToGrFilterMode(args.fFilterQuality, *args.fViewMatrix, this ->getLocalMatrix(),
112 &doBicubic);
117 GrTextureParams params(tm, textureFilterMode); 113 GrTextureParams params(tm, textureFilterMode);
118 SkAutoTUnref<GrTexture> texture(as_IB(fImage)->asTextureRef(context, params, gammaTreatment)); 114 SkAutoTUnref<GrTexture> texture(as_IB(fImage)->asTextureRef(args.fContext, p arams,
115 args.fGammaTreat ment));
119 if (!texture) { 116 if (!texture) {
120 return nullptr; 117 return nullptr;
121 } 118 }
122 119
123 sk_sp<GrFragmentProcessor> inner; 120 sk_sp<GrFragmentProcessor> inner;
124 if (doBicubic) { 121 if (doBicubic) {
125 inner = GrBicubicEffect::Make(texture, nullptr, matrix, tm); 122 inner = GrBicubicEffect::Make(texture, nullptr, matrix, tm);
126 } else { 123 } else {
127 inner = GrSimpleTextureEffect::Make(texture, nullptr, matrix, params); 124 inner = GrSimpleTextureEffect::Make(texture, nullptr, matrix, params);
128 } 125 }
129 126
130 if (GrPixelConfigIsAlphaOnly(texture->config())) { 127 if (GrPixelConfigIsAlphaOnly(texture->config())) {
131 return inner; 128 return inner;
132 } 129 }
133 return sk_sp<GrFragmentProcessor>(GrFragmentProcessor::MulOutputByInputAlpha (std::move(inner))); 130 return sk_sp<GrFragmentProcessor>(GrFragmentProcessor::MulOutputByInputAlpha (std::move(inner)));
134 } 131 }
135 132
136 #endif 133 #endif
OLDNEW
« no previous file with comments | « src/image/SkImageShader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698