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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 (domain.fLeft <= domain.fRight && domain.fTop <= domain.fBottom)); | 403 (domain.fLeft <= domain.fRight && domain.fTop <= domain.fBottom)); |
404 textureMatrix.postIDiv(texture->width(), texture->height()); | 404 textureMatrix.postIDiv(texture->width(), texture->height()); |
405 return create_fp_for_domain_and_filter(texture, textureMatrix, domainMode, d
omain, | 405 return create_fp_for_domain_and_filter(texture, textureMatrix, domainMode, d
omain, |
406 filterOrNullForBicubic); | 406 filterOrNullForBicubic); |
407 } | 407 } |
408 | 408 |
409 ////////////////////////////////////////////////////////////////////////////// | 409 ////////////////////////////////////////////////////////////////////////////// |
410 | 410 |
411 GrTexture* GrTextureMaker::refTextureForParams(const GrTextureParams& params) { | 411 GrTexture* GrTextureMaker::refTextureForParams(const GrTextureParams& params) { |
412 CopyParams copyParams; | 412 CopyParams copyParams; |
| 413 bool willBeMipped = params.filterMode() == GrTextureParams::kMipMap_FilterMo
de; |
| 414 |
| 415 if (!fContext->caps()->mipMapSupport()) { |
| 416 willBeMipped = false; |
| 417 } |
| 418 |
413 if (!fContext->getGpu()->makeCopyForTextureParams(this->width(), this->heigh
t(), params, | 419 if (!fContext->getGpu()->makeCopyForTextureParams(this->width(), this->heigh
t(), params, |
414 ©Params)) { | 420 ©Params)) { |
415 return this->refOriginalTexture(); | 421 return this->refOriginalTexture(willBeMipped); |
416 } | 422 } |
417 GrUniqueKey copyKey; | 423 GrUniqueKey copyKey; |
418 this->makeCopyKey(copyParams, ©Key); | 424 this->makeCopyKey(copyParams, ©Key); |
419 if (copyKey.isValid()) { | 425 if (copyKey.isValid()) { |
420 GrTexture* result = fContext->textureProvider()->findAndRefTextureByUniq
ueKey(copyKey); | 426 GrTexture* result = fContext->textureProvider()->findAndRefTextureByUniq
ueKey(copyKey); |
421 if (result) { | 427 if (result) { |
422 return result; | 428 return result; |
423 } | 429 } |
424 } | 430 } |
425 | 431 |
426 GrTexture* result = this->generateTextureForParams(copyParams); | 432 GrTexture* result = this->generateTextureForParams(copyParams, willBeMipped)
; |
427 if (!result) { | 433 if (!result) { |
428 return nullptr; | 434 return nullptr; |
429 } | 435 } |
430 | 436 |
431 if (copyKey.isValid()) { | 437 if (copyKey.isValid()) { |
432 fContext->textureProvider()->assignUniqueKeyToTexture(copyKey, result); | 438 fContext->textureProvider()->assignUniqueKeyToTexture(copyKey, result); |
433 this->didCacheCopy(copyKey); | 439 this->didCacheCopy(copyKey); |
434 } | 440 } |
435 return result; | 441 return result; |
436 } | 442 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 determine_domain_mode(constraintRect, filterConstraint, coordsLimitedToC
onstraintRect, | 476 determine_domain_mode(constraintRect, filterConstraint, coordsLimitedToC
onstraintRect, |
471 texture->width(), texture->height(), nullptr, fmFo
rDetermineDomain, | 477 texture->width(), texture->height(), nullptr, fmFo
rDetermineDomain, |
472 &domain); | 478 &domain); |
473 SkASSERT(kTightCopy_DomainMode != domainMode); | 479 SkASSERT(kTightCopy_DomainMode != domainMode); |
474 SkMatrix normalizedTextureMatrix = textureMatrix; | 480 SkMatrix normalizedTextureMatrix = textureMatrix; |
475 normalizedTextureMatrix.postIDiv(texture->width(), texture->height()); | 481 normalizedTextureMatrix.postIDiv(texture->width(), texture->height()); |
476 return create_fp_for_domain_and_filter(texture, normalizedTextureMatrix, dom
ainMode, domain, | 482 return create_fp_for_domain_and_filter(texture, normalizedTextureMatrix, dom
ainMode, domain, |
477 filterOrNullForBicubic); | 483 filterOrNullForBicubic); |
478 } | 484 } |
479 | 485 |
480 GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams
) { | 486 GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams
, |
481 SkAutoTUnref<GrTexture> original(this->refOriginalTexture()); | 487 bool willBeMipped) { |
| 488 SkAutoTUnref<GrTexture> original(this->refOriginalTexture(willBeMipped)); |
482 if (!original) { | 489 if (!original) { |
483 return nullptr; | 490 return nullptr; |
484 } | 491 } |
485 return copy_on_gpu(original, nullptr, copyParams); | 492 return copy_on_gpu(original, nullptr, copyParams); |
486 } | 493 } |
OLD | NEW |