intentionallyLeaked->start();
}
-extern bool gDefaultProfileIsSRGB;
-
int nanobench_main();
int nanobench_main() {
SetupCrashHandler();
gGrFactory.reset(new GrContextFactory(grContextOpts));
#endif
- if (FLAGS_forceSRGB) {
- gDefaultProfileIsSRGB = true;
- }
-
if (FLAGS_veryVerbose) {
FLAGS_verbose = true;
}
extern sk_sp<SkTypeface> (*gCreateTypefaceDelegate)(const char [], SkFontStyle );
-extern bool gDefaultProfileIsSRGB;
-
int dm_main();
int dm_main() {
setbuf(stdout, nullptr);
gVLog = freopen(SkOSPath::Join(FLAGS_writePath[0], "verbose.log").c_str(), "w", stderr);
}
- if (FLAGS_forceSRGB) {
- gDefaultProfileIsSRGB = true;
- }
-
JsonWriter::DumpJson(); // It's handy for the bots to assume this is ~never missing.
SkAutoGraphics ag;
SkTaskGroup::Enabler enabled(FLAGS_threads);
SkPixmap pmdst;
bmdst.peekPixels(&pmdst);
- SkImageInfo info = SkImageInfo::MakeN32Premul(ir.width(), ir.height(), kLinear_SkColorProfileType);
+ SkImageInfo info = SkImageInfo::MakeN32Premul(ir.width(), ir.height());
sk_sp<SkImage> image(SkImage::MakeRasterCopy(SkPixmap(info, pmsrc.addr32(), pmsrc.rowBytes())));
SkPaint paint;
}
uint32_t flags = 0;
- //if (kSRGB_SkColorProfileType == profile) {
- //flags |= SkXfermode::kDstIsSRGB_PM4fFlag;
- //}
auto procN = SkXfermode::GetD32Proc(nullptr, flags);
SkLinearBitmapPipeline pipeline{
static void make_color_test_bitmap_variant(
SkColorType colorType,
SkAlphaType alphaType,
- SkColorProfileType profile,
+ sk_sp<SkColorSpace> colorSpace,
SkBitmap* bm)
{
SkASSERT(colorType == kRGBA_8888_SkColorType || colorType == kBGRA_8888_SkColorType);
SkASSERT(alphaType == kPremul_SkAlphaType || alphaType == kUnpremul_SkAlphaType);
bm->allocPixels(
- SkImageInfo::Make(SCALE, SCALE, colorType, alphaType, profile));
+ SkImageInfo::Make(SCALE, SCALE, colorType, alphaType, colorSpace));
SkPixmap pm;
bm->peekPixels(&pm);
for (int y = 0; y < bm->height(); y++) {
DEF_SIMPLE_GM(all_variants_8888, canvas, 4 * SCALE + 30, 2 * SCALE + 10) {
sk_tool_utils::draw_checkerboard(canvas, SK_ColorLTGRAY, SK_ColorWHITE, 8);
- for (auto profile : {kSRGB_SkColorProfileType, kLinear_SkColorProfileType}) {
+ sk_sp<SkColorSpace> colorSpaces[] {
+ nullptr,
+ SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)
+ };
+ for (auto colorSpace : colorSpaces) {
canvas->save();
for (auto alphaType : {kPremul_SkAlphaType, kUnpremul_SkAlphaType}) {
canvas->save();
for (auto colorType : {kRGBA_8888_SkColorType, kBGRA_8888_SkColorType}) {
SkBitmap bm;
- make_color_test_bitmap_variant(colorType, alphaType, profile, &bm);
+ make_color_test_bitmap_variant(colorType, alphaType, colorSpace, &bm);
canvas->drawBitmap(bm, 0.0f, 0.0f);
canvas->translate(SCALE + 10, 0.0f);
}
// even if it holds sRGB values.
bg.setColor(0xFFFFFFFF);
- SkColorProfileType const profiles[] { kLinear_SkColorProfileType, kSRGB_SkColorProfileType };
- for (auto profile : profiles) {
+ sk_sp<SkColorSpace> colorSpaces[]{
+ nullptr,
+ SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)
+ };
+ for (auto colorSpace : colorSpaces) {
const SkImageInfo info = SkImageInfo::Make(1024, 100, kN32_SkColorType, kPremul_SkAlphaType,
- profile);
+ colorSpace);
auto surface(SkSurface::MakeRaster(info));
surface->getCanvas()->drawPaint(bg);
draw_into_canvas(surface->getCanvas());
// set up offscreen rendering with distance field text
#if SK_SUPPORT_GPU
GrContext* ctx = inputCanvas->getGrContext();
- SkImageInfo info = SkImageInfo::MakeN32Premul(onISize(),
- inputCanvas->imageInfo().profileType());
+ SkISize size = onISize();
+ SkImageInfo info = SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType,
+ sk_ref_sp(inputCanvas->imageInfo().colorSpace()));
SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType);
uint32_t gammaCorrect = inputCanvas->getProps(&canvasProps)
? canvasProps.flags() & SkSurfaceProps::kGammaCorrect_Flag : 0;
const SkScalar tx = sz + 5.0f;
const SkRect r = SkRect::MakeXYWH(0, 0, sz, sz);
SkShader::TileMode rpt = SkShader::kRepeat_TileMode;
+ auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
SkBitmap ditherBmp;
ditherBmp.allocN32Pixels(2, 2);
pixels[1] = pixels[2] = SkPackARGB32(0xFF, 0, 0, 0);
SkBitmap linearGreyBmp;
- SkImageInfo linearGreyInfo = SkImageInfo::MakeN32(szInt, szInt, kOpaque_SkAlphaType,
- kLinear_SkColorProfileType);
+ SkImageInfo linearGreyInfo = SkImageInfo::MakeN32(szInt, szInt, kOpaque_SkAlphaType, nullptr);
linearGreyBmp.allocPixels(linearGreyInfo);
linearGreyBmp.eraseARGB(0xFF, 0x7F, 0x7F, 0x7F);
SkBitmap srgbGreyBmp;
SkImageInfo srgbGreyInfo = SkImageInfo::MakeN32(szInt, szInt, kOpaque_SkAlphaType,
- kSRGB_SkColorProfileType);
+ srgbColorSpace);
srgbGreyBmp.allocPixels(srgbGreyInfo);
// 0xBC = 255 * linear_to_srgb(0.5f)
srgbGreyBmp.eraseARGB(0xFF, 0xBC, 0xBC, 0xBC);
SkBitmap mipmapBmp;
SkImageInfo mipmapInfo = SkImageInfo::Make(2, 2, kN32_SkColorType, kOpaque_SkAlphaType,
- SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named));
+ srgbColorSpace);
mipmapBmp.allocPixels(mipmapInfo);
SkPMColor* mipmapPixels = reinterpret_cast<SkPMColor*>(mipmapBmp.getPixels());
unsigned s25 = 0x89; // 255 * linear_to_srgb(0.25f)
// must be opaque to have a hope of testing LCD text
const SkImageInfo info = SkImageInfo::MakeN32(W, H, kOpaque_SkAlphaType,
- canvas->imageInfo().profileType());
+ sk_ref_sp(canvas->imageInfo().colorSpace()));
SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType);
bool gammaCorrect = canvas->getProps(&canvasProps) && canvasProps.isGammaCorrect();
SkAutoTUnref<const SkTextBlob> blob(builder.build());
- SkImageInfo info = SkImageInfo::MakeN32Premul(200, 200, canvas->imageInfo().profileType());
+ SkImageInfo info = SkImageInfo::MakeN32(200, 200, kPremul_SkAlphaType,
+ sk_ref_sp(canvas->imageInfo().colorSpace()));
SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType);
uint32_t gammaCorrect = canvas->getProps(&canvasProps)
? canvasProps.flags() & SkSurfaceProps::kGammaCorrect_Flag : 0;
#if SK_SUPPORT_GPU
// Create a new Canvas to enable DFT
GrContext* ctx = inputCanvas->getGrContext();
- SkImageInfo info = SkImageInfo::MakeN32Premul(onISize(),
- inputCanvas->imageInfo().profileType());
+ SkISize size = onISize();
+ sk_sp<SkColorSpace> colorSpace = sk_ref_sp(inputCanvas->imageInfo().colorSpace());
+ SkImageInfo info = SkImageInfo::MakeN32(size.width(), size.height(),
+ kPremul_SkAlphaType, colorSpace);
SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType);
uint32_t gammaCorrect = inputCanvas->getProps(&canvasProps)
? canvasProps.flags() & SkSurfaceProps::kGammaCorrect_Flag : 0;
canvas->drawColor(sk_tool_utils::color_to_565(SK_ColorWHITE));
- SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight,
- canvas->imageInfo().profileType());
+ SkImageInfo info = SkImageInfo::MakeN32(kWidth, kHeight, kPremul_SkAlphaType,
+ sk_ref_sp(canvas->imageInfo().colorSpace()));
SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType);
uint32_t gammaCorrect = canvas->getProps(&canvasProps)
? canvasProps.flags() & SkSurfaceProps::kGammaCorrect_Flag : 0;
GrContext* context = baseCanvas->getGrContext();
SkImageInfo baseInfo = baseCanvas->imageInfo();
SkImageInfo info = SkImageInfo::Make(w, h, baseInfo.colorType(), baseInfo.alphaType(),
- baseInfo.profileType());
+ sk_ref_sp(baseInfo.colorSpace()));
SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType);
baseCanvas->getProps(&canvasProps);
return SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info, 0, &canvasProps);
'<(skia_include_path)/private/SkFloatBits.h',
'<(skia_include_path)/private/SkFloatingPoint.h',
'<(skia_include_path)/private/SkGpuFenceSync.h',
- '<(skia_include_path)/private/SkImageInfoPriv.h',
'<(skia_include_path)/private/SkMiniRecorder.h',
'<(skia_include_path)/private/SkMutex.h',
'<(skia_include_path)/private/SkOnce.h',
+++ /dev/null
-/*
- * Copyright 2016 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#ifndef SkImageInfoPriv_DEFINED
-#define SkImageInfoPriv_DEFINED
-
-#include "SkImageInfo.h"
-
-SK_API SkColorProfileType SkDefaultColorProfile();
-
-#endif // SkImageInfoPriv_DEFINED
const SkPaint* paint) {
// need to force L32 for now if we have an image filter. Once filters support other colortypes
// e.g. sRGB or F16, we can remove this check
+ // SRGBTODO: Can we remove this check now?
const bool hasImageFilter = paint && paint->getImageFilter();
SkAlphaType alphaType = isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
return SkImageInfo::MakeN32(w, h, alphaType);
} else {
// keep the same characteristics as the prev
- return SkImageInfo::Make(w, h, prev.colorType(), alphaType, prev.profileType());
+ return SkImageInfo::Make(w, h, prev.colorType(), alphaType, sk_ref_sp(prev.colorSpace()));
}
}
*/
#include "SkImageInfo.h"
-#include "SkImageInfoPriv.h"
#include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
}
#endif
-// Indicate how images and gradients should interpret colors by default.
-bool gDefaultProfileIsSRGB;
-
-SkColorProfileType SkDefaultColorProfile() {
- return gDefaultProfileIsSRGB ? kSRGB_SkColorProfileType
- : kLinear_SkColorProfileType;
-}
-
static bool alpha_type_is_valid(SkAlphaType alphaType) {
return (alphaType >= 0) && (alphaType <= kLastEnum_SkAlphaType);
}
bool sw_convert_to_premul(GrPixelConfig srcConfig, int width, int height, size_t inRowBytes,
const void* inPixels, size_t outRowBytes, void* outPixels) {
SkSrcPixelInfo srcPI;
- if (!GrPixelConfig2ColorAndProfileType(srcConfig, &srcPI.fColorType, nullptr)) {
+ if (!GrPixelConfigToColorAndColorSpace(srcConfig, &srcPI.fColorType, nullptr)) {
return false;
}
srcPI.fAlphaType = kUnpremul_SkAlphaType;
// Perform umpremul conversion if we weren't able to perform it as a draw.
if (unpremul) {
SkDstPixelInfo dstPI;
- if (!GrPixelConfig2ColorAndProfileType(dstConfig, &dstPI.fColorType, nullptr)) {
+ if (!GrPixelConfigToColorAndColorSpace(dstConfig, &dstPI.fColorType, nullptr)) {
return false;
}
dstPI.fAlphaType = kUnpremul_SkAlphaType;
SkImageInfo GrSurface::info(SkAlphaType alphaType) const {
SkColorType colorType;
- SkColorProfileType profileType;
- if (!GrPixelConfig2ColorAndProfileType(this->config(), &colorType, &profileType)) {
+ sk_sp<SkColorSpace> colorSpace;
+ if (!GrPixelConfigToColorAndColorSpace(this->config(), &colorType, &colorSpace)) {
sk_throw();
}
- return SkImageInfo::Make(this->width(), this->height(), colorType, alphaType,
- profileType);
+ return SkImageInfo::Make(this->width(), this->height(), colorType, alphaType, colorSpace);
}
// TODO: This should probably be a non-member helper function. It might only be needed in
return kUnknown_GrPixelConfig;
}
-bool GrPixelConfig2ColorAndProfileType(GrPixelConfig config, SkColorType* ctOut,
- SkColorProfileType* ptOut) {
+bool GrPixelConfigToColorAndColorSpace(GrPixelConfig config, SkColorType* ctOut,
+ sk_sp<SkColorSpace>* csOut) {
SkColorType ct;
- SkColorProfileType pt = kLinear_SkColorProfileType;
+ sk_sp<SkColorSpace> cs = nullptr;
switch (config) {
case kAlpha_8_GrPixelConfig:
ct = kAlpha_8_SkColorType;
break;
case kSRGBA_8888_GrPixelConfig:
ct = kRGBA_8888_SkColorType;
- pt = kSRGB_SkColorProfileType;
+ cs = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
break;
case kSBGRA_8888_GrPixelConfig:
ct = kBGRA_8888_SkColorType;
- pt = kSRGB_SkColorProfileType;
+ cs = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
break;
case kRGBA_half_GrPixelConfig:
ct = kRGBA_F16_SkColorType;
if (ctOut) {
*ctOut = ct;
}
- if (ptOut) {
- *ptOut = pt;
+ if (csOut) {
+ *csOut = cs;
}
return true;
}
SkASSERT(h <= desc.fHeight);
#endif
const GrPixelConfig config = tex->config();
- SkColorType ct;
+ SkColorType ct = kUnknown_SkColorType;
SkAlphaType at = isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
- if (!GrPixelConfig2ColorAndProfileType(config, &ct, nullptr)) {
+ if (!GrPixelConfigToColorAndColorSpace(config, &ct, nullptr)) {
ct = kUnknown_SkColorType;
}
return SkImageInfo::Make(w, h, ct, at);
GrSurfaceDesc GrImageInfoToSurfaceDesc(const SkImageInfo&, const GrCaps&);
-bool GrPixelConfig2ColorAndProfileType(GrPixelConfig, SkColorType*, SkColorProfileType*);
+bool GrPixelConfigToColorAndColorSpace(GrPixelConfig, SkColorType*, sk_sp<SkColorSpace>*);
/**
* If the compressed data in the SkData is supported (as a texture format, this returns
DEFINE_bool(dryRun, false,
"just print the tests that would be run, without actually running them.");
-DEFINE_bool(forceSRGB, false, "Force SRGB for imageinfos");
-
DEFINE_bool(gpu, true, "master switch for running GPU-bound work.");
DEFINE_string(images, "", "List of images and/or directories to decode. A directory with no images"
DECLARE_bool(cpu);
DECLARE_bool(dryRun);
-DECLARE_bool(forceSRGB);
DECLARE_bool(gpu);
DECLARE_string(images);
DECLARE_string(colorImages);