| 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "src/gpu/GrTextureMaker.h" |
| 9 | |
| 10 | #include "include/private/GrRecordingContext.h" |
| 11 | #include "src/gpu/GrColorSpaceXform.h" |
| 12 | #include "src/gpu/GrGpu.h" |
| 13 | #include "src/gpu/GrProxyProvider.h" |
| 14 | #include "src/gpu/GrRecordingContextPriv.h" |
| 15 | #include "src/gpu/SkGr.h" |
| 16 | |
| 17 | GrSurfaceProxyView GrTextureMaker::onView(GrMipMapped mipMapped) { |
| 18 | if (this->width() > this->context()->priv().caps()->maxTextureSize() || |
| 19 | this->height() > this->context()->priv().caps()->maxTextureSize()) { |
| 20 | return {}; |
| 21 | } |
| 22 | return this->refOriginalTextureProxyView(mipMapped); |
| 23 | } |
| 24 | |
| 25 | std::unique_ptr<GrFragmentProcessor> GrTextureMaker::createFragmentProcessor( |
| 26 | const SkMatrix& textureMatrix, |
| 27 | const SkRect& constraintRect, |
| 28 | FilterConstraint filterConstraint, |
| 29 | bool coordsLimitedToConstraintRect, |
| 30 | GrSamplerState::WrapMode wrapX, |
| 31 | GrSamplerState::WrapMode wrapY, |
| 32 | const GrSamplerState::Filter* filterOrNullForBicubic) { |
| 33 | const GrSamplerState::Filter* fmForDetermineDomain = filterOrNullForBicubic; |
| 34 | if (filterOrNullForBicubic && GrSamplerState::Filter::kMipMap == *filterOrNullForBicubic && |
| 35 | kYes_FilterConstraint == filterConstraint) { |
| 36 | // TODO: Here we should force a copy restricted to the constraintRect since MIP maps will |
| 37 | // read outside the constraint rect. However, as in the adjuster case, we aren't currently |
| 38 | // doing that. |
| 39 | // We instead we compute the domain as though were bilerping which is only correct if we |
| 40 | // only sample level 0. |
| 41 | static const GrSamplerState::Filter kBilerp = GrSamplerState::Filter::kBilerp; |
| 42 | fmForDetermineDomain = &kBilerp; |
| 43 | } |
| 44 | |
| 45 | GrSurfaceProxyView view; |
| 46 | if (filterOrNullForBicubic) { |
| 47 | view = this->view(*filterOrNullForBicubic); |
| 48 | } else { |
| 49 | view = this->view(GrMipMapped::kNo); |
| 50 | } |
| 51 | if (!view) { |
| 52 | return nullptr; |
| 53 | } |
| 54 | |
| 55 | SkRect domain; |
| 56 | DomainMode domainMode = |
| 57 | DetermineDomainMode(constraintRect, filterConstraint, coordsLimitedToConstraintRect, |
| 58 | view.proxy(), fmForDetermineDomain, &domain); |
| 59 | SkASSERT(kTightCopy_DomainMode != domainMode); |
| 60 | return this->createFragmentProcessorForSubsetAndFilter(std::move(view), textureMatrix, |
| 61 | domainMode, domain, wrapX, wrapY, |
| 62 | filterOrNullForBicubic); |
| 63 | } |
| 64 | |