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

Side by Side Diff: src/effects/GrAlphaThresholdFragmentProcessor.cpp

Issue 2041113004: sk_sp for gpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Reserve correctly. Created 4 years, 6 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/core/SkXfermode_proccoeff.h ('k') | src/effects/GrCircleBlurFragmentProcessor.h » ('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 2016 Google Inc. 2 * Copyright 2016 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 "GrAlphaThresholdFragmentProcessor.h" 8 #include "GrAlphaThresholdFragmentProcessor.h"
9 9
10 #if SK_SUPPORT_GPU 10 #if SK_SUPPORT_GPU
11 11
12 #include "GrInvariantOutput.h" 12 #include "GrInvariantOutput.h"
13 #include "GrTextureAccess.h" 13 #include "GrTextureAccess.h"
14 #include "SkRefCnt.h"
14 15
15 #include "glsl/GrGLSLFragmentProcessor.h" 16 #include "glsl/GrGLSLFragmentProcessor.h"
16 #include "glsl/GrGLSLFragmentShaderBuilder.h" 17 #include "glsl/GrGLSLFragmentShaderBuilder.h"
17 #include "glsl/GrGLSLUniformHandler.h" 18 #include "glsl/GrGLSLUniformHandler.h"
18 19
19 sk_sp<GrFragmentProcessor> GrAlphaThresholdFragmentProcessor::Make(GrTexture* te xture, 20 sk_sp<GrFragmentProcessor> GrAlphaThresholdFragmentProcessor::Make(GrTexture* te xture,
20 GrTexture* ma skTexture, 21 GrTexture* ma skTexture,
21 float innerTh reshold, 22 float innerTh reshold,
22 float outerTh reshold, 23 float outerTh reshold,
23 const SkIRect & bounds) { 24 const SkIRect & bounds) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 const GrProcessor& proc) { 138 const GrProcessor& proc) {
138 const GrAlphaThresholdFragmentProcessor& atfp = proc.cast<GrAlphaThresholdFr agmentProcessor>(); 139 const GrAlphaThresholdFragmentProcessor& atfp = proc.cast<GrAlphaThresholdFr agmentProcessor>();
139 pdman.set1f(fInnerThresholdVar, atfp.innerThreshold()); 140 pdman.set1f(fInnerThresholdVar, atfp.innerThreshold());
140 pdman.set1f(fOuterThresholdVar, atfp.outerThreshold()); 141 pdman.set1f(fOuterThresholdVar, atfp.outerThreshold());
141 } 142 }
142 143
143 ///////////////////////////////////////////////////////////////////// 144 /////////////////////////////////////////////////////////////////////
144 145
145 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrAlphaThresholdFragmentProcessor); 146 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrAlphaThresholdFragmentProcessor);
146 147
147 const GrFragmentProcessor* GrAlphaThresholdFragmentProcessor::TestCreate(GrProce ssorTestData* d) { 148 sk_sp<GrFragmentProcessor> GrAlphaThresholdFragmentProcessor::TestCreate(GrProce ssorTestData* d) {
148 GrTexture* bmpTex = d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx]; 149 GrTexture* bmpTex = d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx];
149 GrTexture* maskTex = d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx]; 150 GrTexture* maskTex = d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx];
150 float innerThresh = d->fRandom->nextUScalar1(); 151 float innerThresh = d->fRandom->nextUScalar1();
151 float outerThresh = d->fRandom->nextUScalar1(); 152 float outerThresh = d->fRandom->nextUScalar1();
152 const int kMaxWidth = 1000; 153 const int kMaxWidth = 1000;
153 const int kMaxHeight = 1000; 154 const int kMaxHeight = 1000;
154 uint32_t width = d->fRandom->nextULessThan(kMaxWidth); 155 uint32_t width = d->fRandom->nextULessThan(kMaxWidth);
155 uint32_t height = d->fRandom->nextULessThan(kMaxHeight); 156 uint32_t height = d->fRandom->nextULessThan(kMaxHeight);
156 uint32_t x = d->fRandom->nextULessThan(kMaxWidth - width); 157 uint32_t x = d->fRandom->nextULessThan(kMaxWidth - width);
157 uint32_t y = d->fRandom->nextULessThan(kMaxHeight - height); 158 uint32_t y = d->fRandom->nextULessThan(kMaxHeight - height);
158 SkIRect bounds = SkIRect::MakeXYWH(x, y, width, height); 159 SkIRect bounds = SkIRect::MakeXYWH(x, y, width, height);
159 return GrAlphaThresholdFragmentProcessor::Make(bmpTex, maskTex, 160 return GrAlphaThresholdFragmentProcessor::Make(bmpTex, maskTex,
160 innerThresh, outerThresh, 161 innerThresh, outerThresh,
161 bounds).release(); 162 bounds);
162 } 163 }
163 164
164 /////////////////////////////////////////////////////////////////////////////// 165 ///////////////////////////////////////////////////////////////////////////////
165 166
166 void GrAlphaThresholdFragmentProcessor::onGetGLSLProcessorKey(const GrGLSLCaps& caps, 167 void GrAlphaThresholdFragmentProcessor::onGetGLSLProcessorKey(const GrGLSLCaps& caps,
167 GrProcessorKeyBuil der* b) const { 168 GrProcessorKeyBuil der* b) const {
168 GrGLAlphaThresholdFragmentProcessor::GenKey(*this, caps, b); 169 GrGLAlphaThresholdFragmentProcessor::GenKey(*this, caps, b);
169 } 170 }
170 171
171 GrGLSLFragmentProcessor* GrAlphaThresholdFragmentProcessor::onCreateGLSLInstance () const { 172 GrGLSLFragmentProcessor* GrAlphaThresholdFragmentProcessor::onCreateGLSLInstance () const {
172 return new GrGLAlphaThresholdFragmentProcessor; 173 return new GrGLAlphaThresholdFragmentProcessor;
173 } 174 }
174 175
175 #endif 176 #endif
OLDNEW
« no previous file with comments | « src/core/SkXfermode_proccoeff.h ('k') | src/effects/GrCircleBlurFragmentProcessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698