aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/RectangleTextureTest.cpp
diff options
context:
space:
mode:
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 10c392ddb0..21540d99c0 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());