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