remove experimental treat-skcolor-as-srgb flag

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2097003003

Review-Url: https://codereview.chromium.org/2097003003
This commit is contained in:
reed 2016-06-24 18:14:07 -07:00 committed by Commit bot
parent f8c2be3fbc
commit a84d6606f5
9 changed files with 6 additions and 148 deletions

View File

@ -834,8 +834,6 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
itemID = fAppMenu->appendList("ColorType", "ColorType", sinkID, 0,
gConfig[0].fName, gConfig[1].fName, gConfig[2].fName, nullptr);
fAppMenu->assignKeyEquivalentToItem(itemID, 'C');
itemID = fAppMenu->appendSwitch("sRGB SkColor", "sRGB SkColor", sinkID, gTreatSkColorAsSRGB);
fAppMenu->assignKeyEquivalentToItem(itemID, 'S');
itemID = fAppMenu->appendList("Device Type", "Device Type", sinkID, 0,
"Raster",
@ -1549,8 +1547,7 @@ bool SampleWindow::onEvent(const SkEvent& evt) {
SkOSMenu::FindListIndex(evt, "Hinting", &fHintingState) ||
SkOSMenu::FindSwitchState(evt, "Clip", &fUseClip) ||
SkOSMenu::FindSwitchState(evt, "Zoomer", &fShowZoomer) ||
SkOSMenu::FindSwitchState(evt, "Magnify", &fMagnify) ||
SkOSMenu::FindSwitchState(evt, "sRGB SkColor", &gTreatSkColorAsSRGB))
SkOSMenu::FindSwitchState(evt, "Magnify", &fMagnify))
{
this->inval(nullptr);
this->updateTitle();
@ -2060,10 +2057,6 @@ void SampleWindow::updateTitle() {
title.appendf(" %d bpc", fDevManager->getColorBits());
}
if (gTreatSkColorAsSRGB) {
title.append(" sRGB");
}
this->setTitle(title.c_str());
}

View File

@ -9,8 +9,6 @@
#include "SkColorPriv.h"
#include "SkFixed.h"
bool gTreatSkColorAsSRGB;
SkPMColor SkPreMultiplyARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {
return SkPremultiplyARGBInline(a, r, g, b);
}
@ -158,17 +156,15 @@ SkColor4f SkColor4f::FromColor(SkColor c) {
Sk4f value = SkNx_shuffle<2,1,0,3>(SkNx_cast<float>(Sk4b::Load(&c)));
SkColor4f c4;
(value * Sk4f(1.0f / 255)).store(&c4);
if (gTreatSkColorAsSRGB) {
c4.fR = srgb_to_linear(c4.fR);
c4.fG = srgb_to_linear(c4.fG);
c4.fB = srgb_to_linear(c4.fB);
}
c4.fR = srgb_to_linear(c4.fR);
c4.fG = srgb_to_linear(c4.fG);
c4.fB = srgb_to_linear(c4.fB);
return c4;
}
SkColor SkColor4f::toSkColor() const {
SkColor result;
Sk4f value = SkNx_shuffle<2, 1, 0, 3>(Sk4f::Load(this->vec()));
Sk4f value = Sk4f(linear_to_srgb(fB), linear_to_srgb(fG), linear_to_srgb(fR), fA);
SkNx_cast<uint8_t>(value * Sk4f(255) + Sk4f(0.5f)).store(&result);
return result;
}

View File

@ -11,8 +11,6 @@
#include "SkColorPriv.h"
#include "SkPM4f.h"
extern bool gTreatSkColorAsSRGB;
static inline float get_alpha(const Sk4f& f4) {
return f4[SkPM4f::A];
}
@ -108,7 +106,7 @@ static inline Sk4f Sk4f_fromS32(uint32_t src) {
// SkColor has an ordering of (b, g, r, a) if cast to an Sk4f, so the code swizzles r and b to
// produce the needed (r, g, b, a) ordering.
static inline Sk4f Sk4f_from_SkColor(SkColor color) {
return swizzle_rb(gTreatSkColorAsSRGB ? Sk4f_fromS32(color) : Sk4f_fromL32(color));
return swizzle_rb(Sk4f_fromS32(color));
}
static inline uint32_t Sk4f_toL32(const Sk4f& x4) {

View File

@ -43,7 +43,6 @@ DEF_TEST(SkColor4f_FromColor, reporter) {
{ SK_ColorGREEN, { 0, 1, 0, 1 } },
{ SK_ColorBLUE, { 0, 0, 1, 1 } },
{ 0, { 0, 0, 0, 0 } },
{ 0x55AAFF00, { 2/3.0f, 1, 0, 1 / 3.0f } },
};
for (const auto& r : recs) {
@ -97,35 +96,6 @@ static sk_sp<SkColorFilter> make_compose_cf() {
return SkColorFilter::MakeComposeFilter(make_mode_cf(), make_mx_cf());
}
static sk_sp<SkShader> make_color_sh() { return SkShader::MakeColorShader(0xFFBB8855); }
static sk_sp<SkShader> make_image_sh() {
const SkImageInfo info = SkImageInfo::MakeN32Premul(2, 2);
const SkPMColor pixels[] {
SkPackARGB32(0xFF, 0xBB, 0x88, 0x55),
SkPackARGB32(0xFF, 0xBB, 0x88, 0x55),
SkPackARGB32(0xFF, 0xBB, 0x88, 0x55),
SkPackARGB32(0xFF, 0xBB, 0x88, 0x55),
};
sk_sp<SkImage> image(SkImage::MakeRasterCopy(SkPixmap(info, pixels, sizeof(SkPMColor) * 2)));
return image->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode);
}
static sk_sp<SkShader> make_grad_sh() {
#if 0
const SkPoint pts[] {{ 0, 0 }, { 100, 100 }};
const SkColor colors[] { SK_ColorRED, SK_ColorBLUE };
return SkGradientShader::CreateLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode);
#else
// TODO: need to convert new gradient code to enforce PM4f --> RGBA order
return make_color_sh();
#endif
}
static sk_sp<SkShader> make_cf_sh() {
return make_color_sh()->makeWithColorFilter(make_mx_cf());
}
static bool compare_spans(const SkPM4f span4f[], const SkPMColor span4b[], int count,
float tolerance = 1.0f/255) {
for (int i = 0; i < count; ++i) {
@ -138,42 +108,6 @@ static bool compare_spans(const SkPM4f span4f[], const SkPMColor span4b[], int c
return true;
}
DEF_TEST(Color4f_shader, reporter) {
struct {
sk_sp<SkShader> (*fFact)();
bool fSupports4f;
float fTolerance;
} recs[] = {
{ make_color_sh, true, 1.0f/255 },
// PMColor 4f gradients are interpolated in 255-multiplied values, so we need a
// slightly relaxed tolerance to accommodate the cumulative precision deviation.
{ make_grad_sh, true, 1.001f/255 },
{ make_image_sh, false, 1.0f/255 },
{ make_cf_sh, true, 1.0f/255 },
};
SkPaint paint;
for (const auto& rec : recs) {
uint32_t storage[kSkBlitterContextSize];
paint.setShader(rec.fFact());
// Encourage 4f context selection. At some point we may need
// to instantiate two separate contexts for optimal 4b/4f selection.
const SkShader::ContextRec contextRec(paint, SkMatrix::I(), nullptr,
SkShader::ContextRec::kPM4f_DstType);
SkASSERT(paint.getShader()->contextSize(contextRec) <= sizeof(storage));
SkShader::Context* ctx = paint.getShader()->createContext(contextRec, storage);
if (rec.fSupports4f) {
const int N = 100;
SkPM4f buffer4f[N];
ctx->shadeSpan4f(0, 0, buffer4f, N);
SkPMColor buffer4b[N];
ctx->shadeSpan(0, 0, buffer4b, N);
REPORTER_ASSERT(reporter, compare_spans(buffer4f, buffer4b, N, rec.fTolerance));
}
ctx->~Context();
}
}
DEF_TEST(Color4f_colorfilter, reporter) {
struct {
sk_sp<SkColorFilter> (*fFact)();

View File

@ -201,11 +201,6 @@ bool Request::setColorMode(int mode) {
return enableGPU(fGPUEnabled);
}
bool Request::setSRGBMode(bool enable) {
gTreatSkColorAsSRGB = enable;
return true;
}
bool Request::enableGPU(bool enable) {
if (enable) {
SkSurface* surface = this->createGPUSurface();
@ -258,7 +253,6 @@ SkData* Request::getJsonOps(int n) {
root["mode"] = Json::Value(fGPUEnabled ? "gpu" : "cpu");
root["drawGpuBatchBounds"] = Json::Value(fDebugCanvas->getDrawGpuBatchBounds());
root["colorMode"] = Json::Value(fColorMode);
root["srgbMode"] = Json::Value(gTreatSkColorAsSRGB);
SkDynamicMemoryWStream stream;
stream.writeText(Json::FastWriter().write(root).c_str());

View File

@ -42,7 +42,6 @@ struct Request {
SkBitmap* getBitmapFromCanvas(SkCanvas* canvas);
bool enableGPU(bool enable);
bool setColorMode(int mode);
bool setSRGBMode(bool enable);
bool hasPicture() const { return SkToBool(fPicture.get()); }
int getLastOp() const { return fDebugCanvas->getSize() - 1; }

View File

@ -45,7 +45,6 @@ public:
fHandlers.push_back(new BatchesHandler);
fHandlers.push_back(new BatchBoundsHandler);
fHandlers.push_back(new ColorModeHandler);
fHandlers.push_back(new SRGBModeHandler);
fHandlers.push_back(new QuitHandler);
}

View File

@ -1,42 +0,0 @@
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "UrlHandler.h"
#include "microhttpd.h"
#include "../Request.h"
#include "../Response.h"
using namespace Response;
bool SRGBModeHandler::canHandle(const char* method, const char* url) {
static const char* kBasePath = "/srgbMode/";
return 0 == strcmp(method, MHD_HTTP_METHOD_POST) &&
0 == strncmp(url, kBasePath, strlen(kBasePath));
}
int SRGBModeHandler::handle(Request* request, MHD_Connection* connection,
const char* url, const char* method,
const char* upload_data, size_t* upload_data_size) {
SkTArray<SkString> commands;
SkStrSplit(url, "/", &commands);
if (commands.count() != 2) {
return MHD_NO;
}
int enable;
if (1 != sscanf(commands[1].c_str(), "%d", &enable)) {
return MHD_NO;
}
bool success = request->setSRGBMode(SkToBool(enable));
if (!success) {
return SendError(connection, "Unable to set requested mode");
}
return SendOK(connection);
}

View File

@ -142,19 +142,6 @@ public:
const char* upload_data, size_t* upload_data_size) override;
};
/**
* Controls the global sRGB flag (is SkColor treated as sRGB or not).
* Posting to /srgbMode/0 causes SkColor to be linear, /colorMode/1
* causes SkColor to be sRGB;
*/
class SRGBModeHandler : public UrlHandler {
public:
bool canHandle(const char* method, const char* url) override;
int handle(Request* request, MHD_Connection* connection,
const char* url, const char* method,
const char* upload_data, size_t* upload_data_size) override;
};
class QuitHandler : public UrlHandler {
public:
bool canHandle(const char* method, const char* url) override;