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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 } | 366 } |
367 } | 367 } |
368 } | 368 } |
369 | 369 |
370 sk_sp<GrFragmentProcessor> GrTextureAdjuster::createFragmentProcessor( | 370 sk_sp<GrFragmentProcessor> GrTextureAdjuster::createFragmentProcessor( |
371 const SkMatrix& origTextureMatrix, | 371 const SkMatrix& origTextureMatrix, |
372 const SkRect& origConstraintRect, | 372 const SkRect& origConstraintRect, |
373 FilterConstraint filterConstraint, | 373 FilterConstraint filterConstraint, |
374 bool coordsLimitedToConstraintRect, | 374 bool coordsLimitedToConstraintRect, |
375 const GrTextureParams::FilterMode* filte
rOrNullForBicubic, | 375 const GrTextureParams::FilterMode* filte
rOrNullForBicubic, |
| 376 SkColorSpace* dstColorSpace, |
376 SkSourceGammaTreatment gammaTreatment) { | 377 SkSourceGammaTreatment gammaTreatment) { |
377 | 378 |
378 SkMatrix textureMatrix = origTextureMatrix; | 379 SkMatrix textureMatrix = origTextureMatrix; |
379 const SkIRect* contentArea = this->contentAreaOrNull(); | 380 const SkIRect* contentArea = this->contentAreaOrNull(); |
380 // Convert the constraintRect to be relative to the texture rather than the
content area so | 381 // Convert the constraintRect to be relative to the texture rather than the
content area so |
381 // that both rects are in the same coordinate system. | 382 // that both rects are in the same coordinate system. |
382 SkTCopyOnFirstWrite<SkRect> constraintRect(origConstraintRect); | 383 SkTCopyOnFirstWrite<SkRect> constraintRect(origConstraintRect); |
383 if (contentArea) { | 384 if (contentArea) { |
384 SkScalar l = SkIntToScalar(contentArea->fLeft); | 385 SkScalar l = SkIntToScalar(contentArea->fLeft); |
385 SkScalar t = SkIntToScalar(contentArea->fTop); | 386 SkScalar t = SkIntToScalar(contentArea->fTop); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 static const GrTextureParams::FilterMode kBilerp = GrTextureParams::kBil
erp_FilterMode; | 419 static const GrTextureParams::FilterMode kBilerp = GrTextureParams::kBil
erp_FilterMode; |
419 domainMode = | 420 domainMode = |
420 determine_domain_mode(*constraintRect, filterConstraint, coordsLimit
edToConstraintRect, | 421 determine_domain_mode(*constraintRect, filterConstraint, coordsLimit
edToConstraintRect, |
421 texture->width(), texture->height(), | 422 texture->width(), texture->height(), |
422 contentArea, &kBilerp, &domain); | 423 contentArea, &kBilerp, &domain); |
423 SkASSERT(kTightCopy_DomainMode != domainMode); | 424 SkASSERT(kTightCopy_DomainMode != domainMode); |
424 } | 425 } |
425 SkASSERT(kNoDomain_DomainMode == domainMode || | 426 SkASSERT(kNoDomain_DomainMode == domainMode || |
426 (domain.fLeft <= domain.fRight && domain.fTop <= domain.fBottom)); | 427 (domain.fLeft <= domain.fRight && domain.fTop <= domain.fBottom)); |
427 textureMatrix.postIDiv(texture->width(), texture->height()); | 428 textureMatrix.postIDiv(texture->width(), texture->height()); |
428 SkColorSpace* dstColorSpace = nullptr; // XFORMTODO | |
429 sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(this->get
ColorSpace(), | 429 sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(this->get
ColorSpace(), |
430 dstColorS
pace); | 430 dstColorS
pace); |
431 return create_fp_for_domain_and_filter(texture, std::move(colorSpaceXform),
textureMatrix, | 431 return create_fp_for_domain_and_filter(texture, std::move(colorSpaceXform),
textureMatrix, |
432 domainMode, domain, filterOrNullForBi
cubic); | 432 domainMode, domain, filterOrNullForBi
cubic); |
433 } | 433 } |
434 | 434 |
435 ////////////////////////////////////////////////////////////////////////////// | 435 ////////////////////////////////////////////////////////////////////////////// |
436 | 436 |
437 GrTexture* GrTextureMaker::refTextureForParams(const GrTextureParams& params, | 437 GrTexture* GrTextureMaker::refTextureForParams(const GrTextureParams& params, |
438 SkSourceGammaTreatment gammaTreat
ment) { | 438 SkSourceGammaTreatment gammaTreat
ment) { |
(...skipping 28 matching lines...) Expand all Loading... |
467 } | 467 } |
468 return result; | 468 return result; |
469 } | 469 } |
470 | 470 |
471 sk_sp<GrFragmentProcessor> GrTextureMaker::createFragmentProcessor( | 471 sk_sp<GrFragmentProcessor> GrTextureMaker::createFragmentProcessor( |
472 const SkMatrix& textureMatrix, | 472 const SkMatrix& textureMatrix, |
473 const SkRect& constraintRect, | 473 const SkRect& constraintRect, |
474 FilterConstraint filterConstraint, | 474 FilterConstraint filterConstraint, |
475 bool coordsLimitedToConstraintRect, | 475 bool coordsLimitedToConstraintRect, |
476 const GrTextureParams::FilterMode* filte
rOrNullForBicubic, | 476 const GrTextureParams::FilterMode* filte
rOrNullForBicubic, |
| 477 SkColorSpace* dstColorSpace, |
477 SkSourceGammaTreatment gammaTreatment) { | 478 SkSourceGammaTreatment gammaTreatment) { |
478 | 479 |
479 const GrTextureParams::FilterMode* fmForDetermineDomain = filterOrNullForBic
ubic; | 480 const GrTextureParams::FilterMode* fmForDetermineDomain = filterOrNullForBic
ubic; |
480 if (filterOrNullForBicubic && GrTextureParams::kMipMap_FilterMode == *filter
OrNullForBicubic && | 481 if (filterOrNullForBicubic && GrTextureParams::kMipMap_FilterMode == *filter
OrNullForBicubic && |
481 kYes_FilterConstraint == filterConstraint) { | 482 kYes_FilterConstraint == filterConstraint) { |
482 // TODo: Here we should force a copy restricted to the constraintRect si
nce MIP maps will | 483 // TODo: Here we should force a copy restricted to the constraintRect si
nce MIP maps will |
483 // read outside the constraint rect. However, as in the adjuster case, w
e aren't currently | 484 // read outside the constraint rect. However, as in the adjuster case, w
e aren't currently |
484 // doing that. | 485 // doing that. |
485 // We instead we compute the domain as though were bilerping which is on
ly correct if we | 486 // We instead we compute the domain as though were bilerping which is on
ly correct if we |
486 // only sample level 0. | 487 // only sample level 0. |
(...skipping 13 matching lines...) Expand all Loading... |
500 return nullptr; | 501 return nullptr; |
501 } | 502 } |
502 SkRect domain; | 503 SkRect domain; |
503 DomainMode domainMode = | 504 DomainMode domainMode = |
504 determine_domain_mode(constraintRect, filterConstraint, coordsLimitedToC
onstraintRect, | 505 determine_domain_mode(constraintRect, filterConstraint, coordsLimitedToC
onstraintRect, |
505 texture->width(), texture->height(), nullptr, fmFo
rDetermineDomain, | 506 texture->width(), texture->height(), nullptr, fmFo
rDetermineDomain, |
506 &domain); | 507 &domain); |
507 SkASSERT(kTightCopy_DomainMode != domainMode); | 508 SkASSERT(kTightCopy_DomainMode != domainMode); |
508 SkMatrix normalizedTextureMatrix = textureMatrix; | 509 SkMatrix normalizedTextureMatrix = textureMatrix; |
509 normalizedTextureMatrix.postIDiv(texture->width(), texture->height()); | 510 normalizedTextureMatrix.postIDiv(texture->width(), texture->height()); |
510 SkColorSpace* dstColorSpace = nullptr; // XFORMTODO | |
511 sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(this->get
ColorSpace(), | 511 sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(this->get
ColorSpace(), |
512 dstColorS
pace); | 512 dstColorS
pace); |
513 return create_fp_for_domain_and_filter(texture, std::move(colorSpaceXform), | 513 return create_fp_for_domain_and_filter(texture, std::move(colorSpaceXform), |
514 normalizedTextureMatrix, domainMode,
domain, | 514 normalizedTextureMatrix, domainMode,
domain, |
515 filterOrNullForBicubic); | 515 filterOrNullForBicubic); |
516 } | 516 } |
517 | 517 |
518 GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams
, bool willBeMipped, | 518 GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams
, bool willBeMipped, |
519 SkSourceGammaTreatment gamma
Treatment) { | 519 SkSourceGammaTreatment gamma
Treatment) { |
520 SkAutoTUnref<GrTexture> original(this->refOriginalTexture(willBeMipped, gamm
aTreatment)); | 520 SkAutoTUnref<GrTexture> original(this->refOriginalTexture(willBeMipped, gamm
aTreatment)); |
521 if (!original) { | 521 if (!original) { |
522 return nullptr; | 522 return nullptr; |
523 } | 523 } |
524 return copy_on_gpu(original, nullptr, copyParams); | 524 return copy_on_gpu(original, nullptr, copyParams); |
525 } | 525 } |
OLD | NEW |