Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Unified Diff: src/gpu/GrTextureParamsAdjuster.cpp

Issue 1594483003: Texturing support for RECTANGLE textures. (Closed) Base URL: https://skia.googlesource.com/skia.git@rectangle
Patch Set: fix float->int warnings Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrTextureParamsAdjuster.h ('k') | src/gpu/gl/GrGLCaps.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrTextureParamsAdjuster.cpp
diff --git a/src/gpu/GrTextureParamsAdjuster.cpp b/src/gpu/GrTextureParamsAdjuster.cpp
index 336ab6b10c4a8f37d9bf96763be57f7144e6c3c7..fd17d2adb47c6b2c8f6f79ed7563951da649eb68 100644
--- a/src/gpu/GrTextureParamsAdjuster.cpp
+++ b/src/gpu/GrTextureParamsAdjuster.cpp
@@ -133,6 +133,28 @@ GrTextureAdjuster::GrTextureAdjuster(GrTexture* original,
}
}
+GrTexture* GrTextureAdjuster::refCopy(const CopyParams& copyParams) {
+ GrTexture* texture = this->originalTexture();
+ GrContext* context = texture->getContext();
+ const SkIRect* contentArea = this->contentAreaOrNull();
+ GrUniqueKey key;
+ this->makeCopyKey(copyParams, &key);
+ if (key.isValid()) {
+ GrTexture* cachedCopy = context->textureProvider()->findAndRefTextureByUniqueKey(key);
+ if (cachedCopy) {
+ return cachedCopy;
+ }
+ }
+ GrTexture* copy = copy_on_gpu(texture, contentArea, copyParams);
+ if (copy) {
+ if (key.isValid()) {
+ copy->resourcePriv().setUniqueKey(key);
+ this->didCacheCopy(key);
+ }
+ }
+ return copy;
+}
+
GrTexture* GrTextureAdjuster::refTextureSafeForParams(const GrTextureParams& params,
SkIPoint* outOffset) {
GrTexture* texture = this->originalTexture();
@@ -146,8 +168,7 @@ GrTexture* GrTextureAdjuster::refTextureSafeForParams(const GrTextureParams& par
copyParams.fWidth = contentArea->width();
copyParams.fHeight = contentArea->height();
copyParams.fFilter = GrTextureParams::kBilerp_FilterMode;
- } else if (!context->getGpu()->makeCopyForTextureParams(texture->width(), texture->height(),
- params, &copyParams)) {
+ } else if (!context->getGpu()->makeCopyForTextureParams(texture, params, &copyParams)) {
if (outOffset) {
if (contentArea) {
outOffset->set(contentArea->fLeft, contentArea->fRight);
@@ -157,25 +178,12 @@ GrTexture* GrTextureAdjuster::refTextureSafeForParams(const GrTextureParams& par
}
return SkRef(texture);
}
- GrUniqueKey key;
- this->makeCopyKey(copyParams, &key);
- if (key.isValid()) {
- GrTexture* result = context->textureProvider()->findAndRefTextureByUniqueKey(key);
- if (result) {
- return result;
- }
- }
- GrTexture* result = copy_on_gpu(texture, contentArea, copyParams);
- if (result) {
- if (key.isValid()) {
- result->resourcePriv().setUniqueKey(key);
- this->didCacheCopy(key);
- }
- if (outOffset) {
- outOffset->set(0, 0);
- }
+
+ GrTexture* copy = this->refCopy(copyParams);
+ if (copy && outOffset) {
+ outOffset->set(0, 0);
}
- return result;
+ return copy;
}
enum DomainMode {
@@ -352,7 +360,7 @@ static const GrFragmentProcessor* create_fp_for_domain_and_filter(
return GrBicubicEffect::Create(texture, textureMatrix, domain);
} else {
static const SkShader::TileMode kClampClamp[] =
- { SkShader::kClamp_TileMode, SkShader::kClamp_TileMode };
+ { SkShader::kClamp_TileMode, SkShader::kClamp_TileMode };
return GrBicubicEffect::Create(texture, textureMatrix, kClampClamp);
}
}
@@ -378,7 +386,20 @@ const GrFragmentProcessor* GrTextureAdjuster::createFragmentProcessor(
}
SkRect domain;
- GrTexture* texture = this->originalTexture();
+ GrTextureParams params;
+ if (filterOrNullForBicubic) {
+ params.setFilterMode(*filterOrNullForBicubic);
+ }
+ SkAutoTUnref<GrTexture> texture(this->refTextureSafeForParams(params, nullptr));
+ if (!texture) {
+ return nullptr;
+ }
+ // If we made a copy then we only copied the contentArea, in which case the new texture is all
+ // content.
+ if (texture != this->originalTexture()) {
+ contentArea = nullptr;
+ }
+
DomainMode domainMode =
determine_domain_mode(*constraintRect, filterConstraint, coordsLimitedToConstraintRect,
texture->width(), texture->height(),
« no previous file with comments | « src/gpu/GrTextureParamsAdjuster.h ('k') | src/gpu/gl/GrGLCaps.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698