IntTextureTest.cpp revision d316e77c1e1967b439a9a6c11146c54e367bff71
1bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon/* 2bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon * Copyright 2016 Google Inc. 3bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon * 4bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon * Use of this source code is governed by a BSD-style license that can be 5bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon * found in the LICENSE file. 6bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon */ 7bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 8bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon#include "Test.h" 9bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 10bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon#if SK_SUPPORT_GPU 11bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon#include "GrContext.h" 12bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon#include "GrRenderTargetContext.h" 13bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon#include "GrTexture.h" 14bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon#include "effects/GrSimpleTextureEffect.h" 15bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 16bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomontemplate <typename I> 17bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomonstatic SK_WHEN(std::is_integral<I>::value && 4 == sizeof(I), void) 18bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomoncheck_pixels(skiatest::Reporter* reporter, int w, int h, 19bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon const I exepctedData[], const I actualData[]) { 20bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon for (int j = 0; j < h; ++j) { 21bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon for (int i = 0; i < w; ++i) { 22bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon I expected = exepctedData[j * w + i]; 23bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon I actual = actualData[j * w + i]; 24bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (expected != actual) { 25bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon ERRORF(reporter, "Expected 0x08%x, got 0x%08x at %d, %d.", expected, actual, i, j); 26bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon return; 27bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 28bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 29bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 30bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon} 31bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 32bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian SalomonDEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { 33bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon GrContext* context = ctxInfo.grContext(); 34bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (!context->caps()->isConfigTexturable(kRGBA_8888_sint_GrPixelConfig)) { 35bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon return; 36bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 37bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon static const int kS = UINT8_MAX + 1; 38bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon GrSurfaceDesc desc; 39bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon desc.fConfig = kRGBA_8888_sint_GrPixelConfig; 40bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon desc.fWidth = kS; 41bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon desc.fHeight = kS; 42bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon sk_sp<GrTexture> texture; 43bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 44bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon std::unique_ptr<int32_t[]> testData(new int32_t[kS * kS]); 45bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon for (int j = 0; j < kS; ++j) { 46bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon for (int i = 0; i < kS; ++i) { 47bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon uint32_t r = i - INT8_MIN; 48bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon uint32_t g = j - INT8_MIN; 49bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon uint32_t b = INT8_MAX - r; 50bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon uint32_t a = INT8_MAX - g; 51bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon testData.get()[j * kS + i] = (a << 24) | (b << 16) | (g << 8) | r; 52bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 53bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 54bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 55bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon // Test that attempting to create a integer texture with multiple MIP level fails. 56bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon GrMipLevel levels[2]; 57bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon levels[0].fPixels = testData.get(); 58bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon levels[0].fRowBytes = kS * sizeof(int32_t); 59bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon levels[1].fPixels = testData.get(); 60bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon levels[1].fRowBytes = (kS / 2) * sizeof(int32_t); 61bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon texture.reset(context->textureProvider()->createMipMappedTexture(desc, SkBudgeted::kYes, levels, 62bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 2)); 63bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon REPORTER_ASSERT(reporter, !texture); 64bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 65bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon // Test that we can create a integer texture. 66bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon texture.reset(context->textureProvider()->createTexture(desc, SkBudgeted::kYes, 67bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon levels[0].fPixels, 68bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon levels[0].fRowBytes)); 69bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon REPORTER_ASSERT(reporter, texture); 70bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (!texture) { 71bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon return; 72bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 73bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 74bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon // Test that reading to a non-integer config fails. 75bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon std::unique_ptr<int32_t[]> readData(new int32_t[kS * kS]); 76bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon bool success = texture->readPixels(0, 0, kS, kS, kRGBA_8888_GrPixelConfig, readData.get()); 77bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon REPORTER_ASSERT(reporter, !success); 78bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon std::unique_ptr<uint16_t[]> halfData(new uint16_t[4 * kS * kS]); 79bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon success = texture->readPixels(0, 0, kS, kS, kRGBA_half_GrPixelConfig, halfData.get()); 80bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon REPORTER_ASSERT(reporter, !success); 81bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 82bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon // Can read back as ints. (ES only requires being able to read back into 32bit ints which 83bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon // we don't support. Right now this test is counting on GR_RGBA_INTEGER/GL_BYTE being the 84bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon // implementation-dependent second format). 85bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon sk_bzero(readData.get(), sizeof(int32_t) * kS * kS); 86bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon success = texture->readPixels(0, 0, kS, kS, kRGBA_8888_sint_GrPixelConfig, readData.get()); 87bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon REPORTER_ASSERT(reporter, success); 88bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (success) { 89bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon check_pixels(reporter, kS, kS, testData.get(), readData.get()); 90bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 91bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 92bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon // readPixels should fail if we attempt to use the unpremul flag with an integer texture. 93bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon success = texture->readPixels(0, 0, kS, kS, kRGBA_8888_sint_GrPixelConfig, readData.get(), 0, 94bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon GrContext::kUnpremul_PixelOpsFlag); 95bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon REPORTER_ASSERT(reporter, !success); 96bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 97bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon // Test that copying from one integer texture to another succeeds. 98d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips sk_sp<GrTexture> copy(context->textureProvider()->createTexture(desc, SkBudgeted::kYes)); 99d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips REPORTER_ASSERT(reporter, copy); 100d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips if (!copy) { 101d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips return; 102bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 103d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips success = context->copySurface(copy.get(), texture.get()); 104d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips REPORTER_ASSERT(reporter, success); 105d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips if (!success) { 106d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips return; 107d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips } 108d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips sk_bzero(readData.get(), sizeof(int32_t) * kS * kS); 109d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips success = texture->readPixels(0, 0, kS, kS, kRGBA_8888_sint_GrPixelConfig, readData.get()); 110d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips REPORTER_ASSERT(reporter, success); 111d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips if (success) { 112d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips check_pixels(reporter, kS, kS, testData.get(), readData.get()); 113293d696fcfb9f1c83019c4b15c4864cd6649ed78Robert Phillips } 114398487a850431cf495330d4023607df5305a311fRobert Phillips 115d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips // Test that copying to a non-integer texture fails. 116d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips GrSurfaceDesc nonIntDesc = desc; 117d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips nonIntDesc.fConfig = kRGBA_8888_GrPixelConfig; 118d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips copy.reset(context->textureProvider()->createTexture(nonIntDesc, SkBudgeted::kYes)); 119d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips REPORTER_ASSERT(reporter, copy); 120d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips if (!copy) { 121d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips return; 122d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips } 123d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips success = context->copySurface(copy.get(), texture.get()); 124d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips REPORTER_ASSERT(reporter, !success); 125d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips nonIntDesc.fConfig = kRGBA_half_GrPixelConfig; 126d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips copy.reset(context->textureProvider()->createTexture(nonIntDesc, SkBudgeted::kYes)); 127d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips REPORTER_ASSERT(reporter, copy || 128d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips !context->caps()->isConfigTexturable(kRGBA_half_GrPixelConfig)); 129d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips if (copy) { 130d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips success = context->copySurface(copy.get(), texture.get()); 131d316e77c1e1967b439a9a6c11146c54e367bff71Robert Phillips REPORTER_ASSERT(reporter, !success); 132bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 133bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 134bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon // We overwrite the top left quarter of the texture with the bottom right quarter of the 135bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon // original data. 136bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon const void* bottomRightQuarter = testData.get() + kS / 2 * kS + kS / 2; 137bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon size_t rowBytes = kS * sizeof(int32_t); 138bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 139bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon // Can't write pixels from a non-int config. 140bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon success = texture->writePixels(0, 0, kS/2, kS/2, kRGBA_8888_GrPixelConfig, bottomRightQuarter, 141bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon rowBytes); 142bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon REPORTER_ASSERT(reporter, !success); 143bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 144bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon // Can't use unpremul flag. 145bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon success = texture->writePixels(0, 0, kS/2, kS/2, kRGBA_8888_sint_GrPixelConfig, 146bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon bottomRightQuarter, rowBytes, 147bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon GrContext::kUnpremul_PixelOpsFlag); 148bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon REPORTER_ASSERT(reporter, !success); 149bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 150bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon success = texture->writePixels(0, 0, kS/2, kS/2, kRGBA_8888_sint_GrPixelConfig, 151bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon bottomRightQuarter, rowBytes); 152bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon REPORTER_ASSERT(reporter, success); 153bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (!success) { 154bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon return; 155bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 156bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon sk_bzero(readData.get(), sizeof(int32_t) * kS * kS); 157bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon success = texture->readPixels(0, 0, kS, kS, kRGBA_8888_sint_GrPixelConfig, readData.get()); 158bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon REPORTER_ASSERT(reporter, success); 159bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (!success) { 160bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon return; 161bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 162bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon std::unique_ptr<int32_t[]> overwrittenTestData(new int32_t[kS * kS]); 163bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon memcpy(overwrittenTestData.get(), testData.get(), sizeof(int32_t) * kS * kS); 164bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon char* dst = (char*)overwrittenTestData.get(); 165bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon char* src = (char*)(testData.get() + kS/2 * kS + kS/2); 166bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon for (int i = 0; i < kS/2; ++i) { 167bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon memcpy(dst, src, sizeof(int32_t) * kS/2); 168bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon dst += rowBytes; 169bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon src += rowBytes; 170bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 171bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon check_pixels(reporter, kS, kS, overwrittenTestData.get(), readData.get()); 172bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 173bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon // Test drawing from the integer texture to a fixed point texture. To avoid any premul issues 174bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon // we init the int texture with 0s and 1s and make alpha always be 1. We expect that 1s turn 175bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon // into 0xffs and zeros stay zero. 176bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon std::unique_ptr<uint32_t[]> expectedData(new uint32_t[kS * kS]); 177bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon std::unique_ptr<uint32_t[]> actualData(new uint32_t[kS * kS]); 178bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon for (int i = 0; i < kS*kS; ++i) { 179bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon int32_t a = 0x1; 180bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon int32_t b = ((i & 0x1) ? 1 : 0); 181bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon int32_t g = ((i & 0x1) ? 0 : 1); 182bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon int32_t r = ((i & 0x2) ? 1 : 0); 183bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon testData.get()[i] = (a << 24) | (b << 16) | (g << 8) | r; 184bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon expectedData.get()[i] = ((0xFF * a) << 24) | ((0xFF * b) << 16) | 185bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon ((0xFF * g) << 8) | (0xFF * r); 186bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 187bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon texture->writePixels(0, 0, kS, kS, kRGBA_8888_sint_GrPixelConfig, testData.get()); 188bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon sk_sp<GrRenderTargetContext> rtContext = context->makeRenderTargetContext( 189bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon SkBackingFit::kExact, kS, kS, kRGBA_8888_GrPixelConfig, nullptr); 190bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 191514baff8be7f71111aa7bfb9b099a096b31e16ecBrian Salomon for (auto filter : {GrSamplerParams::kNone_FilterMode, 192514baff8be7f71111aa7bfb9b099a096b31e16ecBrian Salomon GrSamplerParams::kBilerp_FilterMode, 193514baff8be7f71111aa7bfb9b099a096b31e16ecBrian Salomon GrSamplerParams::kMipMap_FilterMode}) { 194bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon SkMatrix m; 195bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon m.setIDiv(kS, kS); 196bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(texture.get(), nullptr, m, 197bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon filter)); 198bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon REPORTER_ASSERT(reporter, fp); 199bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon if (!fp) { 200bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon return; 201bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 202bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon rtContext->clear(nullptr, 0xDDAABBCC, true); 203bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon GrPaint paint; 204bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon paint.setPorterDuffXPFactory(SkBlendMode::kSrc); 205bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon paint.addColorFragmentProcessor(fp); 206bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon rtContext->drawPaint(GrNoClip(), paint, SkMatrix::I()); 207bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon SkImageInfo readInfo = SkImageInfo::Make(kS, kS, kRGBA_8888_SkColorType, 208bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon kPremul_SkAlphaType); 209bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon rtContext->readPixels(readInfo, actualData.get(), 0, 0, 0); 210bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon check_pixels(reporter, kS, kS, expectedData.get(), actualData.get()); 211bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon } 212bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 213bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon // No rendering to integer textures. 214bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon GrSurfaceDesc intRTDesc = desc; 215bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon intRTDesc.fFlags = kRenderTarget_GrSurfaceFlag; 216bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon texture.reset(context->textureProvider()->createTexture(intRTDesc, SkBudgeted::kYes)); 217bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon REPORTER_ASSERT(reporter, !texture); 218bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon} 219bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon 220bf7b620b1e44985b164a8bd68031a7613fe0bb9bBrian Salomon#endif 221