aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrTextureAdjuster.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-03-27 11:08:16 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-27 16:31:02 +0000
commit3798c86f6885f0b47fb2e659a43b48a4468a97ef (patch)
tree8670d4adcc7889af63b4168256f0325aa78aa3bd /src/gpu/GrTextureAdjuster.cpp
parent465748c246dde8c131effdfa69aed82ef7a48af8 (diff)
Remove GrFragmentProcessor-derived class' GrTexture-based ctors
Split out into: https://skia-review.googlesource.com/c/8881/ (Switch GrTextureStripAtlas over to GrTextureProxies) https://skia-review.googlesource.com/c/8942/ (Wrap cached GrTextures in GrTextureProxies (e.g., blur profiles, nine-patch blurs, etc.)) https://skia-review.googlesource.com/c/8997/ (Clean up/remove unused GrFragmentProcessor-derived ctors) https://skia-review.googlesource.com/c/9191/ (Switch SkImageGenerator over to generating GrTextureProxies) https://skia-review.googlesource.com/c/9448/ (Switch GrYUVProvider over to GrTextureProxies) https://skia-review.googlesource.com/c/9559/ (Preparatory Proxification) https://skia-review.googlesource.com/c/9626/ (Consolidate Proxy caching code in GrResourceProvider) https://skia-review.googlesource.com/c/9683/ (More pre-emptive proxification) https://skia-review.googlesource.com/c/9917/ (Make experimental Perlin noise shader take texture proxies) https://skia-review.googlesource.com/c/9961/ (rename makeCopyForTextureParams to isACopyNeededForTextureParams) https://skia-review.googlesource.com/c/9945/ (Make SkImageCacherator be deferred) https://skia-review.googlesource.com/c/10180/ (Add new proxy-based DetermineDomainMode w/ test) Change-Id: Ia33389d92360e542a9d2bf395948deb04d017465 Reviewed-on: https://skia-review.googlesource.com/8823 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrTextureAdjuster.cpp')
-rw-r--r--src/gpu/GrTextureAdjuster.cpp61
1 files changed, 19 insertions, 42 deletions
diff --git a/src/gpu/GrTextureAdjuster.cpp b/src/gpu/GrTextureAdjuster.cpp
index 5dc71489ce..bb4d92aa54 100644
--- a/src/gpu/GrTextureAdjuster.cpp
+++ b/src/gpu/GrTextureAdjuster.cpp
@@ -14,20 +14,20 @@
#include "GrTexture.h"
#include "SkGr.h"
-GrTextureAdjuster::GrTextureAdjuster(GrContext* context, GrTexture* original,
+GrTextureAdjuster::GrTextureAdjuster(GrContext* context, sk_sp<GrTextureProxy> original,
SkAlphaType alphaType,
const SkIRect& contentArea, uint32_t uniqueID,
SkColorSpace* cs)
: INHERITED(contentArea.width(), contentArea.height(),
GrPixelConfigIsAlphaOnly(original->config()))
, fContext(context)
- , fOriginal(original)
+ , fOriginal(std::move(original))
, fAlphaType(alphaType)
, fColorSpace(cs)
, fUniqueID(uniqueID) {
- SkASSERT(SkIRect::MakeWH(original->width(), original->height()).contains(contentArea));
+ SkASSERT(SkIRect::MakeWH(fOriginal->width(), fOriginal->height()).contains(contentArea));
if (contentArea.fLeft > 0 || contentArea.fTop > 0 ||
- contentArea.fRight < original->width() || contentArea.fBottom < original->height()) {
+ contentArea.fRight < fOriginal->width() || contentArea.fBottom < fOriginal->height()) {
fContentArea.set(contentArea);
}
}
@@ -44,31 +44,6 @@ void GrTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) {
// We don't currently have a mechanism for notifications on Images!
}
-sk_sp<GrTextureProxy> GrTextureAdjuster::originalProxyRef() {
- return GrSurfaceProxy::MakeWrapped(sk_ref_sp(fOriginal));
-}
-
-GrTexture* GrTextureAdjuster::refCopy(const CopyParams& copyParams) {
- GrTexture* texture = this->originalTexture();
- const SkIRect* contentArea = this->contentAreaOrNull();
- GrUniqueKey key;
- this->makeCopyKey(copyParams, &key, nullptr);
- if (key.isValid()) {
- GrTexture* cachedCopy = fContext->resourceProvider()->findAndRefTextureByUniqueKey(key);
- if (cachedCopy) {
- return cachedCopy;
- }
- }
- GrTexture* copy = CopyOnGpu(texture, contentArea, copyParams);
- if (copy) {
- if (key.isValid()) {
- fContext->resourceProvider()->assignUniqueKeyToTexture(key, copy);
- this->didCacheCopy(key);
- }
- }
- return copy;
-}
-
sk_sp<GrTextureProxy> GrTextureAdjuster::refTextureProxyCopy(const CopyParams& copyParams) {
GrUniqueKey key;
this->makeCopyKey(copyParams, &key, nullptr);
@@ -92,10 +67,11 @@ sk_sp<GrTextureProxy> GrTextureAdjuster::refTextureProxyCopy(const CopyParams& c
return copy;
}
-GrTexture* GrTextureAdjuster::refTextureSafeForParams(const GrSamplerParams& params,
- SkIPoint* outOffset,
- SkScalar scaleAdjust[2]) {
- GrTexture* texture = this->originalTexture();
+sk_sp<GrTextureProxy> GrTextureAdjuster::refTextureProxySafeForParams(
+ const GrSamplerParams& params,
+ SkIPoint* outOffset,
+ SkScalar scaleAdjust[2]) {
+ sk_sp<GrTextureProxy> proxy = this->originalProxyRef();
CopyParams copyParams;
const SkIRect* contentArea = this->contentAreaOrNull();
@@ -110,7 +86,7 @@ GrTexture* GrTextureAdjuster::refTextureSafeForParams(const GrSamplerParams& par
copyParams.fWidth = contentArea->width();
copyParams.fHeight = contentArea->height();
copyParams.fFilter = GrSamplerParams::kBilerp_FilterMode;
- } else if (!fContext->getGpu()->isACopyNeededForTextureParams(texture, params, &copyParams,
+ } else if (!fContext->getGpu()->isACopyNeededForTextureParams(proxy.get(), params, &copyParams,
scaleAdjust)) {
if (outOffset) {
if (contentArea) {
@@ -119,10 +95,10 @@ GrTexture* GrTextureAdjuster::refTextureSafeForParams(const GrSamplerParams& par
outOffset->set(0, 0);
}
}
- return SkRef(texture);
+ return proxy;
}
- GrTexture* copy = this->refCopy(copyParams);
+ sk_sp<GrTextureProxy> copy = this->refTextureProxyCopy(copyParams);
if (copy && outOffset) {
outOffset->set(0, 0);
}
@@ -155,20 +131,20 @@ sk_sp<GrFragmentProcessor> GrTextureAdjuster::createFragmentProcessor(
params.setFilterMode(*filterOrNullForBicubic);
}
SkScalar scaleAdjust[2] = { 1.0f, 1.0f };
- sk_sp<GrTexture> texture(this->refTextureSafeForParams(params, nullptr, scaleAdjust));
- if (!texture) {
+ sk_sp<GrTextureProxy> proxy(this->refTextureProxySafeForParams(params, nullptr, scaleAdjust));
+ if (!proxy) {
return nullptr;
}
// If we made a copy then we only copied the contentArea, in which case the new texture is all
// content.
- if (texture.get() != this->originalTexture()) {
+ if (proxy.get() != this->originalProxy()) {
contentArea = nullptr;
textureMatrix.postScale(scaleAdjust[0], scaleAdjust[1]);
}
DomainMode domainMode =
DetermineDomainMode(*constraintRect, filterConstraint, coordsLimitedToConstraintRect,
- texture->width(), texture->height(),
+ proxy.get(),
contentArea, filterOrNullForBicubic,
&domain);
if (kTightCopy_DomainMode == domainMode) {
@@ -182,7 +158,7 @@ sk_sp<GrFragmentProcessor> GrTextureAdjuster::createFragmentProcessor(
static const GrSamplerParams::FilterMode kBilerp = GrSamplerParams::kBilerp_FilterMode;
domainMode =
DetermineDomainMode(*constraintRect, filterConstraint, coordsLimitedToConstraintRect,
- texture->width(), texture->height(),
+ proxy.get(),
contentArea, &kBilerp, &domain);
SkASSERT(kTightCopy_DomainMode != domainMode);
}
@@ -190,7 +166,8 @@ sk_sp<GrFragmentProcessor> GrTextureAdjuster::createFragmentProcessor(
(domain.fLeft <= domain.fRight && domain.fTop <= domain.fBottom));
sk_sp<GrColorSpaceXform> colorSpaceXform = GrColorSpaceXform::Make(fColorSpace,
dstColorSpace);
- return CreateFragmentProcessorForDomainAndFilter(texture.get(), std::move(colorSpaceXform),
+ return CreateFragmentProcessorForDomainAndFilter(fContext->resourceProvider(), std::move(proxy),
+ std::move(colorSpaceXform),
textureMatrix, domainMode, domain,
filterOrNullForBicubic);
}