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

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

Issue 2154753003: Introduce GrColorSpaceXform, for gamut conversion on textures (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: More progress & refactoring Created 4 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/effects/SkBlurMaskFilter.cpp ('k') | src/effects/SkLightingImageFilter.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 "SkGpuBlurUtils.h" 8 #include "SkGpuBlurUtils.h"
9 9
10 #include "SkRect.h" 10 #include "SkRect.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 SkMatrix matrix; 268 SkMatrix matrix;
269 matrix.setIDiv(srcTexture->width(), srcTexture->height()); 269 matrix.setIDiv(srcTexture->width(), srcTexture->height());
270 SkIRect dstRect(srcRect); 270 SkIRect dstRect(srcRect);
271 if (srcBounds && i == 1) { 271 if (srcBounds && i == 1) {
272 SkRect domain; 272 SkRect domain;
273 matrix.mapRect(&domain, SkRect::Make(*srcBounds)); 273 matrix.mapRect(&domain, SkRect::Make(*srcBounds));
274 domain.inset((i < scaleFactorX) ? SK_ScalarHalf / srcTexture->width( ) : 0.0f, 274 domain.inset((i < scaleFactorX) ? SK_ScalarHalf / srcTexture->width( ) : 0.0f,
275 (i < scaleFactorY) ? SK_ScalarHalf / srcTexture->height () : 0.0f); 275 (i < scaleFactorY) ? SK_ScalarHalf / srcTexture->height () : 0.0f);
276 sk_sp<GrFragmentProcessor> fp(GrTextureDomainEffect::Make( 276 sk_sp<GrFragmentProcessor> fp(GrTextureDomainEffect::Make(
277 srcTexture.get(), 277 srcTexture.get(),
278 nullptr,
278 matrix, 279 matrix,
279 domain, 280 domain,
280 GrTextureDomain::kDecal_ Mode, 281 GrTextureDomain::kDecal_ Mode,
281 GrTextureParams::kBilerp _FilterMode)); 282 GrTextureParams::kBilerp _FilterMode));
282 paint.addColorFragmentProcessor(std::move(fp)); 283 paint.addColorFragmentProcessor(std::move(fp));
283 srcRect.offset(-srcOffset); 284 srcRect.offset(-srcOffset);
284 srcOffset.set(0, 0); 285 srcOffset.set(0, 0);
285 } else { 286 } else {
286 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::k Bilerp_FilterMode); 287 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::k Bilerp_FilterMode);
287 paint.addColorTextureProcessor(srcTexture.get(), matrix, params); 288 paint.addColorTextureProcessor(srcTexture.get(), nullptr, matrix, pa rams);
288 } 289 }
289 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); 290 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
290 shrink_irect_by_2(&dstRect, i < scaleFactorX, i < scaleFactorY); 291 shrink_irect_by_2(&dstRect, i < scaleFactorX, i < scaleFactorY);
291 292
292 dstDrawContext->fillRectToRect(clip, paint, SkMatrix::I(), 293 dstDrawContext->fillRectToRect(clip, paint, SkMatrix::I(),
293 SkRect::Make(dstRect), SkRect::Make(srcRe ct)); 294 SkRect::Make(dstRect), SkRect::Make(srcRe ct));
294 295
295 srcDrawContext = dstDrawContext; 296 srcDrawContext = dstDrawContext;
296 srcRect = dstRect; 297 srcRect = dstRect;
297 srcTexture = srcDrawContext->asTexture(); 298 srcTexture = srcDrawContext->asTexture();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 srcDrawContext->clear(&clearRect, 0x0, false); 355 srcDrawContext->clear(&clearRect, 0x0, false);
355 356
356 SkMatrix matrix; 357 SkMatrix matrix;
357 matrix.setIDiv(srcDrawContext->width(), srcDrawContext->height()); 358 matrix.setIDiv(srcDrawContext->width(), srcDrawContext->height());
358 359
359 GrPaint paint; 360 GrPaint paint;
360 paint.setGammaCorrect(gammaCorrect); 361 paint.setGammaCorrect(gammaCorrect);
361 // FIXME: this should be mitchell, not bilinear. 362 // FIXME: this should be mitchell, not bilinear.
362 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBile rp_FilterMode); 363 GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBile rp_FilterMode);
363 sk_sp<GrTexture> tex(srcDrawContext->asTexture()); 364 sk_sp<GrTexture> tex(srcDrawContext->asTexture());
364 paint.addColorTextureProcessor(tex.get(), matrix, params); 365 paint.addColorTextureProcessor(tex.get(), nullptr, matrix, params);
365 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); 366 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
366 367
367 SkIRect dstRect(srcRect); 368 SkIRect dstRect(srcRect);
368 scale_irect(&dstRect, scaleFactorX, scaleFactorY); 369 scale_irect(&dstRect, scaleFactorX, scaleFactorY);
369 370
370 dstDrawContext->fillRectToRect(clip, paint, SkMatrix::I(), 371 dstDrawContext->fillRectToRect(clip, paint, SkMatrix::I(),
371 SkRect::Make(dstRect), SkRect::Make(srcRe ct)); 372 SkRect::Make(dstRect), SkRect::Make(srcRe ct));
372 373
373 srcDrawContext = dstDrawContext; 374 srcDrawContext = dstDrawContext;
374 srcRect = dstRect; 375 srcRect = dstRect;
375 dstDrawContext.swap(tmpDrawContext); 376 dstDrawContext.swap(tmpDrawContext);
376 } 377 }
377 378
378 return srcDrawContext; 379 return srcDrawContext;
379 } 380 }
380 381
381 } 382 }
382 383
383 #endif 384 #endif
384 385
OLDNEW
« no previous file with comments | « src/effects/SkBlurMaskFilter.cpp ('k') | src/effects/SkLightingImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698