Revert "Revert "add explicit src and dst colorspaces to filterColor4f""
This reverts commit 355111bf7c
.
Change-Id: I0aa45bf92f437a0d680aa788ef4dc5c0299c6fe0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/244882
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Mike Reed <reed@google.com>
This commit is contained in:
parent
8ab1530cd3
commit
bd84330ba2
@ -3,6 +3,8 @@ Skia Graphics Release Notes
|
|||||||
This file includes a list of high level updates for each milestone release.
|
This file includes a list of high level updates for each milestone release.
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
* Add explicit src and dst colorspace parameters to SkColorFilter::filterColor4f()
|
||||||
|
|
||||||
* Add SkSurface::MakeFromCAMetalLayer
|
* Add SkSurface::MakeFromCAMetalLayer
|
||||||
|
|
||||||
* Remove isRectContour and ksNestedFillRects from public
|
* Remove isRectContour and ksNestedFillRects from public
|
||||||
|
@ -67,7 +67,13 @@ public:
|
|||||||
virtual uint32_t getFlags() const { return 0; }
|
virtual uint32_t getFlags() const { return 0; }
|
||||||
|
|
||||||
SkColor filterColor(SkColor) const;
|
SkColor filterColor(SkColor) const;
|
||||||
SkColor4f filterColor4f(const SkColor4f&, SkColorSpace*) const;
|
|
||||||
|
/**
|
||||||
|
* Converts the src color (in src colorspace), into the dst colorspace,
|
||||||
|
* then applies this filter to it, returning the filtered color in the dst colorspace.
|
||||||
|
*/
|
||||||
|
SkColor4f filterColor4f(const SkColor4f& srcColor, SkColorSpace* srcCS,
|
||||||
|
SkColorSpace* dstCS) const;
|
||||||
|
|
||||||
/** Construct a colorfilter whose effect is to first apply the inner filter and then apply
|
/** Construct a colorfilter whose effect is to first apply the inner filter and then apply
|
||||||
* this filter, applied to the output of the inner filter.
|
* this filter, applied to the output of the inner filter.
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "include/private/SkTo.h"
|
#include "include/private/SkTo.h"
|
||||||
#include "src/core/SkAntiRun.h"
|
#include "src/core/SkAntiRun.h"
|
||||||
#include "src/core/SkArenaAlloc.h"
|
#include "src/core/SkArenaAlloc.h"
|
||||||
|
#include "src/core/SkColorSpacePriv.h"
|
||||||
#include "src/core/SkMask.h"
|
#include "src/core/SkMask.h"
|
||||||
#include "src/core/SkMaskFilterBase.h"
|
#include "src/core/SkMaskFilterBase.h"
|
||||||
#include "src/core/SkPaintPriv.h"
|
#include "src/core/SkPaintPriv.h"
|
||||||
@ -718,6 +719,17 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device,
|
|||||||
p->setColor(0x00000000);
|
p->setColor(0x00000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef SK_SUPPORT_LEGACY_COLORFILTER_NO_SHADER
|
||||||
|
if (paint->getColorFilter() && !paint->getShader()) {
|
||||||
|
// apply the filter to the paint's color, and then remove the filter
|
||||||
|
auto dstCS = device.colorSpace();
|
||||||
|
SkPaint* p = paint.writable();
|
||||||
|
p->setColor(p->getColorFilter()->filterColor4f(p->getColor4f(), sk_srgb_singleton(), dstCS),
|
||||||
|
dstCS);
|
||||||
|
p->setColorFilter(nullptr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (drawCoverage) {
|
if (drawCoverage) {
|
||||||
if (device.colorType() == kAlpha_8_SkColorType) {
|
if (device.colorType() == kAlpha_8_SkColorType) {
|
||||||
SkASSERT(!paint->getShader());
|
SkASSERT(!paint->getShader());
|
||||||
|
@ -44,30 +44,39 @@ bool SkColorFilter::appendStages(const SkStageRec& rec, bool shaderIsOpaque) con
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkColor SkColorFilter::filterColor(SkColor c) const {
|
SkColor SkColorFilter::filterColor(SkColor c) const {
|
||||||
return this->filterColor4f(SkColor4f::FromColor(c), nullptr)
|
#ifdef SK_SUPPORT_LEGACY_COLORFILTER_NO_SHADER
|
||||||
.toSkColor();
|
SkColorSpace* cs = nullptr;
|
||||||
|
#else
|
||||||
|
SkColorSpace* cs = sk_srgb_singleton();
|
||||||
|
#endif
|
||||||
|
return this->filterColor4f(SkColor4f::FromColor(c), cs, cs).toSkColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "src/core/SkRasterPipeline.h"
|
SkColor4f SkColorFilter::filterColor4f(const SkColor4f& origSrcColor, SkColorSpace* srcCS,
|
||||||
SkColor4f SkColorFilter::filterColor4f(const SkColor4f& c, SkColorSpace* colorSpace) const {
|
SkColorSpace* dstCS) const {
|
||||||
SkPMColor4f dst, src = c.premul();
|
#ifdef SK_SUPPORT_LEGACY_COLORFILTER_NO_SHADER
|
||||||
|
SkPMColor4f src = origSrcColor.premul();
|
||||||
|
SkColor4f color = *(SkColor4f*)&src;
|
||||||
|
#else
|
||||||
|
SkColor4f color = origSrcColor;
|
||||||
|
SkColorSpaceXformSteps(srcCS, kUnpremul_SkAlphaType,
|
||||||
|
dstCS, kPremul_SkAlphaType).apply(color.vec());
|
||||||
|
#endif
|
||||||
|
|
||||||
// determined experimentally, seems to cover compose+colormatrix
|
constexpr size_t kEnoughForCommonFilters = 512; // big enough for compose+colormatrix
|
||||||
constexpr size_t kEnoughForCommonFilters = 512;
|
|
||||||
SkSTArenaAlloc<kEnoughForCommonFilters> alloc;
|
SkSTArenaAlloc<kEnoughForCommonFilters> alloc;
|
||||||
SkRasterPipeline pipeline(&alloc);
|
SkRasterPipeline pipeline(&alloc);
|
||||||
|
pipeline.append_constant_color(&alloc, color.vec());
|
||||||
pipeline.append_constant_color(&alloc, src.vec());
|
|
||||||
|
|
||||||
SkPaint dummyPaint;
|
SkPaint dummyPaint;
|
||||||
SkStageRec rec = {
|
SkStageRec rec = {
|
||||||
&pipeline, &alloc, kRGBA_F32_SkColorType, colorSpace, dummyPaint, nullptr, SkMatrix::I()
|
&pipeline, &alloc, kRGBA_F32_SkColorType, dstCS, dummyPaint, nullptr, SkMatrix::I()
|
||||||
};
|
};
|
||||||
this->onAppendStages(rec, c.fA == 1);
|
this->onAppendStages(rec, color.fA == 1);
|
||||||
|
|
||||||
|
SkPMColor4f dst;
|
||||||
SkRasterPipeline_MemoryCtx dstPtr = { &dst, 0 };
|
SkRasterPipeline_MemoryCtx dstPtr = { &dst, 0 };
|
||||||
pipeline.append(SkRasterPipeline::store_f32, &dstPtr);
|
pipeline.append(SkRasterPipeline::store_f32, &dstPtr);
|
||||||
pipeline.run(0,0, 1,1);
|
pipeline.run(0,0, 1,1);
|
||||||
|
|
||||||
return dst.unpremul();
|
return dst.unpremul();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include "src/core/SkDistanceFieldGen.h"
|
#include "src/core/SkDistanceFieldGen.h"
|
||||||
#include "src/core/SkDraw.h"
|
#include "src/core/SkDraw.h"
|
||||||
#include "src/core/SkFontPriv.h"
|
#include "src/core/SkFontPriv.h"
|
||||||
#include "src/core/SkPaintPriv.h"
|
|
||||||
#include "src/core/SkRasterClip.h"
|
#include "src/core/SkRasterClip.h"
|
||||||
#include "src/core/SkStrike.h"
|
#include "src/core/SkStrike.h"
|
||||||
#include "src/core/SkStrikeCache.h"
|
#include "src/core/SkStrikeCache.h"
|
||||||
@ -589,6 +588,7 @@ SkPMColor4f generate_filtered_color(const SkPaint& paint, const GrColorSpaceInfo
|
|||||||
}
|
}
|
||||||
if (paint.getColorFilter() != nullptr) {
|
if (paint.getColorFilter() != nullptr) {
|
||||||
filteredColor = paint.getColorFilter()->filterColor4f(filteredColor,
|
filteredColor = paint.getColorFilter()->filterColor4f(filteredColor,
|
||||||
|
colorSpaceInfo.colorSpace(),
|
||||||
colorSpaceInfo.colorSpace());
|
colorSpaceInfo.colorSpace());
|
||||||
}
|
}
|
||||||
return filteredColor.premul();
|
return filteredColor.premul();
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "include/private/SkTemplates.h"
|
#include "include/private/SkTemplates.h"
|
||||||
#include "src/core/SkAutoMalloc.h"
|
#include "src/core/SkAutoMalloc.h"
|
||||||
#include "src/core/SkBlendModePriv.h"
|
#include "src/core/SkBlendModePriv.h"
|
||||||
|
#include "src/core/SkColorSpacePriv.h"
|
||||||
#include "src/core/SkImagePriv.h"
|
#include "src/core/SkImagePriv.h"
|
||||||
#include "src/core/SkMaskFilterBase.h"
|
#include "src/core/SkMaskFilterBase.h"
|
||||||
#include "src/core/SkMessageBus.h"
|
#include "src/core/SkMessageBus.h"
|
||||||
@ -427,8 +428,8 @@ static inline bool skpaint_to_grpaint_impl(GrRecordingContext* context,
|
|||||||
SkColorFilter* colorFilter = skPaint.getColorFilter();
|
SkColorFilter* colorFilter = skPaint.getColorFilter();
|
||||||
if (colorFilter) {
|
if (colorFilter) {
|
||||||
if (applyColorFilterToPaintColor) {
|
if (applyColorFilterToPaintColor) {
|
||||||
grPaint->setColor4f(
|
SkColorSpace* dstCS = colorSpaceInfo.colorSpace();
|
||||||
colorFilter->filterColor4f(origColor, colorSpaceInfo.colorSpace()).premul());
|
grPaint->setColor4f(colorFilter->filterColor4f(origColor, dstCS, dstCS).premul());
|
||||||
} else {
|
} else {
|
||||||
auto cfFP = colorFilter->asFragmentProcessor(context, colorSpaceInfo);
|
auto cfFP = colorFilter->asFragmentProcessor(context, colorSpaceInfo);
|
||||||
if (cfFP) {
|
if (cfFP) {
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "src/core/SkAnnotationKeys.h"
|
#include "src/core/SkAnnotationKeys.h"
|
||||||
#include "src/core/SkBitmapDevice.h"
|
#include "src/core/SkBitmapDevice.h"
|
||||||
#include "src/core/SkClipOpPriv.h"
|
#include "src/core/SkClipOpPriv.h"
|
||||||
|
#include "src/core/SkColorSpacePriv.h"
|
||||||
#include "src/core/SkDraw.h"
|
#include "src/core/SkDraw.h"
|
||||||
#include "src/core/SkGlyphRun.h"
|
#include "src/core/SkGlyphRun.h"
|
||||||
#include "src/core/SkImageFilterCache.h"
|
#include "src/core/SkImageFilterCache.h"
|
||||||
@ -163,7 +164,9 @@ static SkTCopyOnFirstWrite<SkPaint> clean_paint(const SkPaint& srcPaint) {
|
|||||||
if (SkShader* shader = paint->getShader()) {
|
if (SkShader* shader = paint->getShader()) {
|
||||||
p->setShader(shader->makeWithColorFilter(paint->refColorFilter()));
|
p->setShader(shader->makeWithColorFilter(paint->refColorFilter()));
|
||||||
} else {
|
} else {
|
||||||
p->setColor4f(cf->filterColor4f(paint->getColor4f(), nullptr), nullptr);
|
SkColorSpace* dstCS = sk_srgb_singleton(); // don't know PDF's space, so use srgb
|
||||||
|
SkColor4f newColor = cf->filterColor4f(p->getColor4f(), sk_srgb_singleton(), dstCS);
|
||||||
|
p->setColor4f(newColor, dstCS);
|
||||||
}
|
}
|
||||||
p->setColorFilter(nullptr);
|
p->setColorFilter(nullptr);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user