diff options
author | Brian Salomon <bsalomon@google.com> | 2018-03-07 13:01:25 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-03-07 18:22:40 +0000 |
commit | 58389b90cd387533021c109eb28da40c08e0ead5 (patch) | |
tree | 7744ee9c23c74c61aa00a3cc01eff74cedb8f541 /gm/flippity.cpp | |
parent | ab6fd7ef91aeca8a3fbbc6c6670cb89a5a7b6d53 (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 'gm/flippity.cpp')
-rw-r--r-- | gm/flippity.cpp | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/gm/flippity.cpp b/gm/flippity.cpp index 554b4d151b..d730ed58a6 100644 --- a/gm/flippity.cpp +++ b/gm/flippity.cpp @@ -13,7 +13,7 @@ #if SK_SUPPORT_GPU #include "GrContextPriv.h" -#include "GrProxyProvider.h" +#include "ProxyUtils.h" #include "SkImage_Gpu.h" static const int kNumMatrices = 6; @@ -85,20 +85,15 @@ static sk_sp<SkImage> make_text_image(GrContext* context, const char* text, SkCo return image->makeTextureImage(context, nullptr); } -static SkColor swap_red_and_blue(SkColor c) { - return SkColorSetRGB(SkColorGetB(c), SkColorGetG(c), SkColorGetR(c)); -} - // Create an image with each corner marked w/ "LL", "LR", etc., with the origin either bottom-left // or top-left. static sk_sp<SkImage> make_reference_image(GrContext* context, const SkTArray<sk_sp<SkImage>>& labels, bool bottomLeftOrigin) { - GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider(); SkASSERT(kNumLabels == labels.count()); - SkImageInfo ii = SkImageInfo::Make(kImageSize, kImageSize, - kN32_SkColorType, kOpaque_SkAlphaType); + SkImageInfo ii = + SkImageInfo::Make(kImageSize, kImageSize, kRGBA_8888_SkColorType, kOpaque_SkAlphaType); SkBitmap bm; bm.allocPixels(ii); SkCanvas canvas(bm); @@ -110,26 +105,11 @@ static sk_sp<SkImage> make_reference_image(GrContext* context, 0.0 != kPoints[i].fY ? kPoints[i].fY-kLabelSize-kInset : kInset); } - GrSurfaceDesc desc; - desc.fWidth = kImageSize; - desc.fHeight = kImageSize; - desc.fConfig = kRGBA_8888_GrPixelConfig; - auto origin = bottomLeftOrigin ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin; - if (kN32_SkColorType == kBGRA_8888_SkColorType) { - // We're playing a game here and uploading N32 data into an RGB dest. We might have - // to swap red & blue to compensate. - for (int y = 0; y < bm.height(); ++y) { - uint32_t *sl = bm.getAddr32(0, y); - for (int x = 0; x < bm.width(); ++x) { - sl[x] = swap_red_and_blue(sl[x]); - } - } - } - - sk_sp<GrTextureProxy> proxy = proxyProvider->createTextureProxy(desc, origin, SkBudgeted::kYes, - bm.getPixels(), bm.rowBytes()); + auto proxy = sk_gpu_test::MakeTextureProxyFromData(context, false, kImageSize, kImageSize, + bm.colorType(), origin, bm.getPixels(), + bm.rowBytes()); if (!proxy) { return nullptr; } |