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

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

Issue 759713002: Make all blending up to GrOptDrawState be handled by the xp/xp factory. (Closed) Base URL: https://skia.googlesource.com/skia.git@xferFactorySolo
Patch Set: rebase 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/core/SkXfermode.cpp ('k') | src/effects/SkBlurMaskFilter.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 30 matching lines...) Expand all
41 SkImageFilter* input) { 41 SkImageFilter* input) {
42 return SkNEW_ARGS(SkAlphaThresholdFilterImpl, (region, innerThreshold, outer Threshold, input)); 42 return SkNEW_ARGS(SkAlphaThresholdFilterImpl, (region, innerThreshold, outer Threshold, input));
43 } 43 }
44 44
45 #if SK_SUPPORT_GPU 45 #if SK_SUPPORT_GPU
46 #include "GrContext.h" 46 #include "GrContext.h"
47 #include "GrCoordTransform.h" 47 #include "GrCoordTransform.h"
48 #include "GrFragmentProcessor.h" 48 #include "GrFragmentProcessor.h"
49 #include "GrInvariantOutput.h" 49 #include "GrInvariantOutput.h"
50 #include "GrTextureAccess.h" 50 #include "GrTextureAccess.h"
51 #include "effects/GrPorterDuffXferProcessor.h"
51 52
52 #include "SkGr.h" 53 #include "SkGr.h"
53 54
54 #include "gl/GrGLProcessor.h" 55 #include "gl/GrGLProcessor.h"
55 #include "gl/builders/GrGLProgramBuilder.h" 56 #include "gl/builders/GrGLProgramBuilder.h"
56 57
57 class AlphaThresholdEffect : public GrFragmentProcessor { 58 class AlphaThresholdEffect : public GrFragmentProcessor {
58 59
59 public: 60 public:
60 static GrFragmentProcessor* Create(GrTexture* texture, 61 static GrFragmentProcessor* Create(GrTexture* texture,
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 maskDesc.fHeight = texture->height(); 277 maskDesc.fHeight = texture->height();
277 SkAutoTUnref<GrTexture> maskTexture( 278 SkAutoTUnref<GrTexture> maskTexture(
278 context->refScratchTexture(maskDesc, GrContext::kApprox_ScratchTexMa tch)); 279 context->refScratchTexture(maskDesc, GrContext::kApprox_ScratchTexMa tch));
279 if (!maskTexture) { 280 if (!maskTexture) {
280 return false; 281 return false;
281 } 282 }
282 283
283 { 284 {
284 GrContext::AutoRenderTarget art(context, maskTexture->asRenderTarget ()); 285 GrContext::AutoRenderTarget art(context, maskTexture->asRenderTarget ());
285 GrPaint grPaint; 286 GrPaint grPaint;
286 grPaint.setBlendFunc(kOne_GrBlendCoeff, kZero_GrBlendCoeff); 287 grPaint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
287 SkRegion::Iterator iter(fRegion); 288 SkRegion::Iterator iter(fRegion);
288 context->clear(NULL, 0x0, true, maskTexture->asRenderTarget()); 289 context->clear(NULL, 0x0, true, maskTexture->asRenderTarget());
289 290
290 SkMatrix old_matrix = context->getMatrix(); 291 SkMatrix old_matrix = context->getMatrix();
291 context->setMatrix(in_matrix); 292 context->setMatrix(in_matrix);
292 293
293 while (!iter.done()) { 294 while (!iter.done()) {
294 SkRect rect = SkRect::Make(iter.rect()); 295 SkRect rect = SkRect::Make(iter.rect());
295 context->drawRect(grPaint, rect); 296 context->drawRect(grPaint, rect);
296 iter.next(); 297 iter.next();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 (U8CPU)(SkColorGetG(source) * scale), 369 (U8CPU)(SkColorGetG(source) * scale),
369 (U8CPU)(SkColorGetB(source) * scale)); 370 (U8CPU)(SkColorGetB(source) * scale));
370 } 371 }
371 } 372 }
372 dptr[y * dst->width() + x] = output_color; 373 dptr[y * dst->width() + x] = output_color;
373 } 374 }
374 } 375 }
375 376
376 return true; 377 return true;
377 } 378 }
OLDNEW
« no previous file with comments | « src/core/SkXfermode.cpp ('k') | src/effects/SkBlurMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698