| OLD | NEW |
| 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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 (domain.fLeft <= domain.fRight && domain.fTop <= domain.fBottom)); | 424 (domain.fLeft <= domain.fRight && domain.fTop <= domain.fBottom)); |
| 425 textureMatrix.postIDiv(texture->width(), texture->height()); | 425 textureMatrix.postIDiv(texture->width(), texture->height()); |
| 426 return create_fp_for_domain_and_filter(texture, textureMatrix, domainMode, d
omain, | 426 return create_fp_for_domain_and_filter(texture, textureMatrix, domainMode, d
omain, |
| 427 filterOrNullForBicubic); | 427 filterOrNullForBicubic); |
| 428 } | 428 } |
| 429 | 429 |
| 430 ////////////////////////////////////////////////////////////////////////////// | 430 ////////////////////////////////////////////////////////////////////////////// |
| 431 | 431 |
| 432 GrTexture* GrTextureMaker::refTextureForParams(const GrTextureParams& params) { | 432 GrTexture* GrTextureMaker::refTextureForParams(const GrTextureParams& params) { |
| 433 CopyParams copyParams; | 433 CopyParams copyParams; |
| 434 bool willBeMipped = params.filterMode() == GrTextureParams::kMipMap_FilterMo
de; |
| 435 |
| 436 if (!fContext->caps()->mipMapSupport()) { |
| 437 willBeMipped = false; |
| 438 } |
| 439 |
| 434 if (!fContext->getGpu()->makeCopyForTextureParams(this->width(), this->heigh
t(), params, | 440 if (!fContext->getGpu()->makeCopyForTextureParams(this->width(), this->heigh
t(), params, |
| 435 ©Params)) { | 441 ©Params)) { |
| 436 return this->refOriginalTexture(); | 442 return this->refOriginalTexture(willBeMipped); |
| 437 } | 443 } |
| 438 GrUniqueKey copyKey; | 444 GrUniqueKey copyKey; |
| 439 this->makeCopyKey(copyParams, ©Key); | 445 this->makeCopyKey(copyParams, ©Key); |
| 440 if (copyKey.isValid()) { | 446 if (copyKey.isValid()) { |
| 441 GrTexture* result = fContext->textureProvider()->findAndRefTextureByUniq
ueKey(copyKey); | 447 GrTexture* result = fContext->textureProvider()->findAndRefTextureByUniq
ueKey(copyKey); |
| 442 if (result) { | 448 if (result) { |
| 443 return result; | 449 return result; |
| 444 } | 450 } |
| 445 } | 451 } |
| 446 | 452 |
| 447 GrTexture* result = this->generateTextureForParams(copyParams); | 453 GrTexture* result = this->generateTextureForParams(copyParams, willBeMipped)
; |
| 448 if (!result) { | 454 if (!result) { |
| 449 return nullptr; | 455 return nullptr; |
| 450 } | 456 } |
| 451 | 457 |
| 452 if (copyKey.isValid()) { | 458 if (copyKey.isValid()) { |
| 453 fContext->textureProvider()->assignUniqueKeyToTexture(copyKey, result); | 459 fContext->textureProvider()->assignUniqueKeyToTexture(copyKey, result); |
| 454 this->didCacheCopy(copyKey); | 460 this->didCacheCopy(copyKey); |
| 455 } | 461 } |
| 456 return result; | 462 return result; |
| 457 } | 463 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 determine_domain_mode(constraintRect, filterConstraint, coordsLimitedToC
onstraintRect, | 497 determine_domain_mode(constraintRect, filterConstraint, coordsLimitedToC
onstraintRect, |
| 492 texture->width(), texture->height(), nullptr, fmFo
rDetermineDomain, | 498 texture->width(), texture->height(), nullptr, fmFo
rDetermineDomain, |
| 493 &domain); | 499 &domain); |
| 494 SkASSERT(kTightCopy_DomainMode != domainMode); | 500 SkASSERT(kTightCopy_DomainMode != domainMode); |
| 495 SkMatrix normalizedTextureMatrix = textureMatrix; | 501 SkMatrix normalizedTextureMatrix = textureMatrix; |
| 496 normalizedTextureMatrix.postIDiv(texture->width(), texture->height()); | 502 normalizedTextureMatrix.postIDiv(texture->width(), texture->height()); |
| 497 return create_fp_for_domain_and_filter(texture, normalizedTextureMatrix, dom
ainMode, domain, | 503 return create_fp_for_domain_and_filter(texture, normalizedTextureMatrix, dom
ainMode, domain, |
| 498 filterOrNullForBicubic); | 504 filterOrNullForBicubic); |
| 499 } | 505 } |
| 500 | 506 |
| 501 GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams
) { | 507 GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams
, |
| 502 SkAutoTUnref<GrTexture> original(this->refOriginalTexture()); | 508 bool willBeMipped) { |
| 509 SkAutoTUnref<GrTexture> original(this->refOriginalTexture(willBeMipped)); |
| 503 if (!original) { | 510 if (!original) { |
| 504 return nullptr; | 511 return nullptr; |
| 505 } | 512 } |
| 506 return copy_on_gpu(original, nullptr, copyParams); | 513 return copy_on_gpu(original, nullptr, copyParams); |
| 507 } | 514 } |
| OLD | NEW |