Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Unified Diff: src/gpu/SkGpuDevice.cpp

Issue 2270823002: Some tests around surface creation and snapshotting with color space (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Test wrapped backend textures, too. Make those tests pass. Fix problems when sRGB support is missin… Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/gpu/SkGpuDevice.cpp
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index a6c8a1fc74fceb34ff86038324c78d25368c2fa0..491c58810ef43c801fea3ef25fcc421b7c187985 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -68,10 +68,31 @@ enum { kDefaultImageFilterCacheSize = 32 * 1024 * 1024 };
///////////////////////////////////////////////////////////////////////////////
-/** Checks that the alpha type is legal and gets constructor flags. Returns false if device creation
- should fail. */
-bool SkGpuDevice::CheckAlphaTypeAndGetFlags(
+/** Checks that the alpha type, color space, etc... is legal and gets constructor flags.
+ Returns false if device creation should fail. */
+bool SkGpuDevice::CheckInfoAndGetFlags(
const SkImageInfo* info, SkGpuDevice::InitContents init, unsigned* flags) {
+ if (info) {
+ switch (info->colorType()) {
+ case kRGBA_F16_SkColorType:
+ if (!info->colorSpace() ||
+ SkColorSpace::kLinear_GammaNamed != info->colorSpace()->gammaNamed()) {
+ return false;
+ }
+ break;
+ case kRGBA_8888_SkColorType:
+ case kBGRA_8888_SkColorType:
+ if (info->colorSpace() && !info->colorSpace()->gammaCloseToSRGB()) {
+ return false;
+ }
+ break;
+ default:
+ if (info->colorSpace()) {
+ return false;
+ }
+ }
+ }
+
*flags = 0;
if (info) {
switch (info->alphaType()) {
@@ -97,7 +118,7 @@ sk_sp<SkGpuDevice> SkGpuDevice::Make(sk_sp<GrDrawContext> drawContext,
return nullptr;
}
unsigned flags;
- if (!CheckAlphaTypeAndGetFlags(nullptr, init, &flags)) {
+ if (!CheckInfoAndGetFlags(nullptr, init, &flags)) {
return nullptr;
}
return sk_sp<SkGpuDevice>(new SkGpuDevice(std::move(drawContext), width, height, flags));
@@ -108,7 +129,7 @@ sk_sp<SkGpuDevice> SkGpuDevice::Make(GrContext* context, SkBudgeted budgeted,
GrSurfaceOrigin origin,
const SkSurfaceProps* props, InitContents init) {
unsigned flags;
- if (!CheckAlphaTypeAndGetFlags(&info, init, &flags)) {
+ if (!CheckInfoAndGetFlags(&info, init, &flags)) {
return nullptr;
}

Powered by Google App Engine
This is Rietveld 408576698