Remove more SkColorSpaceXform (and friends)
- gammaencodedpremul GM was just demonstrating something that we understand well (and have much better testing for). - readpixels GM was filled with workarounds for things that are no longer true (unpremul images, clamped F16). - Other uses can be switched to SkConvertPixels trivially. - Remove SkColorSpaceXformPriv and SkColorLookUpTable, all unused. - Remove SkColorSpaceXform_skcms.cpp, no longer referenced by clients. Bug: skia: Change-Id: I7298bb53aa61b49ad1398ebc504d35c119fd5cf4 Reviewed-on: https://skia-review.googlesource.com/157153 Commit-Queue: Mike Klein <mtklein@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
parent
7a3197bae3
commit
5ea41fc89b
@ -8,7 +8,6 @@
|
||||
#include "../src/jumper/SkJumper.h"
|
||||
#include "Benchmark.h"
|
||||
#include "SkColor.h"
|
||||
#include "SkColorSpaceXform.h"
|
||||
#include "SkColorSpaceXformer.h"
|
||||
#include "SkColorSpaceXformSteps.h"
|
||||
#include "SkMakeUnique.h"
|
||||
@ -16,14 +15,13 @@
|
||||
#include "SkRandom.h"
|
||||
#include "SkRasterPipeline.h"
|
||||
|
||||
enum class Mode { xform, steps, pipeA, pipeB, xformer };
|
||||
enum class Mode { steps, pipeA, pipeB, xformer };
|
||||
|
||||
struct ColorSpaceXformBench : public Benchmark {
|
||||
ColorSpaceXformBench(Mode mode) : fMode(mode) {}
|
||||
|
||||
const Mode fMode;
|
||||
|
||||
std::unique_ptr<SkColorSpaceXform> fXform;
|
||||
std::unique_ptr<SkColorSpaceXformSteps> fSteps;
|
||||
std::function<void(size_t, size_t, size_t, size_t)> fPipeA;
|
||||
|
||||
@ -35,7 +33,6 @@ struct ColorSpaceXformBench : public Benchmark {
|
||||
|
||||
const char* onGetName() override {
|
||||
switch (fMode) {
|
||||
case Mode::xform : return "ColorSpaceXformBench_xform";
|
||||
case Mode::steps : return "ColorSpaceXformBench_steps";
|
||||
case Mode::pipeA : return "ColorSpaceXformBench_pipeA";
|
||||
case Mode::pipeB : return "ColorSpaceXformBench_pipeB";
|
||||
@ -51,7 +48,6 @@ struct ColorSpaceXformBench : public Benchmark {
|
||||
dst = SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma,
|
||||
SkColorSpace::kDCIP3_D65_Gamut);
|
||||
|
||||
fXform = SkColorSpaceXform::New(src.get(), dst.get());
|
||||
fSteps = skstd::make_unique<SkColorSpaceXformSteps>(src.get(), kOpaque_SkAlphaType,
|
||||
dst.get(), kPremul_SkAlphaType);
|
||||
|
||||
@ -76,12 +72,6 @@ struct ColorSpaceXformBench : public Benchmark {
|
||||
fPipeDst.pixels = &dst;
|
||||
|
||||
switch (fMode) {
|
||||
case Mode::xform: {
|
||||
fXform->apply(SkColorSpaceXform::kBGRA_8888_ColorFormat, &dst,
|
||||
SkColorSpaceXform::kBGRA_8888_ColorFormat, &src,
|
||||
1, kUnpremul_SkAlphaType);
|
||||
} break;
|
||||
|
||||
case Mode::steps: {
|
||||
float rgba[4];
|
||||
swizzle_rb(Sk4f_fromL32(src)).store(rgba);
|
||||
@ -116,7 +106,6 @@ struct ColorSpaceXformBench : public Benchmark {
|
||||
}
|
||||
};
|
||||
|
||||
DEF_BENCH(return new ColorSpaceXformBench{Mode::xform };)
|
||||
DEF_BENCH(return new ColorSpaceXformBench{Mode::steps };)
|
||||
DEF_BENCH(return new ColorSpaceXformBench{Mode::pipeA };)
|
||||
DEF_BENCH(return new ColorSpaceXformBench{Mode::pipeB };)
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "SkCodec.h"
|
||||
#include "SkCodecImageGenerator.h"
|
||||
#include "SkColorSpace.h"
|
||||
#include "SkColorSpaceXform.h"
|
||||
#include "SkColorSpaceXformCanvas.h"
|
||||
#include "SkCommonFlags.h"
|
||||
#include "SkCommonFlagsGpu.h"
|
||||
|
@ -1,133 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "gm.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkColorSpaceXform.h"
|
||||
#include "SkColorSpaceXformPriv.h"
|
||||
#include "SkOpts.h"
|
||||
#include "SkUtils.h"
|
||||
|
||||
static void clamp_to_alpha(uint32_t* pixels, int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
uint8_t a = SkGetPackedA32(pixels[i]);
|
||||
uint8_t r = SkGetPackedR32(pixels[i]);
|
||||
uint8_t g = SkGetPackedG32(pixels[i]);
|
||||
uint8_t b = SkGetPackedB32(pixels[i]);
|
||||
pixels[i] = SkPackARGB32(a,
|
||||
SkTMin(a, r),
|
||||
SkTMin(a, g),
|
||||
SkTMin(a, b));
|
||||
}
|
||||
}
|
||||
|
||||
class GammaEncodedPremulGM : public skiagm::GM {
|
||||
public:
|
||||
GammaEncodedPremulGM(sk_sp<SkColorSpace> dst, sk_sp<SkColorSpace> src, const char* desc)
|
||||
: fDstSpace(dst)
|
||||
, fSrcSpace(src)
|
||||
, fXform(SkColorSpaceXform::New(src.get(), dst.get()))
|
||||
, fName(SkStringPrintf("gamma_encoded_premul_dst-v-src_%s", desc))
|
||||
{
|
||||
int i = 0;
|
||||
for (int r = 0; r < kColorSteps; r++) {
|
||||
for (int g = 0; g < kColorSteps; g++) {
|
||||
for (int b = 0; b < kColorSteps; b++) {
|
||||
fColors[i++] = SkColorSetRGB(r * kColorScale,
|
||||
g * kColorScale,
|
||||
b * kColorScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual SkISize onISize() override {
|
||||
return SkISize::Make(kAlphaMax, kNumColors * 2 * kStripeHeight);
|
||||
}
|
||||
|
||||
SkString onShortName() override {
|
||||
return fName;
|
||||
}
|
||||
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
if (canvas->imageInfo().isOpaque()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkBitmap bitmap;
|
||||
SkImageInfo bitmapInfo = SkImageInfo::MakeN32Premul(kAlphaMax, 1,
|
||||
canvas->imageInfo().refColorSpace());
|
||||
bitmap.allocPixels(bitmapInfo);
|
||||
uint32_t* pixels = bitmap.getAddr32(0, 0);
|
||||
|
||||
for (int i = 0; i < kNumColors; i++) {
|
||||
// Create an entire row of the same color, with the alpha from 0 to kAlphaMax.
|
||||
uint32_t row[kAlphaMax];
|
||||
sk_memset32(row, fColors[i], kAlphaMax);
|
||||
for (int a = 0; a < kAlphaMax; a++) {
|
||||
row[a] = (row[a] & 0x00FFFFFF) | (a << 24);
|
||||
}
|
||||
|
||||
// Tranform row to dst, then premultiply.
|
||||
fXform->apply(select_xform_format(kN32_SkColorType), pixels,
|
||||
SkColorSpaceXform::kBGRA_8888_ColorFormat, row, kAlphaMax,
|
||||
kUnpremul_SkAlphaType);
|
||||
SkOpts::RGBA_to_rgbA(pixels, pixels, kAlphaMax);
|
||||
bitmap.notifyPixelsChanged();
|
||||
|
||||
// Write the dst space premultiplied row to the canvas.
|
||||
for (int j = 0; j < kStripeHeight; j++) {
|
||||
canvas->drawBitmap(bitmap, 0, 2 * i * kStripeHeight + j);
|
||||
}
|
||||
|
||||
// Premultiply, then transform the row to dst.
|
||||
SkOpts::RGBA_to_rgbA(pixels, row, kAlphaMax);
|
||||
fXform->apply(select_xform_format(kN32_SkColorType), pixels,
|
||||
SkColorSpaceXform::kBGRA_8888_ColorFormat, pixels, kAlphaMax,
|
||||
kUnpremul_SkAlphaType);
|
||||
clamp_to_alpha(pixels, kAlphaMax);
|
||||
bitmap.notifyPixelsChanged();
|
||||
|
||||
// Write the src space premultiplied row to the canvas.
|
||||
for (int j = 0; j < kStripeHeight; j++) {
|
||||
canvas->drawBitmap(bitmap, 0, (2 * i + 1) * kStripeHeight + j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr int kColorSteps = 4;
|
||||
static constexpr int kNumColors = kColorSteps * kColorSteps * kColorSteps;
|
||||
static constexpr int kColorScale = 255 / (kColorSteps - 1);
|
||||
static constexpr int kStripeHeight = 10;
|
||||
static constexpr int kAlphaMax = 255;
|
||||
|
||||
sk_sp<SkColorSpace> fDstSpace;
|
||||
sk_sp<SkColorSpace> fSrcSpace;
|
||||
std::unique_ptr<SkColorSpaceXform> fXform;
|
||||
SkString fName;
|
||||
SkColor fColors[kNumColors];
|
||||
|
||||
typedef GM INHERITED;
|
||||
};
|
||||
|
||||
DEF_GM(return new GammaEncodedPremulGM(SkColorSpace::MakeSRGB(),
|
||||
SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma, SkColorSpace::kRec2020_Gamut),
|
||||
"toWideGamut");)
|
||||
DEF_GM(return new GammaEncodedPremulGM(SkColorSpace::MakeRGB(SkColorSpace::kSRGB_RenderTargetGamma,
|
||||
SkColorSpace::kRec2020_Gamut), SkColorSpace::MakeSRGB(), "fromWideGamut");)
|
||||
DEF_GM(return new GammaEncodedPremulGM(SkColorSpace::MakeSRGB(),
|
||||
SkColorSpace::MakeRGB(SkColorSpace::kLinear_RenderTargetGamma, SkColorSpace::kSRGB_Gamut),
|
||||
"toLinear");)
|
||||
DEF_GM(return new GammaEncodedPremulGM(
|
||||
SkColorSpace::MakeRGB(SkColorSpace::kLinear_RenderTargetGamma, SkColorSpace::kSRGB_Gamut),
|
||||
SkColorSpace::MakeSRGB(), "fromLinear");)
|
||||
DEF_GM(return new GammaEncodedPremulGM(
|
||||
SkColorSpace::MakeRGB({ 1.8f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
|
||||
SkColorSpace::kSRGB_Gamut), SkColorSpace::MakeSRGB(), "from1.8");)
|
@ -10,36 +10,11 @@
|
||||
#include "SkCodec.h"
|
||||
#include "SkColorSpace.h"
|
||||
#include "SkColorSpacePriv.h"
|
||||
#include "SkColorSpaceXform.h"
|
||||
#include "SkColorSpaceXformPriv.h"
|
||||
#include "SkHalf.h"
|
||||
#include "SkImage.h"
|
||||
#include "SkImageInfoPriv.h"
|
||||
#include "SkPictureRecorder.h"
|
||||
|
||||
static void clamp_if_necessary(const SkImageInfo& info, void* pixels) {
|
||||
if (kRGBA_F16_SkColorType != info.colorType()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int y = 0; y < info.height(); y++) {
|
||||
for (int x = 0; x < info.width(); x++) {
|
||||
uint64_t pixel = ((uint64_t*) pixels)[y * info.width() + x];
|
||||
|
||||
Sk4f rgba = SkHalfToFloat_finite_ftz(pixel);
|
||||
if (kUnpremul_SkAlphaType == info.alphaType()) {
|
||||
rgba = Sk4f::Max(0.0f, Sk4f::Min(rgba, 1.0f));
|
||||
} else {
|
||||
SkASSERT(kPremul_SkAlphaType == info.alphaType());
|
||||
rgba = Sk4f::Max(0.0f, Sk4f::Min(rgba, rgba[3]));
|
||||
}
|
||||
SkFloatToHalf_finite_ftz(rgba).store(&pixel);
|
||||
|
||||
((uint64_t*) pixels)[y * info.width() + x] = pixel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const int kWidth = 64;
|
||||
static const int kHeight = 64;
|
||||
|
||||
@ -129,20 +104,6 @@ static void draw_image(SkCanvas* canvas, SkImage* image, SkColorType dstColorTyp
|
||||
memset(data->writable_data(), 0, rowBytes * image->height());
|
||||
}
|
||||
|
||||
// SkImage must be premul, so manually premul the data if we unpremul'd during readPixels
|
||||
if (kUnpremul_SkAlphaType == dstAlphaType) {
|
||||
auto xform = SkColorSpaceXform::New(dstColorSpace.get(), dstColorSpace.get());
|
||||
if (!xform->apply(select_xform_format(dstColorType), data->writable_data(),
|
||||
select_xform_format(dstColorType), data->data(),
|
||||
image->width() * image->height(), kPremul_SkAlphaType)) {
|
||||
memset(data->writable_data(), 0, rowBytes * image->height());
|
||||
}
|
||||
dstInfo = dstInfo.makeAlphaType(kPremul_SkAlphaType);
|
||||
}
|
||||
|
||||
// readPixels() does not always clamp F16. The drawing code expects pixels in the 0-1 range.
|
||||
clamp_if_necessary(dstInfo, data->writable_data());
|
||||
|
||||
// Now that we have called readPixels(), dump the raw pixels into an srgb image.
|
||||
sk_sp<SkColorSpace> srgb = SkColorSpace::MakeSRGB();
|
||||
sk_sp<SkImage> raw = SkImage::MakeRasterData(dstInfo.makeColorSpace(srgb), data, rowBytes);
|
||||
|
@ -70,8 +70,6 @@ skia_core_sources = [
|
||||
"$_src/core/SkClipStackDevice.h",
|
||||
"$_src/core/SkColor.cpp",
|
||||
"$_src/core/SkColorFilter.cpp",
|
||||
"$_src/core/SkColorLookUpTable.cpp",
|
||||
"$_src/core/SkColorLookUpTable.h",
|
||||
"$_src/core/SkColorMatrixFilterRowMajor255.cpp",
|
||||
"$_src/core/SkColorMatrixFilterRowMajor255.h",
|
||||
"$_src/core/SkColorSpace.cpp",
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Copyright 2016 Google Inc.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
# found in the LICENSE file.
|
||||
|
||||
# Things are easiest for everyone if these source paths are absolute.
|
||||
_gm = get_path_info("../gm", "abspath")
|
||||
@ -144,7 +144,6 @@ gm_sources = [
|
||||
"$_gm/fontscaler.cpp",
|
||||
"$_gm/fontscalerdistortable.cpp",
|
||||
"$_gm/gamma.cpp",
|
||||
"$_gm/gammaencodedpremul.cpp",
|
||||
"$_gm/gammatext.cpp",
|
||||
"$_gm/gamut.cpp",
|
||||
"$_gm/getpostextpath.cpp",
|
||||
|
@ -263,9 +263,6 @@ BASE_SRCS_ALL = struct(
|
||||
# Atlas text
|
||||
"src/atlastext/*",
|
||||
|
||||
# Not time for skcms in Google3 yet.
|
||||
"src/core/SkColorSpaceXform_skcms.cpp",
|
||||
|
||||
# Compute backend not yet even hooked into Skia.
|
||||
"src/compute/**/*",
|
||||
],
|
||||
|
@ -1011,7 +1011,7 @@ SkCodec::Result SkPngCodec::initializeXforms(const SkImageInfo& dstInfo, const O
|
||||
// interlaced scanline decoder may need to rewind.
|
||||
fSwizzler.reset(nullptr);
|
||||
|
||||
// If SkColorSpaceXform directly supports the encoded PNG format, we should skip format
|
||||
// If skcms directly supports the encoded PNG format, we should skip format
|
||||
// conversion in the swizzler (or skip swizzling altogether).
|
||||
bool skipFormatConversion = false;
|
||||
switch (this->getEncodedInfo().color()) {
|
||||
|
@ -1,20 +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 "SkColorLookUpTable.h"
|
||||
#include "SkColorSpaceXformPriv.h"
|
||||
#include "SkFloatingPoint.h"
|
||||
|
||||
SkColorLookUpTable::SkColorLookUpTable(uint8_t inputChannels, const uint8_t limits[]) {
|
||||
fInputChannels = inputChannels;
|
||||
SkASSERT(inputChannels >= 1 && inputChannels <= kMaxColorChannels);
|
||||
memcpy(fLimits, limits, fInputChannels * sizeof(uint8_t));
|
||||
|
||||
for (int i = 0; i < inputChannels; i++) {
|
||||
SkASSERT(fLimits[i] > 1);
|
||||
}
|
||||
}
|
@ -1,48 +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.
|
||||
*/
|
||||
|
||||
#ifndef SkColorLookUpTable_DEFINED
|
||||
#define SkColorLookUpTable_DEFINED
|
||||
|
||||
#include "SkNx.h"
|
||||
#include "SkRefCnt.h"
|
||||
#include "SkTemplates.h"
|
||||
|
||||
// TODO: scope inside SkColorLookUpTable
|
||||
static constexpr uint8_t kMaxColorChannels = 4;
|
||||
|
||||
class SkColorLookUpTable : public SkRefCnt {
|
||||
public:
|
||||
static constexpr uint8_t kOutputChannels = 3;
|
||||
|
||||
SkColorLookUpTable(uint8_t inputChannels, const uint8_t limits[]);
|
||||
|
||||
int inputChannels() const { return fInputChannels; }
|
||||
int outputChannels() const { return kOutputChannels; }
|
||||
|
||||
// TODO: Rename to somethingBetter(int)?
|
||||
int gridPoints(int dimension) const {
|
||||
SkASSERT(dimension >= 0 && dimension < inputChannels());
|
||||
return fLimits[dimension];
|
||||
}
|
||||
|
||||
// Objects of this type are created in a custom fashion using sk_malloc_throw
|
||||
// and therefore must be sk_freed.
|
||||
void* operator new(size_t size) = delete;
|
||||
void* operator new(size_t, void* p) { return p; }
|
||||
void operator delete(void* p) { sk_free(p); }
|
||||
|
||||
const float* table() const {
|
||||
return SkTAddOffset<const float>(this, sizeof(SkColorLookUpTable));
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t fInputChannels;
|
||||
uint8_t fLimits[kMaxColorChannels];
|
||||
};
|
||||
|
||||
#endif
|
@ -6,15 +6,10 @@
|
||||
*/
|
||||
|
||||
#include "SkColorSpaceXform.h"
|
||||
#include "SkColorSpaceXformPriv.h"
|
||||
#include "SkData.h"
|
||||
#include "SkMakeUnique.h"
|
||||
#include "../../third_party/skcms/skcms.h"
|
||||
|
||||
std::unique_ptr<SkColorSpaceXform> SkColorSpaceXform::New(SkColorSpace* src, SkColorSpace* dst) {
|
||||
return SkMakeColorSpaceXform(src, dst);
|
||||
}
|
||||
|
||||
bool SkColorSpaceXform::Apply(SkColorSpace* dstCS, ColorFormat dstFormat, void* dst,
|
||||
SkColorSpace* srcCS, ColorFormat srcFormat, const void* src,
|
||||
int len, AlphaOp op) {
|
||||
@ -92,7 +87,7 @@ void SkColorSpace::toProfile(skcms_ICCProfile* profile) const {
|
||||
skcms_SetXYZD50(profile, &m);
|
||||
}
|
||||
|
||||
std::unique_ptr<SkColorSpaceXform> SkMakeColorSpaceXform(SkColorSpace* src, SkColorSpace* dst) {
|
||||
std::unique_ptr<SkColorSpaceXform> SkColorSpaceXform::New(SkColorSpace* src, SkColorSpace* dst) {
|
||||
if (src && dst && dst->toXYZD50()) {
|
||||
// Construct skcms_ICCProfiles from each color space. For now, support A2B and XYZ.
|
||||
// Eventually, only need to support XYZ.
|
||||
|
@ -1,31 +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.
|
||||
*/
|
||||
|
||||
#ifndef SkColorSpaceXformPriv_DEFINED
|
||||
#define SkColorSpaceXformPriv_DEFINED
|
||||
|
||||
#include "SkColorSpaceXform.h"
|
||||
|
||||
std::unique_ptr<SkColorSpaceXform> SkMakeColorSpaceXform(SkColorSpace* src, SkColorSpace* dst);
|
||||
|
||||
static inline SkColorSpaceXform::ColorFormat select_xform_format(SkColorType colorType) {
|
||||
switch (colorType) {
|
||||
case kRGBA_8888_SkColorType:
|
||||
return SkColorSpaceXform::kRGBA_8888_ColorFormat;
|
||||
case kBGRA_8888_SkColorType:
|
||||
return SkColorSpaceXform::kBGRA_8888_ColorFormat;
|
||||
case kRGBA_F16_SkColorType:
|
||||
return SkColorSpaceXform::kRGBA_F16_ColorFormat;
|
||||
case kRGB_565_SkColorType:
|
||||
return SkColorSpaceXform::kBGR_565_ColorFormat;
|
||||
default:
|
||||
SkASSERT(false);
|
||||
return SkColorSpaceXform::kRGBA_8888_ColorFormat;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SkColorSpaceXform.h"
|
||||
|
||||
// Leaving this file around temporarily until client build files no longer refer to it
|
@ -8,7 +8,6 @@
|
||||
#include "SkColorFilter.h"
|
||||
#include "SkColorSpacePriv.h"
|
||||
#include "SkColorSpaceXformer.h"
|
||||
#include "SkColorSpaceXformPriv.h"
|
||||
#include "SkDrawLooper.h"
|
||||
#include "SkGradientShader.h"
|
||||
#include "SkImage.h"
|
||||
|
@ -19,7 +19,6 @@
|
||||
class SkBitmap;
|
||||
class SkColorFilter;
|
||||
class SkColorSpace;
|
||||
class SkColorSpaceXform;
|
||||
class SkImage;
|
||||
class SkImageFilter;
|
||||
class SkPaint;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "SkArenaAlloc.h"
|
||||
#include "SkAutoBlitterChoose.h"
|
||||
#include "SkComposeShader.h"
|
||||
#include "SkConvertPixels.h"
|
||||
#include "SkDraw.h"
|
||||
#include "SkNx.h"
|
||||
#include "SkPM4f.h"
|
||||
@ -19,7 +20,6 @@
|
||||
|
||||
#include "SkArenaAlloc.h"
|
||||
#include "SkCoreBlitters.h"
|
||||
#include "SkColorSpaceXform.h"
|
||||
|
||||
struct Matrix43 {
|
||||
float fMat[12]; // column major
|
||||
@ -137,18 +137,13 @@ update_tricolor_matrix(const SkMatrix& ctmInv, const SkPoint pts[], const SkPMCo
|
||||
// - apply per-color alpha before interpolation (matches old version of vertices)
|
||||
//
|
||||
static SkPMColor4f* convert_colors(const SkColor src[], int count, SkColorSpace* deviceCS,
|
||||
SkArenaAlloc* alloc) {
|
||||
SkArenaAlloc* alloc) {
|
||||
SkPMColor4f* dst = alloc->makeArray<SkPMColor4f>(count);
|
||||
if (!deviceCS) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
dst[i] = SkColor4f::FromColor(src[i]).premul();
|
||||
}
|
||||
} else {
|
||||
auto srcCS = SkColorSpace::MakeSRGB();
|
||||
SkColorSpaceXform::Apply(deviceCS , SkColorSpaceXform::kRGBA_F32_ColorFormat, dst,
|
||||
srcCS.get(), SkColorSpaceXform::kBGRA_8888_ColorFormat, src,
|
||||
count, SkColorSpaceXform::kPremul_AlphaOp);
|
||||
}
|
||||
SkImageInfo srcInfo = SkImageInfo::Make(count, 1, kBGRA_8888_SkColorType,
|
||||
kUnpremul_SkAlphaType, SkColorSpace::MakeSRGB());
|
||||
SkImageInfo dstInfo = SkImageInfo::Make(count, 1, kRGBA_F32_SkColorType,
|
||||
kPremul_SkAlphaType, sk_ref_sp(deviceCS));
|
||||
SkConvertPixels(dstInfo, dst, 0, srcInfo, src, 0);
|
||||
return dst;
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "SkBitmap.h"
|
||||
#include "SkBitmapProcShader.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorSpaceXformPriv.h"
|
||||
#include "SkColorTable.h"
|
||||
#include "SkConvertPixels.h"
|
||||
#include "SkData.h"
|
||||
|
Loading…
Reference in New Issue
Block a user