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

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

Issue 1228683002: rename GrShaderDataManager -> GrProcessorDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@grfixuptests
Patch Set: rebase onto origin/master Created 5 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/core/SkXfermode_proccoeff.h ('k') | src/effects/SkArithmeticMode.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 2013 Google Inc. 2 * Copyright 2013 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 "SkAlphaThresholdFilter.h" 8 #include "SkAlphaThresholdFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
(...skipping 10 matching lines...) Expand all
21 21
22 SK_TO_STRING_OVERRIDE() 22 SK_TO_STRING_OVERRIDE()
23 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAlphaThresholdFilterIm pl) 23 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAlphaThresholdFilterIm pl)
24 24
25 protected: 25 protected:
26 void flatten(SkWriteBuffer&) const override; 26 void flatten(SkWriteBuffer&) const override;
27 27
28 bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, 28 bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
29 SkBitmap* result, SkIPoint* offset) const override; 29 SkBitmap* result, SkIPoint* offset) const override;
30 #if SK_SUPPORT_GPU 30 #if SK_SUPPORT_GPU
31 bool asFragmentProcessor(GrFragmentProcessor**, GrShaderDataManager*, GrText ure*, 31 bool asFragmentProcessor(GrFragmentProcessor**, GrProcessorDataManager*, GrT exture*,
32 const SkMatrix&, const SkIRect& bounds) const overr ide; 32 const SkMatrix&, const SkIRect& bounds) const overr ide;
33 #endif 33 #endif
34 34
35 private: 35 private:
36 SkRegion fRegion; 36 SkRegion fRegion;
37 SkScalar fInnerThreshold; 37 SkScalar fInnerThreshold;
38 SkScalar fOuterThreshold; 38 SkScalar fOuterThreshold;
39 typedef SkImageFilter INHERITED; 39 typedef SkImageFilter INHERITED;
40 }; 40 };
41 41
(...skipping 13 matching lines...) Expand all
55 #include "effects/GrPorterDuffXferProcessor.h" 55 #include "effects/GrPorterDuffXferProcessor.h"
56 56
57 #include "SkGr.h" 57 #include "SkGr.h"
58 58
59 #include "gl/GrGLProcessor.h" 59 #include "gl/GrGLProcessor.h"
60 #include "gl/builders/GrGLProgramBuilder.h" 60 #include "gl/builders/GrGLProgramBuilder.h"
61 61
62 class AlphaThresholdEffect : public GrFragmentProcessor { 62 class AlphaThresholdEffect : public GrFragmentProcessor {
63 63
64 public: 64 public:
65 static GrFragmentProcessor* Create(GrShaderDataManager* shaderDataManager, 65 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager,
66 GrTexture* texture, 66 GrTexture* texture,
67 GrTexture* maskTexture, 67 GrTexture* maskTexture,
68 float innerThreshold, 68 float innerThreshold,
69 float outerThreshold) { 69 float outerThreshold) {
70 return SkNEW_ARGS(AlphaThresholdEffect, (shaderDataManager, 70 return SkNEW_ARGS(AlphaThresholdEffect, (procDataManager,
71 texture, 71 texture,
72 maskTexture, 72 maskTexture,
73 innerThreshold, 73 innerThreshold,
74 outerThreshold)); 74 outerThreshold));
75 } 75 }
76 76
77 virtual ~AlphaThresholdEffect() {}; 77 virtual ~AlphaThresholdEffect() {};
78 78
79 const char* name() const override { return "Alpha Threshold"; } 79 const char* name() const override { return "Alpha Threshold"; }
80 80
81 float innerThreshold() const { return fInnerThreshold; } 81 float innerThreshold() const { return fInnerThreshold; }
82 float outerThreshold() const { return fOuterThreshold; } 82 float outerThreshold() const { return fOuterThreshold; }
83 83
84 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride; 84 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over ride;
85 85
86 GrGLFragmentProcessor* createGLInstance() const override; 86 GrGLFragmentProcessor* createGLInstance() const override;
87 87
88 private: 88 private:
89 AlphaThresholdEffect(GrShaderDataManager*, 89 AlphaThresholdEffect(GrProcessorDataManager*,
90 GrTexture* texture, 90 GrTexture* texture,
91 GrTexture* maskTexture, 91 GrTexture* maskTexture,
92 float innerThreshold, 92 float innerThreshold,
93 float outerThreshold) 93 float outerThreshold)
94 : fInnerThreshold(innerThreshold) 94 : fInnerThreshold(innerThreshold)
95 , fOuterThreshold(outerThreshold) 95 , fOuterThreshold(outerThreshold)
96 , fImageCoordTransform(kLocal_GrCoordSet, 96 , fImageCoordTransform(kLocal_GrCoordSet,
97 GrCoordTransform::MakeDivByTextureWHMatrix(textur e), texture, 97 GrCoordTransform::MakeDivByTextureWHMatrix(textur e), texture,
98 GrTextureParams::kNone_FilterMode) 98 GrTextureParams::kNone_FilterMode)
99 , fImageTextureAccess(texture) 99 , fImageTextureAccess(texture)
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 205
206 ///////////////////////////////////////////////////////////////////// 206 /////////////////////////////////////////////////////////////////////
207 207
208 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(AlphaThresholdEffect); 208 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(AlphaThresholdEffect);
209 209
210 GrFragmentProcessor* AlphaThresholdEffect::TestCreate(GrProcessorTestData* d) { 210 GrFragmentProcessor* AlphaThresholdEffect::TestCreate(GrProcessorTestData* d) {
211 GrTexture* bmpTex = d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx]; 211 GrTexture* bmpTex = d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx];
212 GrTexture* maskTex = d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx]; 212 GrTexture* maskTex = d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx];
213 float innerThresh = d->fRandom->nextUScalar1(); 213 float innerThresh = d->fRandom->nextUScalar1();
214 float outerThresh = d->fRandom->nextUScalar1(); 214 float outerThresh = d->fRandom->nextUScalar1();
215 return AlphaThresholdEffect::Create(d->fShaderDataManager, bmpTex, maskTex, innerThresh, 215 return AlphaThresholdEffect::Create(d->fProcDataManager, bmpTex, maskTex, in nerThresh,
216 outerThresh); 216 outerThresh);
217 } 217 }
218 218
219 /////////////////////////////////////////////////////////////////////////////// 219 ///////////////////////////////////////////////////////////////////////////////
220 220
221 void AlphaThresholdEffect::getGLProcessorKey(const GrGLSLCaps& caps, 221 void AlphaThresholdEffect::getGLProcessorKey(const GrGLSLCaps& caps,
222 GrProcessorKeyBuilder* b) const { 222 GrProcessorKeyBuilder* b) const {
223 GrGLAlphaThresholdEffect::GenKey(*this, caps, b); 223 GrGLAlphaThresholdEffect::GenKey(*this, caps, b);
224 } 224 }
225 225
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 SkScalar outerThreshold, 259 SkScalar outerThreshold,
260 SkImageFilter* input) 260 SkImageFilter* input)
261 : INHERITED(1, &input) 261 : INHERITED(1, &input)
262 , fRegion(region) 262 , fRegion(region)
263 , fInnerThreshold(innerThreshold) 263 , fInnerThreshold(innerThreshold)
264 , fOuterThreshold(outerThreshold) { 264 , fOuterThreshold(outerThreshold) {
265 } 265 }
266 266
267 #if SK_SUPPORT_GPU 267 #if SK_SUPPORT_GPU
268 bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp, 268 bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp,
269 GrShaderDataManager* shader DataManager, 269 GrProcessorDataManager* pro cDataManager,
270 GrTexture* texture, 270 GrTexture* texture,
271 const SkMatrix& in_matrix, 271 const SkMatrix& in_matrix,
272 const SkIRect&) const { 272 const SkIRect&) const {
273 if (fp) { 273 if (fp) {
274 GrContext* context = texture->getContext(); 274 GrContext* context = texture->getContext();
275 GrSurfaceDesc maskDesc; 275 GrSurfaceDesc maskDesc;
276 if (context->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { 276 if (context->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) {
277 maskDesc.fConfig = kAlpha_8_GrPixelConfig; 277 maskDesc.fConfig = kAlpha_8_GrPixelConfig;
278 } else { 278 } else {
279 maskDesc.fConfig = kRGBA_8888_GrPixelConfig; 279 maskDesc.fConfig = kRGBA_8888_GrPixelConfig;
(...skipping 17 matching lines...) Expand all
297 drawContext->clear(maskTexture->asRenderTarget(), NULL, 0x0, true); 297 drawContext->clear(maskTexture->asRenderTarget(), NULL, 0x0, true);
298 298
299 while (!iter.done()) { 299 while (!iter.done()) {
300 SkRect rect = SkRect::Make(iter.rect()); 300 SkRect rect = SkRect::Make(iter.rect());
301 drawContext->drawRect(maskTexture->asRenderTarget(), GrClip::Wid eOpen(), grPaint, 301 drawContext->drawRect(maskTexture->asRenderTarget(), GrClip::Wid eOpen(), grPaint,
302 in_matrix, rect); 302 in_matrix, rect);
303 iter.next(); 303 iter.next();
304 } 304 }
305 } 305 }
306 306
307 *fp = AlphaThresholdEffect::Create(shaderDataManager, 307 *fp = AlphaThresholdEffect::Create(procDataManager,
308 texture, 308 texture,
309 maskTexture, 309 maskTexture,
310 fInnerThreshold, 310 fInnerThreshold,
311 fOuterThreshold); 311 fOuterThreshold);
312 } 312 }
313 return true; 313 return true;
314 } 314 }
315 #endif 315 #endif
316 316
317 void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const { 317 void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 } 384 }
385 385
386 #ifndef SK_IGNORE_TO_STRING 386 #ifndef SK_IGNORE_TO_STRING
387 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { 387 void SkAlphaThresholdFilterImpl::toString(SkString* str) const {
388 str->appendf("SkAlphaThresholdImageFilter: ("); 388 str->appendf("SkAlphaThresholdImageFilter: (");
389 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); 389 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold);
390 str->append(")"); 390 str->append(")");
391 } 391 }
392 #endif 392 #endif
393 393
OLDNEW
« no previous file with comments | « src/core/SkXfermode_proccoeff.h ('k') | src/effects/SkArithmeticMode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698