aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/RectangleTextureTest.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2016-11-04 11:54:32 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-04 16:25:25 +0000
commit4d53c44aa6e8e0d1b6537f83e4287e5a1423ac75 (patch)
treeca7e88b141ef8667921b1ade269e7e2c838b13c0 /tests/RectangleTextureTest.cpp
parent9598c2fbc29ddb5e5d86c5b82b401b62cee02775 (diff)
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>
Diffstat (limited to 'tests/RectangleTextureTest.cpp')
-rw-r--r--tests/RectangleTextureTest.cpp38
1 files changed, 31 insertions, 7 deletions
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index 08311e4c6a..b542986b24 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -15,20 +15,19 @@
#include "gl/GLTestContext.h"
static void test_read_pixels(skiatest::Reporter* reporter, GrContext* context,
- GrTexture* rectangleTexture, uint32_t expectedPixelValues[]) {
- int pixelCnt = rectangleTexture->width() * rectangleTexture->height();
+ GrTexture* texture, uint32_t expectedPixelValues[]) {
+ int pixelCnt = texture->width() * texture->height();
SkAutoTMalloc<uint32_t> pixels(pixelCnt);
memset(pixels.get(), 0, sizeof(uint32_t)*pixelCnt);
- bool read = rectangleTexture->readPixels(0, 0, rectangleTexture->width(),
- rectangleTexture->height(), kRGBA_8888_GrPixelConfig,
- pixels.get());
+ bool read = texture->readPixels(0, 0, texture->width(), texture->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, rectangle texture pixel value %d should be 0x%08x,"
- " got 0x%08x.", i, expectedPixelValues[i], pixels.get()[i]);
+ ERRORF(reporter, "Error, pixel value %d should be 0x%08x, got 0x%08x.", i,
+ expectedPixelValues[i], pixels.get()[i]);
break;
}
}
@@ -90,6 +89,29 @@ 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()) {
@@ -200,6 +222,8 @@ 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());