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

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

Issue 1404823005: GrDrawContext now holds GrRenderTarget pointer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clean up Created 5 years, 2 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
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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 SkImageFilter* input) 244 SkImageFilter* input)
245 : INHERITED(1, &input) 245 : INHERITED(1, &input)
246 , fRegion(region) 246 , fRegion(region)
247 , fInnerThreshold(innerThreshold) 247 , fInnerThreshold(innerThreshold)
248 , fOuterThreshold(outerThreshold) { 248 , fOuterThreshold(outerThreshold) {
249 } 249 }
250 250
251 #if SK_SUPPORT_GPU 251 #if SK_SUPPORT_GPU
252 bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp, 252 bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp,
253 GrTexture* texture, 253 GrTexture* texture,
254 const SkMatrix& in_matrix, 254 const SkMatrix& inMatrix,
255 const SkIRect&) const { 255 const SkIRect&) const {
256 if (fp) { 256 if (fp) {
257 GrContext* context = texture->getContext(); 257 GrContext* context = texture->getContext();
258 GrSurfaceDesc maskDesc; 258 GrSurfaceDesc maskDesc;
259 if (context->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { 259 if (context->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) {
260 maskDesc.fConfig = kAlpha_8_GrPixelConfig; 260 maskDesc.fConfig = kAlpha_8_GrPixelConfig;
261 } else { 261 } else {
262 maskDesc.fConfig = kRGBA_8888_GrPixelConfig; 262 maskDesc.fConfig = kRGBA_8888_GrPixelConfig;
263 } 263 }
264 maskDesc.fFlags = kRenderTarget_GrSurfaceFlag; 264 maskDesc.fFlags = kRenderTarget_GrSurfaceFlag;
265 // Add one pixel of border to ensure that clamp mode will be all zeros 265 // Add one pixel of border to ensure that clamp mode will be all zeros
266 // the outside. 266 // the outside.
267 maskDesc.fWidth = texture->width(); 267 maskDesc.fWidth = texture->width();
268 maskDesc.fHeight = texture->height(); 268 maskDesc.fHeight = texture->height();
269 SkAutoTUnref<GrTexture> maskTexture( 269 SkAutoTUnref<GrTexture> maskTexture(
270 context->textureProvider()->createApproxTexture(maskDesc)); 270 context->textureProvider()->createApproxTexture(maskDesc));
271 if (!maskTexture) { 271 if (!maskTexture) {
272 return false; 272 return false;
273 } 273 }
274 274
275 SkAutoTUnref<GrDrawContext> drawContext(context->drawContext()); 275 SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(maskTexture ->asRenderTarget()));
bsalomon 2015/10/15 14:33:04 line wrap (if you care...)
robertphillips 2015/10/15 14:40:59 Done.
276 if (drawContext) { 276 if (drawContext) {
277 GrPaint grPaint; 277 GrPaint grPaint;
278 grPaint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); 278 grPaint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
279 SkRegion::Iterator iter(fRegion); 279 SkRegion::Iterator iter(fRegion);
280 drawContext->clear(maskTexture->asRenderTarget(), nullptr, 0x0, true ); 280 drawContext->clear(nullptr, 0x0, true);
281 281
282 while (!iter.done()) { 282 while (!iter.done()) {
283 SkRect rect = SkRect::Make(iter.rect()); 283 SkRect rect = SkRect::Make(iter.rect());
284 drawContext->drawRect(maskTexture->asRenderTarget(), GrClip::Wid eOpen(), grPaint, 284 drawContext->drawRect(GrClip::WideOpen(), grPaint, inMatrix, rec t);
285 in_matrix, rect);
286 iter.next(); 285 iter.next();
287 } 286 }
288 } 287 }
289 288
290 *fp = AlphaThresholdEffect::Create(texture, 289 *fp = AlphaThresholdEffect::Create(texture,
291 maskTexture, 290 maskTexture,
292 fInnerThreshold, 291 fInnerThreshold,
293 fOuterThreshold); 292 fOuterThreshold);
294 } 293 }
295 return true; 294 return true;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 } 365 }
367 366
368 #ifndef SK_IGNORE_TO_STRING 367 #ifndef SK_IGNORE_TO_STRING
369 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { 368 void SkAlphaThresholdFilterImpl::toString(SkString* str) const {
370 str->appendf("SkAlphaThresholdImageFilter: ("); 369 str->appendf("SkAlphaThresholdImageFilter: (");
371 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); 370 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold);
372 str->append(")"); 371 str->append(")");
373 } 372 }
374 #endif 373 #endif
375 374
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698