aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-03-07 13:01:25 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-07 18:22:40 +0000
commit58389b90cd387533021c109eb28da40c08e0ead5 (patch)
tree7744ee9c23c74c61aa00a3cc01eff74cedb8f541 /tests
parentab6fd7ef91aeca8a3fbbc6c6670cb89a5a7b6d53 (diff)
Initial texture data is never flipped when uploaded.
The first bytes of the data always refer to the pixel accessed by texture coord (0, 0). Change-Id: I708702d90f35b3bc896a48c3c3fd6a0be73f505a Reviewed-on: https://skia-review.googlesource.com/112261 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/CopySurfaceTest.cpp30
-rw-r--r--tests/FloatingPointTextureTest.cpp12
-rw-r--r--tests/ImageFilterCacheTest.cpp4
-rw-r--r--tests/PackedConfigsTextureTest.cpp24
-rw-r--r--tests/ProcessorTest.cpp10
-rw-r--r--tests/ReadPixelsTest.cpp20
-rw-r--r--tests/ReadWriteAlphaTest.cpp44
-rw-r--r--tests/SRGBMipMapTest.cpp4
-rw-r--r--tests/SpecialImageTest.cpp10
-rw-r--r--tests/TestUtils.cpp26
-rw-r--r--tests/VkUploadPixelsTests.cpp32
11 files changed, 79 insertions, 137 deletions
diff --git a/tests/CopySurfaceTest.cpp b/tests/CopySurfaceTest.cpp
index b37325896c..9574208564 100644
--- a/tests/CopySurfaceTest.cpp
+++ b/tests/CopySurfaceTest.cpp
@@ -12,26 +12,17 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrContextPriv.h"
-#include "GrProxyProvider.h"
-#include "GrResourceProvider.h"
-#include "GrSurfaceContext.h"
-#include "GrSurfaceProxy.h"
#include "GrTextureProxy.h"
+#include "ProxyUtils.h"
#include "SkUtils.h"
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
- GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
static const int kW = 10;
static const int kH = 10;
static const size_t kRowBytes = sizeof(uint32_t) * kW;
- GrSurfaceDesc baseDesc;
- baseDesc.fConfig = kRGBA_8888_GrPixelConfig;
- baseDesc.fWidth = kW;
- baseDesc.fHeight = kH;
-
SkAutoTMalloc<uint32_t> srcPixels(kW * kH);
for (int i = 0; i < kW * kH; ++i) {
srcPixels.get()[i] = i;
@@ -65,19 +56,16 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) {
for (auto sOrigin : {kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin}) {
for (auto dOrigin : {kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin}) {
- for (auto sFlags: {kRenderTarget_GrSurfaceFlag, kNone_GrSurfaceFlags}) {
- for (auto dFlags: {kRenderTarget_GrSurfaceFlag, kNone_GrSurfaceFlags}) {
+ for (auto sRT : {true, false}) {
+ for (auto dRT : {true, false}) {
for (auto srcRect : kSrcRects) {
for (auto dstPoint : kDstPoints) {
- GrSurfaceDesc srcDesc = baseDesc;
- srcDesc.fFlags = sFlags;
- GrSurfaceDesc dstDesc = baseDesc;
- dstDesc.fFlags = dFlags;
-
- sk_sp<GrTextureProxy> src = proxyProvider->createTextureProxy(
- srcDesc, sOrigin, SkBudgeted::kNo, srcPixels.get(), kRowBytes);
- sk_sp<GrTextureProxy> dst = proxyProvider->createTextureProxy(
- dstDesc, dOrigin, SkBudgeted::kNo, dstPixels.get(), kRowBytes);
+ auto src = sk_gpu_test::MakeTextureProxyFromData(
+ context, sRT, kW, kH, ii.colorType(), sOrigin, srcPixels.get(),
+ kRowBytes);
+ auto dst = sk_gpu_test::MakeTextureProxyFromData(
+ context, dRT, kW, kH, ii.colorType(), dOrigin, dstPixels.get(),
+ kRowBytes);
if (!src || !dst) {
ERRORF(reporter,
"Could not create surfaces for copy surface test.");
diff --git a/tests/FloatingPointTextureTest.cpp b/tests/FloatingPointTextureTest.cpp
index 6d2beb33e3..dac13a5a70 100644
--- a/tests/FloatingPointTextureTest.cpp
+++ b/tests/FloatingPointTextureTest.cpp
@@ -20,6 +20,7 @@
#include "GrContextPriv.h"
#include "GrProxyProvider.h"
#include "GrTextureProxy.h"
+#include "ProxyUtils.h"
#include "SkHalf.h"
static const int DEV_W = 100, DEV_H = 100;
@@ -33,7 +34,6 @@ void runFPTest(skiatest::Reporter* reporter, GrContext* context, T min, T max, T
return;
}
- GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
SkTDArray<T> controlPixelData, readBuffer;
controlPixelData.setCount(arraySize);
readBuffer.setCount(arraySize);
@@ -46,14 +46,8 @@ void runFPTest(skiatest::Reporter* reporter, GrContext* context, T min, T max, T
}
for (auto origin : {kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin}) {
- GrSurfaceDesc desc;
- desc.fFlags = kRenderTarget_GrSurfaceFlag;
- desc.fWidth = DEV_W;
- desc.fHeight = DEV_H;
- desc.fConfig = GrColorTypeToPixelConfig(colorType, GrSRGBEncoded::kNo);
-
- sk_sp<GrTextureProxy> fpProxy = proxyProvider->createTextureProxy(
- desc, origin, SkBudgeted::kNo, controlPixelData.begin(), 0);
+ auto fpProxy = sk_gpu_test::MakeTextureProxyFromData(context, true, DEV_W, DEV_H, colorType,
+ origin, controlPixelData.begin(), 0);
// Floating point textures are NOT supported everywhere
if (!fpProxy) {
continue;
diff --git a/tests/ImageFilterCacheTest.cpp b/tests/ImageFilterCacheTest.cpp
index a2409dcc98..a541c1c546 100644
--- a/tests/ImageFilterCacheTest.cpp
+++ b/tests/ImageFilterCacheTest.cpp
@@ -196,8 +196,8 @@ static sk_sp<GrTextureProxy> create_proxy(GrProxyProvider* proxyProvider) {
desc.fHeight = kFullSize;
desc.fConfig = kRGBA_8888_GrPixelConfig;
- return proxyProvider->createTextureProxy(desc, kTopLeft_GrSurfaceOrigin, SkBudgeted::kYes,
- srcBM.getPixels(), srcBM.rowBytes());
+ return proxyProvider->createTextureProxy(desc, SkBudgeted::kYes, srcBM.getPixels(),
+ srcBM.rowBytes());
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_ImageBackedGPU, reporter, ctxInfo) {
diff --git a/tests/PackedConfigsTextureTest.cpp b/tests/PackedConfigsTextureTest.cpp
index 0ac322d23d..b1fbc77977 100644
--- a/tests/PackedConfigsTextureTest.cpp
+++ b/tests/PackedConfigsTextureTest.cpp
@@ -18,6 +18,7 @@
#include "GrContextPriv.h"
#include "GrProxyProvider.h"
#include "GrTextureProxy.h"
+#include "ProxyUtils.h"
static const int DEV_W = 10, DEV_H = 10;
static const uint8_t TOL = 0x4;
@@ -95,9 +96,8 @@ static void check_565(skiatest::Reporter* reporter,
}
}
-static void run_test(skiatest::Reporter* reporter, GrContext* context,
- int arraySize, GrPixelConfig config) {
- GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
+static void run_test(skiatest::Reporter* reporter, GrContext* context, int arraySize,
+ GrColorType colorType) {
SkTDArray<uint16_t> controlPixelData;
// We will read back into an 8888 buffer since 565/4444 read backs aren't supported
SkTDArray<GrColor> readBuffer;
@@ -113,14 +113,8 @@ static void run_test(skiatest::Reporter* reporter, GrContext* context,
kRGBA_8888_SkColorType, kOpaque_SkAlphaType);
for (auto origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) {
- GrSurfaceDesc desc;
- desc.fFlags = kNone_GrSurfaceFlags;
- desc.fWidth = DEV_W;
- desc.fHeight = DEV_H;
- desc.fConfig = config;
-
- sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(
- desc, origin, SkBudgeted::kNo, controlPixelData.begin(), 0);
+ auto proxy = sk_gpu_test::MakeTextureProxyFromData(context, false, DEV_W, DEV_H, colorType,
+ origin, controlPixelData.begin(), 0);
SkASSERT(proxy);
sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeWrappedSurfaceContext(
@@ -128,10 +122,10 @@ static void run_test(skiatest::Reporter* reporter, GrContext* context,
SkAssertResult(sContext->readPixels(dstInfo, readBuffer.begin(), 0, 0, 0));
- if (kRGBA_4444_GrPixelConfig == config) {
+ if (GrColorType::kABGR_4444 == colorType) {
check_4444(reporter, controlPixelData, readBuffer);
} else {
- SkASSERT(kRGB_565_GrPixelConfig == config);
+ SkASSERT(GrColorType::kRGB_565 == colorType);
check_565(reporter, controlPixelData, readBuffer);
}
}
@@ -140,11 +134,11 @@ static void run_test(skiatest::Reporter* reporter, GrContext* context,
static const int CONTROL_ARRAY_SIZE = DEV_W * DEV_H;
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RGBA4444TextureTest, reporter, ctxInfo) {
- run_test(reporter, ctxInfo.grContext(), CONTROL_ARRAY_SIZE, kRGBA_4444_GrPixelConfig);
+ run_test(reporter, ctxInfo.grContext(), CONTROL_ARRAY_SIZE, GrColorType::kABGR_4444);
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RGB565TextureTest, reporter, ctxInfo) {
- run_test(reporter, ctxInfo.grContext(), CONTROL_ARRAY_SIZE, kRGB_565_GrPixelConfig);
+ run_test(reporter, ctxInfo.grContext(), CONTROL_ARRAY_SIZE, GrColorType::kRGB_565);
}
#endif
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index 2694bca005..d4350595b7 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -308,8 +308,7 @@ bool init_test_textures(GrProxyProvider* proxyProvider, SkRandom* random,
}
}
- proxies[0] = proxyProvider->createTextureProxy(desc, kBottomLeft_GrSurfaceOrigin,
- SkBudgeted::kYes, rgbaData.get(),
+ proxies[0] = proxyProvider->createTextureProxy(desc, SkBudgeted::kYes, rgbaData.get(),
kTestTextureSize * sizeof(GrColor));
}
@@ -323,8 +322,7 @@ bool init_test_textures(GrProxyProvider* proxyProvider, SkRandom* random,
}
}
- proxies[1] = proxyProvider->createTextureProxy(desc, kBottomLeft_GrSurfaceOrigin,
- SkBudgeted::kYes, alphaData.get(),
+ proxies[1] = proxyProvider->createTextureProxy(desc, SkBudgeted::kYes, alphaData.get(),
kTestTextureSize);
}
@@ -345,8 +343,8 @@ sk_sp<GrTextureProxy> make_input_texture(GrProxyProvider* proxyProvider, int wid
desc.fHeight = height;
desc.fConfig = kRGBA_8888_GrPixelConfig;
- return proxyProvider->createTextureProxy(desc, kBottomLeft_GrSurfaceOrigin, SkBudgeted::kYes,
- data.get(), width * sizeof(GrColor));
+ return proxyProvider->createTextureProxy(desc, SkBudgeted::kYes, data.get(),
+ width * sizeof(GrColor));
}
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, reporter, ctxInfo) {
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index 34cf5bc85e..ccb2ced4fd 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include <initializer_list>
#include "SkCanvas.h"
#include "SkColorData.h"
#include "SkHalf.h"
@@ -18,10 +19,10 @@
#include "GrContextFactory.h"
#include "GrContextPriv.h"
#include "GrProxyProvider.h"
+#include "ProxyUtils.h"
#include "SkGr.h"
#endif
-#include <initializer_list>
static const int DEV_W = 100, DEV_H = 100;
static const SkIRect DEV_RECT = SkIRect::MakeWH(DEV_W, DEV_H);
@@ -449,25 +450,16 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Texture, reporter, ctxInfo) {
}
GrContext* context = ctxInfo.grContext();
- GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
-
SkBitmap bmp = make_src_bitmap();
// On the GPU we will also try reading back from a non-renderable texture.
for (auto origin : {kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin}) {
- for (auto flags : {kNone_GrSurfaceFlags, kRenderTarget_GrSurfaceFlag}) {
- GrSurfaceDesc desc;
- desc.fFlags = flags;
- desc.fWidth = DEV_W;
- desc.fHeight = DEV_H;
- desc.fConfig = kSkia8888_GrPixelConfig;
-
- sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(
- desc, origin, SkBudgeted::kNo, bmp.getPixels(), bmp.rowBytes());
-
+ for (auto isRT : {false, true}) {
+ sk_sp<GrTextureProxy> proxy = sk_gpu_test::MakeTextureProxyFromData(
+ context, isRT, DEV_W, DEV_H, bmp.colorType(), origin, bmp.getPixels(),
+ bmp.rowBytes());
sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeWrappedSurfaceContext(
std::move(proxy));
-
test_readpixels_texture(reporter, std::move(sContext));
}
}
diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp
index f495fc2b08..eaad411d5a 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -9,7 +9,6 @@
// This test is specific to the GPU backend.
#if SK_SUPPORT_GPU
-
#include "GrContext.h"
#include "GrContextPriv.h"
#include "GrProxyProvider.h"
@@ -17,6 +16,7 @@
#include "GrSurfaceContext.h"
#include "GrSurfaceProxy.h"
#include "GrTextureProxy.h"
+#include "ProxyUtils.h"
#include "SkCanvas.h"
#include "SkSurface.h"
@@ -26,12 +26,12 @@ static const int Y_SIZE = 13;
static void validate_alpha_data(skiatest::Reporter* reporter, int w, int h, const uint8_t* actual,
size_t actualRowBytes, const uint8_t* expected, SkString extraMsg,
- GrPixelConfig config) {
+ GrColorType colorType) {
for (int y = 0; y < h; ++y) {
for (int x = 0; x < w; ++x) {
uint8_t a = actual[y * actualRowBytes + x];
uint8_t e = expected[y * w + x];
- if (kRGBA_1010102_GrPixelConfig == config) {
+ if (GrColorType::kRGBA_1010102 == colorType) {
// This config only preserves two bits of alpha
a >>= 6;
e >>= 6;
@@ -66,8 +66,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
// We are initializing the texture with zeros here
memset(alphaData, 0, X_SIZE * Y_SIZE);
- sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(
- desc, kTopLeft_GrSurfaceOrigin, SkBudgeted::kNo, alphaData, 0);
+ sk_sp<GrTextureProxy> proxy =
+ proxyProvider->createTextureProxy(desc, SkBudgeted::kNo, alphaData, 0);
if (!proxy) {
ERRORF(reporter, "Could not create alpha texture.");
return;
@@ -105,7 +105,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
SkString msg;
msg.printf("rb:%d A8", SkToU32(rowBytes));
validate_alpha_data(reporter, X_SIZE, Y_SIZE, readback.get(), nonZeroRowBytes,
- alphaData, msg, kAlpha_8_GrPixelConfig);
+ alphaData, msg, GrColorType::kAlpha_8);
// Now try writing to a single channel surface (if we could create one).
if (surf) {
@@ -146,11 +146,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
}
}
- static const GrPixelConfig kRGBAConfigs[] {
- kRGBA_8888_GrPixelConfig,
- kBGRA_8888_GrPixelConfig,
- kSRGBA_8888_GrPixelConfig,
- kRGBA_1010102_GrPixelConfig,
+ static constexpr struct {
+ GrColorType fColorType;
+ GrSRGBEncoded fSRGBEncoded;
+ } kInfos[] = {
+ {GrColorType::kRGBA_8888, GrSRGBEncoded::kNo},
+ {GrColorType::kBGRA_8888, GrSRGBEncoded::kNo},
+ {GrColorType::kRGBA_8888, GrSRGBEncoded::kYes},
+ {GrColorType::kRGBA_1010102, GrSRGBEncoded::kNo},
};
for (int y = 0; y < Y_SIZE; ++y) {
@@ -165,14 +168,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
// Attempt to read back just alpha from a RGBA/BGRA texture. Once with a texture-only src and
// once with a render target.
- for (auto config : kRGBAConfigs) {
+ for (auto info : kInfos) {
for (int rt = 0; rt < 2; ++rt) {
- GrSurfaceDesc desc;
- desc.fFlags = rt ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags;
- desc.fConfig = config;
- desc.fWidth = X_SIZE;
- desc.fHeight = Y_SIZE;
-
uint32_t rgbaData[X_SIZE * Y_SIZE];
// Make the alpha channel of the rgba texture come from alphaData.
for (int y = 0; y < Y_SIZE; ++y) {
@@ -182,13 +179,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
}
auto origin = rt ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin;
- sk_sp<GrTextureProxy> proxy =
- proxyProvider->createTextureProxy(desc, origin, SkBudgeted::kNo, rgbaData, 0);
+ auto proxy = sk_gpu_test::MakeTextureProxyFromData(context, rt, X_SIZE, Y_SIZE,
+ info.fColorType, info.fSRGBEncoded,
+ origin, rgbaData, 0);
if (!proxy) {
- // We always expect to be able to create a RGBA texture
- if (!rt && kRGBA_8888_GrPixelConfig == desc.fConfig) {
- ERRORF(reporter, "Failed to create RGBA texture.");
- }
continue;
}
@@ -214,7 +208,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
SkString msg;
msg.printf("rt:%d, rb:%d 8888", rt, SkToU32(rowBytes));
validate_alpha_data(reporter, X_SIZE, Y_SIZE, readback.get(), nonZeroRowBytes,
- alphaData, msg, config);
+ alphaData, msg, info.fColorType);
}
}
}
diff --git a/tests/SRGBMipMapTest.cpp b/tests/SRGBMipMapTest.cpp
index 91294dedb7..7be4db68d7 100644
--- a/tests/SRGBMipMapTest.cpp
+++ b/tests/SRGBMipMapTest.cpp
@@ -131,8 +131,8 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SRGBMipMaps, reporter, ctxInfo) {
desc.fConfig = kSRGBA_8888_GrPixelConfig;
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
- sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(desc, kTopLeft_GrSurfaceOrigin,
- SkBudgeted::kNo, texData, 0);
+ sk_sp<GrTextureProxy> proxy =
+ proxyProvider->createTextureProxy(desc, SkBudgeted::kNo, texData, 0);
// Create two render target contexts (L32 and S32)
sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::MakeSRGB();
diff --git a/tests/SpecialImageTest.cpp b/tests/SpecialImageTest.cpp
index f201fb03ff..8397795261 100644
--- a/tests/SpecialImageTest.cpp
+++ b/tests/SpecialImageTest.cpp
@@ -238,7 +238,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_MakeTexture, reporter, ctxInfo)
const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bm.info(), *context->caps());
sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(
- desc, kTopLeft_GrSurfaceOrigin, SkBudgeted::kNo, bm.getPixels(), bm.rowBytes());
+ desc, SkBudgeted::kNo, bm.getPixels(), bm.rowBytes());
if (!proxy) {
return;
}
@@ -270,8 +270,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_Gpu, reporter, ctxInfo) {
const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bm.info(), *context->caps());
- sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(
- desc, kTopLeft_GrSurfaceOrigin, SkBudgeted::kNo, bm.getPixels(), bm.rowBytes());
+ sk_sp<GrTextureProxy> proxy =
+ proxyProvider->createTextureProxy(desc, SkBudgeted::kNo, bm.getPixels(), bm.rowBytes());
if (!proxy) {
return;
}
@@ -309,8 +309,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialImage_DeferredGpu, reporter, ctxInfo)
desc.fHeight = kFullSize;
desc.fConfig = kSkia8888_GrPixelConfig;
- sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(
- desc, kTopLeft_GrSurfaceOrigin, SkBudgeted::kNo, bm.getPixels(), bm.rowBytes());
+ sk_sp<GrTextureProxy> proxy =
+ proxyProvider->createTextureProxy(desc, SkBudgeted::kNo, bm.getPixels(), bm.rowBytes());
if (!proxy) {
return;
}
diff --git a/tests/TestUtils.cpp b/tests/TestUtils.cpp
index 7878233698..1b146c2cca 100644
--- a/tests/TestUtils.cpp
+++ b/tests/TestUtils.cpp
@@ -11,8 +11,10 @@
#include "GrProxyProvider.h"
#include "GrSurfaceContext.h"
+#include "GrSurfaceContextPriv.h"
#include "GrSurfaceProxy.h"
#include "GrTextureProxy.h"
+#include "ProxyUtils.h"
void test_read_pixels(skiatest::Reporter* reporter,
GrSurfaceContext* srcContext, uint32_t expectedPixelValues[],
@@ -103,22 +105,14 @@ void test_copy_to_surface(skiatest::Reporter* reporter, GrProxyProvider* proxyPr
}
}
- GrSurfaceDesc copySrcDesc;
- copySrcDesc.fWidth = dstContext->width();
- copySrcDesc.fHeight = dstContext->height();
- copySrcDesc.fConfig = kRGBA_8888_GrPixelConfig;
-
- for (auto flags : { kNone_GrSurfaceFlags, kRenderTarget_GrSurfaceFlag }) {
- copySrcDesc.fFlags = flags;
- auto origin = (kNone_GrSurfaceFlags == flags) ? kTopLeft_GrSurfaceOrigin
- : kBottomLeft_GrSurfaceOrigin;
-
- sk_sp<GrTextureProxy> src = proxyProvider->createTextureProxy(
- copySrcDesc, origin, SkBudgeted::kYes, pixels.get(), 0);
-
- dstContext->copy(src.get());
-
- test_read_pixels(reporter, dstContext, pixels.get(), testName);
+ for (auto isRT : {false, true}) {
+ for (auto origin : {kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin}) {
+ auto src = sk_gpu_test::MakeTextureProxyFromData(
+ dstContext->surfPriv().getContext(), isRT, dstContext->width(),
+ dstContext->height(), GrColorType::kRGBA_8888, origin, pixels.get(), 0);
+ dstContext->copy(src.get());
+ test_read_pixels(reporter, dstContext, pixels.get(), testName);
+ }
}
}
diff --git a/tests/VkUploadPixelsTests.cpp b/tests/VkUploadPixelsTests.cpp
index f2d6af3af7..acadf7dc1d 100644
--- a/tests/VkUploadPixelsTests.cpp
+++ b/tests/VkUploadPixelsTests.cpp
@@ -13,9 +13,9 @@
#include "GrContextFactory.h"
#include "GrContextPriv.h"
-#include "GrProxyProvider.h"
#include "GrSurfaceProxy.h"
#include "GrTest.h"
+#include "ProxyUtils.h"
#include "SkGr.h"
#include "Test.h"
#include "vk/GrVkGpu.h"
@@ -52,10 +52,8 @@ bool does_full_buffer_contain_correct_color(GrColor* srcBuffer,
return true;
}
-void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, GrPixelConfig config,
+void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, SkColorType ct,
bool renderTarget) {
- GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
-
const int kWidth = 16;
const int kHeight = 16;
SkAutoTMalloc<GrColor> srcBuffer(kWidth*kHeight);
@@ -63,18 +61,8 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, GrPixe
fill_pixel_data(kWidth, kHeight, srcBuffer.get());
- GrSurfaceDesc surfDesc;
- surfDesc.fFlags = renderTarget ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags;
- surfDesc.fWidth = kWidth;
- surfDesc.fHeight = kHeight;
- surfDesc.fConfig = config;
- surfDesc.fSampleCnt = 1;
-
- SkColorType ct;
- SkAssertResult(GrPixelConfigToColorType(config, &ct));
-
- sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(
- surfDesc, kTopLeft_GrSurfaceOrigin, SkBudgeted::kNo, srcBuffer, 0);
+ auto proxy = sk_gpu_test::MakeTextureProxyFromData(context, renderTarget, kWidth, kHeight, ct,
+ kTopLeft_GrSurfaceOrigin, srcBuffer, 0);
REPORTER_ASSERT(reporter, proxy);
if (proxy) {
sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeWrappedSurfaceContext(proxy);
@@ -103,8 +91,8 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, GrPixe
2));
}
- proxy = proxyProvider->createTextureProxy(surfDesc, kBottomLeft_GrSurfaceOrigin,
- SkBudgeted::kNo, srcBuffer, 0);
+ proxy = sk_gpu_test::MakeTextureProxyFromData(context, renderTarget, kWidth, kHeight, ct,
+ kBottomLeft_GrSurfaceOrigin, srcBuffer, 0);
REPORTER_ASSERT(reporter, proxy);
if (proxy) {
sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeWrappedSurfaceContext(proxy);
@@ -137,12 +125,12 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, GrPixe
DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkUploadPixelsTests, reporter, ctxInfo) {
// RGBA
- basic_texture_test(reporter, ctxInfo.grContext(), kRGBA_8888_GrPixelConfig, false);
- basic_texture_test(reporter, ctxInfo.grContext(), kRGBA_8888_GrPixelConfig, true);
+ basic_texture_test(reporter, ctxInfo.grContext(), kRGBA_8888_SkColorType, false);
+ basic_texture_test(reporter, ctxInfo.grContext(), kRGBA_8888_SkColorType, true);
// BGRA
- basic_texture_test(reporter, ctxInfo.grContext(), kBGRA_8888_GrPixelConfig, false);
- basic_texture_test(reporter, ctxInfo.grContext(), kBGRA_8888_GrPixelConfig, true);
+ basic_texture_test(reporter, ctxInfo.grContext(), kBGRA_8888_SkColorType, false);
+ basic_texture_test(reporter, ctxInfo.grContext(), kBGRA_8888_SkColorType, true);
}
#endif