aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ImageTest.cpp
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2018-03-27 09:56:31 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-27 14:45:14 +0000
commit052ef695708eddeaa81c3fcf5747824c1f0ad073 (patch)
tree1122ad13a7fe3a97d2e6bf4b160f5b9582e679de /tests/ImageTest.cpp
parentf830443814fb21bd4b1009186b23680e3a38935e (diff)
Pin color type when a cross-context image is constructed
Fixes issues with gray images that may be incorrectly re-interpreted as alpha when re-wrapped. (https://github.com/flutter/flutter/issues/15600) Change-Id: I4a78466073e14d212108d168eed0b2df1bc92ffe Reviewed-on: https://skia-review.googlesource.com/116484 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'tests/ImageTest.cpp')
-rw-r--r--tests/ImageTest.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index 726a06adc3..98c2f03c2e 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -1021,6 +1021,35 @@ DEF_GPUTEST(SkImage_MakeCrossContextFromPixmapRelease, reporter, options) {
});
}
+DEF_GPUTEST(SkImage_CrossContextGrayAlphaConfigs, reporter, options) {
+
+ for (SkColorType ct : { kGray_8_SkColorType, kAlpha_8_SkColorType }) {
+ SkAutoPixmapStorage pixmap;
+ pixmap.alloc(SkImageInfo::Make(4, 4, ct, kPremul_SkAlphaType));
+
+ for (int i = 0; i < GrContextFactory::kContextTypeCnt; ++i) {
+ GrContextFactory testFactory(options);
+ GrContextFactory::ContextType ctxType = static_cast<GrContextFactory::ContextType>(i);
+ ContextInfo ctxInfo = testFactory.getContextInfo(ctxType);
+ GrContext* ctx = ctxInfo.grContext();
+ if (!ctx || !ctx->caps()->crossContextTextureSupport()) {
+ continue;
+ }
+
+ sk_sp<SkImage> image = SkImage::MakeCrossContextFromPixmap(ctx, pixmap, false, nullptr);
+ REPORTER_ASSERT(reporter, image);
+
+ sk_sp<SkColorSpace> texColorSpace;
+ sk_sp<GrTextureProxy> proxy = as_IB(image)->asTextureProxyRef(
+ ctx, GrSamplerState::ClampNearest(), nullptr, &texColorSpace, nullptr);
+ REPORTER_ASSERT(reporter, proxy);
+
+ bool expectAlpha = kAlpha_8_SkColorType == ct;
+ REPORTER_ASSERT(reporter, expectAlpha == GrPixelConfigIsAlphaOnly(proxy->config()));
+ }
+ }
+}
+
static uint32_t GetIdForBackendObject(GrContext* ctx, GrBackendObject object) {
if (!object) {
return 0;