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

Unified Diff: src/gpu/GrTextureParamsAdjuster.cpp

Issue 1410383008: Clarify subrect semantics for GrTextureAdjuster and handle mip maps correctly. (Closed) Base URL: https://skia.googlesource.com/skia.git@producer
Patch Set: Address comment Created 5 years, 2 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/SkGr.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 b1faf14bb5d9d21b4f4d8a16c8c05cbe0eb788ef..26fb8a6aa97fbb6a26b2ee81a076009075a9cb0e 100644
--- a/src/gpu/GrTextureParamsAdjuster.cpp
+++ b/src/gpu/GrTextureParamsAdjuster.cpp
@@ -118,11 +118,11 @@ static GrTexture* copy_on_gpu(GrTexture* inputTexture, const SkIRect* subset,
return copy.detach();
}
-GrTextureAdjuster::GrTextureAdjuster(GrTexture* original, const SkIRect& subset)
+GrTextureAdjuster::GrTextureAdjuster(GrTexture* original, const SkIRect& contentArea)
: fOriginal(original) {
- if (subset.fLeft > 0 || subset.fTop > 0 ||
- subset.fRight < original->width() || subset.fBottom < original->height()) {
- fSubset.set(subset);
+ if (contentArea.fLeft > 0 || contentArea.fTop > 0 ||
+ contentArea.fRight < original->width() || contentArea.fBottom < original->height()) {
+ fContentArea.set(contentArea);
}
}
@@ -131,13 +131,19 @@ GrTexture* GrTextureAdjuster::refTextureSafeForParams(const GrTextureParams& par
GrTexture* texture = this->originalTexture();
GrContext* context = texture->getContext();
CopyParams copyParams;
- const SkIRect* subset = this->subset();
-
- if (!context->getGpu()->makeCopyForTextureParams(texture->width(), texture->height(), params,
- &copyParams)) {
+ const SkIRect* contentArea = this->contentArea();
+
+ if (contentArea && GrTextureParams::kMipMap_FilterMode == params.filterMode()) {
+ // If we generate a MIP chain for texture it will read pixel values from outside the content
+ // area.
+ copyParams.fWidth = contentArea->width();
+ copyParams.fHeight = contentArea->height();
+ copyParams.fFilter = GrTextureParams::kBilerp_FilterMode;
+ } else if (!context->getGpu()->makeCopyForTextureParams(texture->width(), texture->height(),
+ params, &copyParams)) {
if (outOffset) {
- if (subset) {
- outOffset->set(subset->fLeft, subset->fRight);
+ if (contentArea) {
+ outOffset->set(contentArea->fLeft, contentArea->fRight);
} else {
outOffset->set(0, 0);
}
@@ -152,7 +158,7 @@ GrTexture* GrTextureAdjuster::refTextureSafeForParams(const GrTextureParams& par
return result;
}
}
- GrTexture* result = copy_on_gpu(texture, subset, copyParams);
+ GrTexture* result = copy_on_gpu(texture, contentArea, copyParams);
if (result) {
if (key.isValid()) {
result->resourcePriv().setUniqueKey(key);
« no previous file with comments | « src/gpu/GrTextureParamsAdjuster.h ('k') | src/gpu/SkGr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698