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

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

Issue 1151283004: Split drawing functionality out of GrContext and into new GrDrawContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix no-GPU builds Created 5 years, 7 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/SkImageFilter.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"
11 #include "SkWriteBuffer.h" 11 #include "SkWriteBuffer.h"
12 #include "SkRegion.h" 12 #include "SkRegion.h"
13 #if SK_SUPPORT_GPU
14 #include "GrDrawContext.h"
15 #endif
13 16
14 class SK_API SkAlphaThresholdFilterImpl : public SkImageFilter { 17 class SK_API SkAlphaThresholdFilterImpl : public SkImageFilter {
15 public: 18 public:
16 SkAlphaThresholdFilterImpl(const SkRegion& region, SkScalar innerThreshold, 19 SkAlphaThresholdFilterImpl(const SkRegion& region, SkScalar innerThreshold,
17 SkScalar outerThreshold, SkImageFilter* input); 20 SkScalar outerThreshold, SkImageFilter* input);
18 21
19 SK_TO_STRING_OVERRIDE() 22 SK_TO_STRING_OVERRIDE()
20 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAlphaThresholdFilterIm pl) 23 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkAlphaThresholdFilterIm pl)
21 24
22 protected: 25 protected:
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // Add one pixel of border to ensure that clamp mode will be all zeros 280 // Add one pixel of border to ensure that clamp mode will be all zeros
278 // the outside. 281 // the outside.
279 maskDesc.fWidth = texture->width(); 282 maskDesc.fWidth = texture->width();
280 maskDesc.fHeight = texture->height(); 283 maskDesc.fHeight = texture->height();
281 SkAutoTUnref<GrTexture> maskTexture(context->textureProvider()->refScrat chTexture( 284 SkAutoTUnref<GrTexture> maskTexture(context->textureProvider()->refScrat chTexture(
282 maskDesc, GrTextureProvider::kApprox_ScratchTexMatch)); 285 maskDesc, GrTextureProvider::kApprox_ScratchTexMatch));
283 if (!maskTexture) { 286 if (!maskTexture) {
284 return false; 287 return false;
285 } 288 }
286 289
287 { 290 GrDrawContext* drawContext = context->drawContext();
291 if (drawContext) {
288 GrPaint grPaint; 292 GrPaint grPaint;
289 grPaint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); 293 grPaint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
290 SkRegion::Iterator iter(fRegion); 294 SkRegion::Iterator iter(fRegion);
291 context->clear(NULL, 0x0, true, maskTexture->asRenderTarget()); 295 drawContext->clear(maskTexture->asRenderTarget(), NULL, 0x0, true);
292 296
293 while (!iter.done()) { 297 while (!iter.done()) {
294 SkRect rect = SkRect::Make(iter.rect()); 298 SkRect rect = SkRect::Make(iter.rect());
295 context->drawRect(maskTexture->asRenderTarget(), GrClip::WideOpe n(), grPaint, 299 drawContext->drawRect(maskTexture->asRenderTarget(), GrClip::Wid eOpen(), grPaint,
296 in_matrix, rect); 300 in_matrix, rect);
297 iter.next(); 301 iter.next();
298 } 302 }
299 } 303 }
300 304
301 *fp = AlphaThresholdEffect::Create(texture, 305 *fp = AlphaThresholdEffect::Create(texture,
302 maskTexture, 306 maskTexture,
303 fInnerThreshold, 307 fInnerThreshold,
304 fOuterThreshold); 308 fOuterThreshold);
305 } 309 }
306 return true; 310 return true;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 } 381 }
378 382
379 #ifndef SK_IGNORE_TO_STRING 383 #ifndef SK_IGNORE_TO_STRING
380 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { 384 void SkAlphaThresholdFilterImpl::toString(SkString* str) const {
381 str->appendf("SkAlphaThresholdImageFilter: ("); 385 str->appendf("SkAlphaThresholdImageFilter: (");
382 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); 386 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold);
383 str->append(")"); 387 str->append(")");
384 } 388 }
385 #endif 389 #endif
386 390
OLDNEW
« no previous file with comments | « src/core/SkImageFilter.cpp ('k') | src/effects/SkBlurMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698