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

Side by Side Diff: src/gpu/GrTextureParamsAdjuster.cpp

Issue 2041113004: sk_sp for gpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Reserve correctly. Created 4 years, 6 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/gpu/GrTextureParamsAdjuster.h ('k') | src/gpu/GrTextureToYUVPlanes.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 2015 Google Inc. 2 * Copyright 2015 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 "GrTextureParamsAdjuster.h" 8 #include "GrTextureParamsAdjuster.h"
9 9
10 #include "GrCaps.h" 10 #include "GrCaps.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 (subset->width() != copyParams.fWidth || subset->height() != copyParams. fHeight)) { 86 (subset->width() != copyParams.fWidth || subset->height() != copyParams. fHeight)) {
87 SkRect domain; 87 SkRect domain;
88 domain.fLeft = (subset->fLeft + 0.5f) * sx; 88 domain.fLeft = (subset->fLeft + 0.5f) * sx;
89 domain.fTop = (subset->fTop + 0.5f)* sy; 89 domain.fTop = (subset->fTop + 0.5f)* sy;
90 domain.fRight = (subset->fRight - 0.5f) * sx; 90 domain.fRight = (subset->fRight - 0.5f) * sx;
91 domain.fBottom = (subset->fBottom - 0.5f) * sy; 91 domain.fBottom = (subset->fBottom - 0.5f) * sy;
92 // This would cause us to read values from outside the subset. Surely, t he caller knows 92 // This would cause us to read values from outside the subset. Surely, t he caller knows
93 // better! 93 // better!
94 SkASSERT(copyParams.fFilter != GrTextureParams::kMipMap_FilterMode); 94 SkASSERT(copyParams.fFilter != GrTextureParams::kMipMap_FilterMode);
95 paint.addColorFragmentProcessor( 95 paint.addColorFragmentProcessor(
96 GrTextureDomainEffect::Create(inputTexture, SkMatrix::I(), domain, 96 GrTextureDomainEffect::Make(inputTexture, SkMatrix::I(), domain,
97 GrTextureDomain::kClamp_Mode, 97 GrTextureDomain::kClamp_Mode,
98 copyParams.fFilter))->unref(); 98 copyParams.fFilter));
99 } else { 99 } else {
100 GrTextureParams params(SkShader::kClamp_TileMode, copyParams.fFilter); 100 GrTextureParams params(SkShader::kClamp_TileMode, copyParams.fFilter);
101 paint.addColorTextureProcessor(inputTexture, SkMatrix::I(), params); 101 paint.addColorTextureProcessor(inputTexture, SkMatrix::I(), params);
102 } 102 }
103 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); 103 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
104 104
105 SkRect localRect; 105 SkRect localRect;
106 if (subset) { 106 if (subset) {
107 localRect = SkRect::Make(*subset); 107 localRect = SkRect::Make(*subset);
108 localRect.fLeft *= sx; 108 localRect.fLeft *= sx;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 if (domainRect->fTop > domainRect->fBottom) { 335 if (domainRect->fTop > domainRect->fBottom) {
336 domainRect->fTop = domainRect->fBottom = SkScalarAve(domainRect->fTop, d omainRect->fBottom); 336 domainRect->fTop = domainRect->fBottom = SkScalarAve(domainRect->fTop, d omainRect->fBottom);
337 } 337 }
338 domainRect->fLeft /= texW; 338 domainRect->fLeft /= texW;
339 domainRect->fTop /= texH; 339 domainRect->fTop /= texH;
340 domainRect->fRight /= texW; 340 domainRect->fRight /= texW;
341 domainRect->fBottom /= texH; 341 domainRect->fBottom /= texH;
342 return kDomain_DomainMode; 342 return kDomain_DomainMode;
343 } 343 }
344 344
345 static const GrFragmentProcessor* create_fp_for_domain_and_filter( 345 static sk_sp<GrFragmentProcessor> create_fp_for_domain_and_filter(
346 GrTexture* texture, 346 GrTexture* texture,
347 const SkMatrix& textureMatrix, 347 const SkMatrix& textureMatrix,
348 DomainMode domainMode, 348 DomainMode domainMode,
349 const SkRect& domain, 349 const SkRect& domain,
350 const GrTextureParams::FilterMode* filte rOrNullForBicubic) { 350 const GrTextureParams::FilterMode* filte rOrNullForBicubic) {
351 SkASSERT(kTightCopy_DomainMode != domainMode); 351 SkASSERT(kTightCopy_DomainMode != domainMode);
352 if (filterOrNullForBicubic) { 352 if (filterOrNullForBicubic) {
353 if (kDomain_DomainMode == domainMode) { 353 if (kDomain_DomainMode == domainMode) {
354 return GrTextureDomainEffect::Create(texture, textureMatrix, domain, 354 return GrTextureDomainEffect::Make(texture, textureMatrix, domain,
355 GrTextureDomain::kClamp_Mode, 355 GrTextureDomain::kClamp_Mode,
356 *filterOrNullForBicubic); 356 *filterOrNullForBicubic);
357 } else { 357 } else {
358 GrTextureParams params(SkShader::kClamp_TileMode, *filterOrNullForBi cubic); 358 GrTextureParams params(SkShader::kClamp_TileMode, *filterOrNullForBi cubic);
359 return GrSimpleTextureEffect::Create(texture, textureMatrix, params) ; 359 return GrSimpleTextureEffect::Make(texture, textureMatrix, params);
360 } 360 }
361 } else { 361 } else {
362 if (kDomain_DomainMode == domainMode) { 362 if (kDomain_DomainMode == domainMode) {
363 return GrBicubicEffect::Create(texture, textureMatrix, domain); 363 return GrBicubicEffect::Make(texture, textureMatrix, domain);
364 } else { 364 } else {
365 static const SkShader::TileMode kClampClamp[] = 365 static const SkShader::TileMode kClampClamp[] =
366 { SkShader::kClamp_TileMode, SkShader::kClamp_TileMode }; 366 { SkShader::kClamp_TileMode, SkShader::kClamp_TileMode };
367 return GrBicubicEffect::Create(texture, textureMatrix, kClampClamp); 367 return GrBicubicEffect::Make(texture, textureMatrix, kClampClamp);
368 } 368 }
369 } 369 }
370 } 370 }
371 371
372 const GrFragmentProcessor* GrTextureAdjuster::createFragmentProcessor( 372 sk_sp<GrFragmentProcessor> GrTextureAdjuster::createFragmentProcessor(
373 const SkMatrix& origTextureMatrix, 373 const SkMatrix& origTextureMatrix,
374 const SkRect& origConstraintRect, 374 const SkRect& origConstraintRect,
375 FilterConstraint filterConstraint, 375 FilterConstraint filterConstraint,
376 bool coordsLimitedToConstraintRect, 376 bool coordsLimitedToConstraintRect,
377 const GrTextureParams::FilterMode* filte rOrNullForBicubic, 377 const GrTextureParams::FilterMode* filte rOrNullForBicubic,
378 SkSourceGammaTreatment gammaTreatment) { 378 SkSourceGammaTreatment gammaTreatment) {
379 379
380 SkMatrix textureMatrix = origTextureMatrix; 380 SkMatrix textureMatrix = origTextureMatrix;
381 const SkIRect* contentArea = this->contentAreaOrNull(); 381 const SkIRect* contentArea = this->contentAreaOrNull();
382 // Convert the constraintRect to be relative to the texture rather than the content area so 382 // Convert the constraintRect to be relative to the texture rather than the content area so
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 return nullptr; 460 return nullptr;
461 } 461 }
462 462
463 if (copyKey.isValid()) { 463 if (copyKey.isValid()) {
464 fContext->textureProvider()->assignUniqueKeyToTexture(copyKey, result); 464 fContext->textureProvider()->assignUniqueKeyToTexture(copyKey, result);
465 this->didCacheCopy(copyKey); 465 this->didCacheCopy(copyKey);
466 } 466 }
467 return result; 467 return result;
468 } 468 }
469 469
470 const GrFragmentProcessor* GrTextureMaker::createFragmentProcessor( 470 sk_sp<GrFragmentProcessor> GrTextureMaker::createFragmentProcessor(
471 const SkMatrix& textureMatrix, 471 const SkMatrix& textureMatrix,
472 const SkRect& constraintRect, 472 const SkRect& constraintRect,
473 FilterConstraint filterConstraint, 473 FilterConstraint filterConstraint,
474 bool coordsLimitedToConstraintRect, 474 bool coordsLimitedToConstraintRect,
475 const GrTextureParams::FilterMode* filte rOrNullForBicubic, 475 const GrTextureParams::FilterMode* filte rOrNullForBicubic,
476 SkSourceGammaTreatment gammaTreatment) { 476 SkSourceGammaTreatment gammaTreatment) {
477 477
478 const GrTextureParams::FilterMode* fmForDetermineDomain = filterOrNullForBic ubic; 478 const GrTextureParams::FilterMode* fmForDetermineDomain = filterOrNullForBic ubic;
479 if (filterOrNullForBicubic && GrTextureParams::kMipMap_FilterMode == *filter OrNullForBicubic && 479 if (filterOrNullForBicubic && GrTextureParams::kMipMap_FilterMode == *filter OrNullForBicubic &&
480 kYes_FilterConstraint == filterConstraint) { 480 kYes_FilterConstraint == filterConstraint) {
(...skipping 30 matching lines...) Expand all
511 } 511 }
512 512
513 GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams , bool willBeMipped, 513 GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams , bool willBeMipped,
514 SkSourceGammaTreatment gamma Treatment) { 514 SkSourceGammaTreatment gamma Treatment) {
515 SkAutoTUnref<GrTexture> original(this->refOriginalTexture(willBeMipped, gamm aTreatment)); 515 SkAutoTUnref<GrTexture> original(this->refOriginalTexture(willBeMipped, gamm aTreatment));
516 if (!original) { 516 if (!original) {
517 return nullptr; 517 return nullptr;
518 } 518 }
519 return copy_on_gpu(original, nullptr, copyParams); 519 return copy_on_gpu(original, nullptr, copyParams);
520 } 520 }
OLDNEW
« no previous file with comments | « src/gpu/GrTextureParamsAdjuster.h ('k') | src/gpu/GrTextureToYUVPlanes.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698