Revert "Limit GL_TEXTURE_RECTANGLE filtering to bilinear."
authorBen Wagner <benjaminwagner@google.com>
Sun, 6 Nov 2016 12:46:37 +0000 (12:46 +0000)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Sun, 6 Nov 2016 12:46:50 +0000 (12:46 +0000)
This reverts commit 4d53c44aa6e8e0d1b6537f83e4287e5a1423ac75.

Reason for revert: Depends on https://skia-review.googlesource.com/c/4383/ which I need to revert.

Original change's description:
> Limit GL_TEXTURE_RECTANGLE filtering to bilinear.
>
> Adds a clamp for GrTexture filtering that can be set by a subclass at construction. The clamping is performed by GrTextureParams. GrGLTexture limits filtering to bilinear for rectangle and external textures.
>
> Also moves samplerType() to GrTexturePriv from GrTexture.
>
> BUG=skia:5932
>
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4352
>
> Change-Id: I1f023d4f4133e7eb393367580c0558257e56c8db
> Reviewed-on: https://skia-review.googlesource.com/4352
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Chris Dalton <csmartdalton@google.com>
>

TBR=bsalomon@google.com,csmartdalton@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=662630

Change-Id: I012aa208594ccff0bb81bece8110a38e1f83ae00
Reviewed-on: https://skia-review.googlesource.com/4444
Commit-Queue: Ben Wagner <benjaminwagner@google.com>
Reviewed-by: Ben Wagner <benjaminwagner@google.com>
include/gpu/GrTexture.h
src/gpu/GrProgramDesc.cpp
src/gpu/GrTexture.cpp
src/gpu/GrTextureAccess.cpp
src/gpu/GrTexturePriv.h
src/gpu/effects/GrSimpleTextureEffect.h
src/gpu/gl/GrGLTexture.cpp
src/gpu/glsl/GrGLSLProgramBuilder.cpp
src/gpu/vk/GrVkTexture.cpp
tests/RectangleTextureTest.cpp

index 8fa0db9..211f193 100644 (file)
 #define GrTexture_DEFINED
 
 #include "GrSurface.h"
-#include "GrTextureParams.h"
 #include "SkPoint.h"
 #include "SkRefCnt.h"
 
+class GrTextureParams;
 class GrTexturePriv;
 
 class GrTexture : virtual public GrSurface {
 public:
     GrTexture* asTexture() override { return this; }
     const GrTexture* asTexture() const override { return this; }
+    GrSLType samplerType() const { return fSamplerType; }
 
     /**
      *  Return the native ID or handle to the texture, depending on the
@@ -45,8 +46,7 @@ public:
     inline const GrTexturePriv texturePriv() const;
 
 protected:
-    GrTexture(GrGpu*, const GrSurfaceDesc&, GrSLType samplerType,
-              GrTextureParams::FilterMode highestFilterMode, bool wasMipMapDataProvided);
+    GrTexture(GrGpu*, const GrSurfaceDesc&, GrSLType, bool wasMipMapDataProvided);
 
     void validateDesc() const;
 
@@ -61,11 +61,11 @@ private:
         kValid_MipMapsStatus
     };
 
-    GrSLType                    fSamplerType;
-    GrTextureParams::FilterMode fHighestFilterMode;
-    MipMapsStatus               fMipMapsStatus;
-    int                         fMaxMipMapLevel;
-    SkSourceGammaTreatment      fGammaTreatment;
+    GrSLType               fSamplerType;
+    MipMapsStatus          fMipMapsStatus;
+    int                    fMaxMipMapLevel;
+    SkSourceGammaTreatment fGammaTreatment;
+
     friend class GrTexturePriv;
 
     typedef GrSurface INHERITED;
index fa728ed..3b0e54b 100644 (file)
@@ -9,7 +9,6 @@
 #include "GrProcessor.h"
 #include "GrPipeline.h"
 #include "GrRenderTargetPriv.h"
-#include "GrTexturePriv.h"
 #include "SkChecksum.h"
 #include "glsl/GrGLSLFragmentProcessor.h"
 #include "glsl/GrGLSLFragmentShaderBuilder.h"
@@ -46,8 +45,7 @@ static void add_sampler_keys(GrProcessorKeyBuilder* b, const GrProcessor& proc,
     for (; i < numTextures; ++i) {
         const GrTextureAccess& access = proc.textureAccess(i);
         const GrTexture* tex = access.getTexture();
-        k16[i] = sampler_key(tex->texturePriv().samplerType(), tex->config(),
-                             access.getVisibility(), caps);
+        k16[i] = sampler_key(tex->samplerType(), tex->config(), access.getVisibility(), caps);
     }
     for (; i < numSamplers; ++i) {
         const GrBufferAccess& access = proc.bufferAccess(i - numTextures);
index 6fc1580..de1135a 100644 (file)
@@ -70,10 +70,9 @@ GrSurfaceOrigin resolve_origin(const GrSurfaceDesc& desc) {
 
 //////////////////////////////////////////////////////////////////////////////
 GrTexture::GrTexture(GrGpu* gpu, const GrSurfaceDesc& desc, GrSLType samplerType,
-                     GrTextureParams::FilterMode highestFilterMode, bool wasMipMapDataProvided)
+                     bool wasMipMapDataProvided)
     : INHERITED(gpu, desc)
     , fSamplerType(samplerType)
-    , fHighestFilterMode(highestFilterMode)
     // Gamma treatment is explicitly set after creation via GrTexturePriv
     , fGammaTreatment(SkSourceGammaTreatment::kIgnore) {
     if (wasMipMapDataProvided) {
index bddbd5a..675bc20 100644 (file)
@@ -8,7 +8,6 @@
 #include "GrTextureAccess.h"
 #include "GrColor.h"
 #include "GrTexture.h"
-#include "GrTexturePriv.h"
 
 GrTextureAccess::GrTextureAccess() {}
 
@@ -29,7 +28,6 @@ void GrTextureAccess::reset(GrTexture* texture,
     SkASSERT(texture);
     fTexture.set(SkRef(texture), kRead_GrIOType);
     fParams = params;
-    fParams.setFilterMode(SkTMin(params.filterMode(), texture->texturePriv().highestFilterMode()));
     fVisibility = visibility;
 }
 
@@ -39,7 +37,6 @@ void GrTextureAccess::reset(GrTexture* texture,
                             GrShaderFlags visibility) {
     SkASSERT(texture);
     fTexture.set(SkRef(texture), kRead_GrIOType);
-    filterMode = SkTMin(filterMode, texture->texturePriv().highestFilterMode());
     fParams.reset(tileXAndY, filterMode);
     fVisibility = visibility;
 }
index c4c1855..c4e6538 100644 (file)
@@ -49,11 +49,6 @@ public:
         return fTexture->fMaxMipMapLevel;
     }
 
-    GrSLType samplerType() const { return fTexture->fSamplerType; }
-
-    /** The filter used is clamped to this value in GrTextureAccess. */
-    GrTextureParams::FilterMode highestFilterMode() const { return fTexture->fHighestFilterMode; }
-
     void setGammaTreatment(SkSourceGammaTreatment gammaTreatment) const {
         fTexture->fGammaTreatment = gammaTreatment;
     }
index fced736..8242362 100644 (file)
@@ -31,8 +31,8 @@ public:
     /* clamp mode */
     static sk_sp<GrFragmentProcessor> Make(GrTexture* tex,
                                            sk_sp<GrColorSpaceXform> colorSpaceXform,
-                                           const SkMatrix& matrix,
-                                           GrTextureParams::FilterMode filterMode) {
+                                            const SkMatrix& matrix,
+                                            GrTextureParams::FilterMode filterMode) {
         return sk_sp<GrFragmentProcessor>(
             new GrSimpleTextureEffect(tex, std::move(colorSpaceXform), matrix, filterMode));
     }
index c45d08f..ec0ad3b 100644 (file)
@@ -12,7 +12,7 @@
 #define GPUGL static_cast<GrGLGpu*>(this->getGpu())
 #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
 
-static inline GrSLType sampler_type(const GrGLTexture::IDDesc& idDesc, const GrGLGpu* gpu) {
+inline static GrSLType sampler_type(const GrGLTexture::IDDesc& idDesc, const GrGLGpu* gpu) {
     if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_EXTERNAL) {
         SkASSERT(gpu->glCaps().glslCaps()->externalTextureSupport());
         return kTextureExternalSampler_GrSLType;
@@ -25,19 +25,11 @@ static inline GrSLType sampler_type(const GrGLTexture::IDDesc& idDesc, const GrG
     }
 }
 
-static inline GrTextureParams::FilterMode highest_filter_mode(const GrGLTexture::IDDesc& idDesc) {
-    if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_RECTANGLE ||
-        idDesc.fInfo.fTarget == GR_GL_TEXTURE_EXTERNAL) {
-        return GrTextureParams::kBilerp_FilterMode;
-    }
-    return GrTextureParams::kMipMap_FilterMode;
-}
-
 // Because this class is virtually derived from GrSurface we must explicitly call its constructor.
 GrGLTexture::GrGLTexture(GrGLGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc& desc,
                          const IDDesc& idDesc)
     : GrSurface(gpu, desc)
-    , INHERITED(gpu, desc, sampler_type(idDesc, gpu), highest_filter_mode(idDesc), false) {
+    , INHERITED(gpu, desc, sampler_type(idDesc, gpu), false) {
     this->init(desc, idDesc);
     this->registerWithCache(budgeted);
 }
@@ -46,15 +38,14 @@ GrGLTexture::GrGLTexture(GrGLGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc&
                          const IDDesc& idDesc,
                          bool wasMipMapDataProvided)
     : GrSurface(gpu, desc)
-    , INHERITED(gpu, desc, sampler_type(idDesc, gpu), highest_filter_mode(idDesc),
-                wasMipMapDataProvided) {
+    , INHERITED(gpu, desc, sampler_type(idDesc, gpu), wasMipMapDataProvided) {
     this->init(desc, idDesc);
     this->registerWithCache(budgeted);
 }
 
 GrGLTexture::GrGLTexture(GrGLGpu* gpu, Wrapped, const GrSurfaceDesc& desc, const IDDesc& idDesc)
     : GrSurface(gpu, desc)
-    , INHERITED(gpu, desc, sampler_type(idDesc, gpu), highest_filter_mode(idDesc), false) {
+    , INHERITED(gpu, desc, sampler_type(idDesc, gpu), false) {
     this->init(desc, idDesc);
     this->registerWithCacheWrapped();
 }
@@ -62,8 +53,7 @@ GrGLTexture::GrGLTexture(GrGLGpu* gpu, Wrapped, const GrSurfaceDesc& desc, const
 GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc,
                          bool wasMipMapDataProvided)
     : GrSurface(gpu, desc)
-    , INHERITED(gpu, desc, sampler_type(idDesc, gpu), highest_filter_mode(idDesc),
-                wasMipMapDataProvided) {
+    , INHERITED(gpu, desc, sampler_type(idDesc, gpu), wasMipMapDataProvided) {
     this->init(desc, idDesc);
 }
 
index 5b1fbe1..abfeafd 100644 (file)
@@ -8,7 +8,6 @@
 #include "glsl/GrGLSLProgramBuilder.h"
 
 #include "GrPipeline.h"
-#include "GrTexturePriv.h"
 #include "glsl/GrGLSLFragmentProcessor.h"
 #include "glsl/GrGLSLGeometryProcessor.h"
 #include "glsl/GrGLSLVarying.h"
@@ -245,7 +244,7 @@ void GrGLSLProgramBuilder::emitSamplers(const GrProcessor& processor,
     int numTextures = processor.numTextures();
     for (int t = 0; t < numTextures; ++t) {
         const GrTextureAccess& access = processor.textureAccess(t);
-        GrSLType samplerType = access.getTexture()->texturePriv().samplerType();
+        GrSLType samplerType = access.getTexture()->samplerType();
         if (kTextureExternalSampler_GrSLType == samplerType) {
             const char* externalFeatureString = this->glslCaps()->externalTextureExtensionString();
             // We shouldn't ever create a GrGLTexture that requires external sampler type
index 3b6108c..8c461f8 100644 (file)
@@ -24,8 +24,7 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu,
                          const GrVkImageView* view)
     : GrSurface(gpu, desc)
     , GrVkImage(info, GrVkImage::kNot_Wrapped)
-    , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, GrTextureParams::kMipMap_FilterMode,
-                desc.fIsMipMapped)
+    , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, desc.fIsMipMapped) 
     , fTextureView(view)
     , fLinearTextureView(nullptr) {
     this->registerWithCache(budgeted);
@@ -39,8 +38,7 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu,
                          GrVkImage::Wrapped wrapped)
     : GrSurface(gpu, desc)
     , GrVkImage(info, wrapped)
-    , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, GrTextureParams::kMipMap_FilterMode,
-                desc.fIsMipMapped)
+    , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, desc.fIsMipMapped)
     , fTextureView(view)
     , fLinearTextureView(nullptr) {
     this->registerWithCacheWrapped();
@@ -54,8 +52,7 @@ GrVkTexture::GrVkTexture(GrVkGpu* gpu,
                          GrVkImage::Wrapped wrapped)
     : GrSurface(gpu, desc)
     , GrVkImage(info, wrapped)
-    , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, GrTextureParams::kMipMap_FilterMode,
-                desc.fIsMipMapped)
+    , INHERITED(gpu, desc, kTexture2DSampler_GrSLType, desc.fIsMipMapped)
     , fTextureView(view)
     , fLinearTextureView(nullptr) {
 }
index 21540d9..10c392d 100644 (file)
 #include "gl/GLTestContext.h"
 
 static void test_read_pixels(skiatest::Reporter* reporter, GrContext* context,
-                             GrTexture* texture, uint32_t expectedPixelValues[]) {
-    int pixelCnt = texture->width() * texture->height();
+                             GrTexture* rectangleTexture, uint32_t expectedPixelValues[]) {
+    int pixelCnt = rectangleTexture->width() * rectangleTexture->height();
     SkAutoTMalloc<uint32_t> pixels(pixelCnt);
     memset(pixels.get(), 0, sizeof(uint32_t)*pixelCnt);
-    bool read = texture->readPixels(0, 0, texture->width(), texture->height(),
-                                    kRGBA_8888_GrPixelConfig, pixels.get());
+    bool read = rectangleTexture->readPixels(0, 0, rectangleTexture->width(),
+                                            rectangleTexture->height(), kRGBA_8888_GrPixelConfig,
+                                            pixels.get());
     if (!read) {
         ERRORF(reporter, "Error reading rectangle texture.");
     }
     for (int i = 0; i < pixelCnt; ++i) {
         if (pixels.get()[i] != expectedPixelValues[i]) {
-            ERRORF(reporter, "Error, pixel value %d should be 0x%08x, got 0x%08x.", i,
-                   expectedPixelValues[i], pixels.get()[i]);
+            ERRORF(reporter, "Error, rectangle texture pixel value %d should be 0x%08x,"
+                             " got 0x%08x.", i, expectedPixelValues[i], pixels.get()[i]);
             break;
         }
     }
@@ -89,29 +90,6 @@ static void test_copy_surface_dst(skiatest::Reporter* reporter, GrContext* conte
     }
 }
 
-// skbug.com/5932
-static void test_basic_draw(skiatest::Reporter* reporter, GrContext* context,
-                            GrTexture* rectangleTexture, uint32_t expectedPixelValues[]) {
-    sk_sp<GrRenderTargetContext> rtContext(
-            context->makeRenderTargetContext(SkBackingFit::kExact, rectangleTexture->width(),
-                                             rectangleTexture->height(), rectangleTexture->config(),
-                                             nullptr));
-    SkMatrix m;
-    m.setIDiv(rectangleTexture->width(), rectangleTexture->height());
-    for (auto filter : {GrTextureParams::kNone_FilterMode,
-                        GrTextureParams::kBilerp_FilterMode,
-                        GrTextureParams::kMipMap_FilterMode}) {
-        rtContext->clear(nullptr, 0xDDCCBBAA, true);
-        sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(rectangleTexture,
-                                                                  nullptr, m, filter));
-        GrPaint paint;
-        paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
-        paint.addColorFragmentProcessor(std::move(fp));
-        rtContext->drawPaint(GrNoClip(), paint, SkMatrix::I());
-        test_read_pixels(reporter, context, rtContext->asTexture().get(), expectedPixelValues);
-    }
-}
-
 static void test_clear(skiatest::Reporter* reporter, GrContext* context,
                        GrTexture* rectangleTexture) {
     if (rectangleTexture->asRenderTarget()) {
@@ -222,8 +200,6 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(RectangleTexture, reporter, ctxInfo) {
 
         test_read_pixels(reporter, context, rectangleTexture.get(), refPixels);
 
-        test_basic_draw(reporter, context, rectangleTexture.get(), refPixels);
-
         test_copy_surface_src(reporter, context, rectangleTexture.get(), refPixels);
 
         test_copy_surface_dst(reporter, context, rectangleTexture.get());