Rename GrColorSpaceInfo -> GrColorInfo

Add version SkImageInfo::Make() that takes SkISize instead of separate
width and height.

Change-Id: I42aa79d23b19e22f5405631728c245b04bce0559
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/245172
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Salomon 2019-09-30 15:12:27 -04:00 committed by Skia Commit-Bot
parent d5a9422f32
commit 4bc0c1fc4b
83 changed files with 391 additions and 417 deletions

View File

@ -35,7 +35,7 @@ protected:
SkISize size = canvas->getBaseLayerSize();
auto info = SkImageInfo::Make(size.width(), size.height(), fCT, fAT, fCS);
auto info = SkImageInfo::Make(size, fCT, fAT, fCS);
SkBitmap bitmap;
bitmap.allocPixels(info);

View File

@ -35,8 +35,7 @@ protected:
void onDraw(int loops, SkCanvas* canvas) override {
SkISize size = canvas->getBaseLayerSize();
SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), fColorType, fAlphaType,
fCS);
SkImageInfo info = SkImageInfo::Make(size, fColorType, fAlphaType, fCS);
SkBitmap bmp;
bmp.allocPixels(info);
bmp.eraseColor(SK_ColorBLACK);

View File

@ -1367,8 +1367,7 @@ Error GPUSink::onDraw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log,
GrContextFactory factory(grOptions);
const SkISize size = src.size();
SkImageInfo info =
SkImageInfo::Make(size.width(), size.height(), fColorType, fAlphaType, fColorSpace);
SkImageInfo info = SkImageInfo::Make(size, fColorType, fAlphaType, fColorSpace);
sk_sp<SkSurface> surface;
GrContext* context = factory.getContextInfo(fContextType, fContextOverrides).grContext();
if (initContext) {
@ -1427,8 +1426,7 @@ Error GPUSink::onDraw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log,
info.colorType() == kRGB_888x_SkColorType) {
// We don't currently support readbacks into these formats on the GPU backend. Convert to
// 32 bit.
info = SkImageInfo::Make(size.width(), size.height(), kRGBA_8888_SkColorType,
kPremul_SkAlphaType, fColorSpace);
info = SkImageInfo::Make(size, kRGBA_8888_SkColorType, kPremul_SkAlphaType, fColorSpace);
}
dst->allocPixels(info);
canvas->readPixels(*dst, 0, 0);
@ -1729,8 +1727,7 @@ Error RasterSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString*) con
SkAlphaType alphaType = kPremul_SkAlphaType;
(void)SkColorTypeValidateAlphaType(fColorType, alphaType, &alphaType);
dst->allocPixelsFlags(SkImageInfo::Make(size.width(), size.height(),
fColorType, alphaType, fColorSpace),
dst->allocPixelsFlags(SkImageInfo::Make(size, fColorType, alphaType, fColorSpace),
SkBitmap::kZeroPixels_AllocFlag);
SkCanvas canvas(*dst);

View File

@ -234,7 +234,7 @@ bool SkVideoEncoder::beginRecording(SkISize dim, int fps) {
// need opaque and bgra to efficiently use libyuv / convert-to-yuv-420
SkAlphaType alphaType = kOpaque_SkAlphaType;
sk_sp<SkColorSpace> cs = nullptr; // should we use this?
fInfo = SkImageInfo::Make(dim.width(), dim.height(), kRGBA_8888_SkColorType, alphaType, cs);
fInfo = SkImageInfo::Make(dim, kRGBA_8888_SkColorType, alphaType, cs);
if (!this->init(fps)) {
return false;
}

View File

@ -1666,7 +1666,7 @@ static void fuzz_ganesh(Fuzz* fuzz, GrContext* context) {
auto surface = SkSurface::MakeRenderTarget(
context,
SkBudgeted::kNo,
SkImageInfo::Make(kCanvasSize.width(), kCanvasSize.height(), kRGBA_8888_SkColorType, kPremul_SkAlphaType));
SkImageInfo::Make(kCanvasSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType));
SkASSERT(surface && surface->getCanvas());
fuzz_canvas(fuzz, surface->getCanvas());
}

View File

@ -189,7 +189,7 @@ void ClockwiseGM::onDraw(GrContext* ctx, GrRenderTargetContext* rtc, SkCanvas* c
// Draw the test to an off-screen, top-down render target.
if (auto topLeftRTC = ctx->priv().makeDeferredRenderTargetContext(
SkBackingFit::kExact, 100, 200, rtc->colorSpaceInfo().colorType(), nullptr, 1,
SkBackingFit::kExact, 100, 200, rtc->colorInfo().colorType(), nullptr, 1,
GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes)) {
topLeftRTC->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
@ -205,7 +205,7 @@ void ClockwiseGM::onDraw(GrContext* ctx, GrRenderTargetContext* rtc, SkCanvas* c
// Draw the test to an off-screen, bottom-up render target.
if (auto topLeftRTC = ctx->priv().makeDeferredRenderTargetContext(
SkBackingFit::kExact, 100, 200, rtc->colorSpaceInfo().colorType(), nullptr, 1,
SkBackingFit::kExact, 100, 200, rtc->colorInfo().colorType(), nullptr, 1,
GrMipMapped::kNo, kBottomLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes)) {
topLeftRTC->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);

View File

@ -112,7 +112,7 @@ protected:
} else {
skPaint.setColor(kPaintColors[paintType]);
}
SkAssertResult(SkPaintToGrPaint(context, renderTargetContext->colorSpaceInfo(),
SkAssertResult(SkPaintToGrPaint(context, renderTargetContext->colorInfo(),
skPaint, viewMatrix, &grPaint));
GrConstColorProcessor::InputMode mode = (GrConstColorProcessor::InputMode) m;

View File

@ -82,7 +82,7 @@ static void draw_gradient_tiles(SkCanvas* canvas, bool alignGradients) {
// Use non-public API to leverage general GrPaint capabilities
SkMatrix view = canvas->getTotalMatrix();
GrPaint grPaint;
SkPaintToGrPaint(context, rtc->colorSpaceInfo(), paint, view, &grPaint);
SkPaintToGrPaint(context, rtc->colorInfo(), paint, view, &grPaint);
rtc->fillRectWithEdgeAA(GrNoClip(), std::move(grPaint), GrAA::kYes,
static_cast<GrQuadAAFlags>(aa), view, tile);
} else {

View File

@ -266,7 +266,7 @@ DrawResult SampleLocationsGM::onDraw(
}
auto offscreenRTC = ctx->priv().makeDeferredRenderTargetContext(
SkBackingFit::kExact, 200, 200, rtc->colorSpaceInfo().colorType(), nullptr,
SkBackingFit::kExact, 200, 200, rtc->colorInfo().colorType(), nullptr,
rtc->numSamples(), GrMipMapped::kNo, fOrigin);
if (!offscreenRTC) {
*errorMsg = "Failed to create offscreen render target.";

View File

@ -503,20 +503,20 @@ static void extract_planes(const SkBitmap& bm, SkYUVColorSpace yuvColorSpace, Pl
SkASSERT(!(bm.width() % 2));
SkASSERT(!(bm.height() % 2));
planes->fYFull.allocPixels(SkImageInfo::Make(bm.width(), bm.height(), kGray_8_SkColorType,
kUnpremul_SkAlphaType));
planes->fUFull.allocPixels(SkImageInfo::Make(bm.width(), bm.height(), kGray_8_SkColorType,
kUnpremul_SkAlphaType));
planes->fVFull.allocPixels(SkImageInfo::Make(bm.width(), bm.height(), kGray_8_SkColorType,
kUnpremul_SkAlphaType));
planes->fYFull.allocPixels(
SkImageInfo::Make(bm.dimensions(), kGray_8_SkColorType, kUnpremul_SkAlphaType));
planes->fUFull.allocPixels(
SkImageInfo::Make(bm.dimensions(), kGray_8_SkColorType, kUnpremul_SkAlphaType));
planes->fVFull.allocPixels(
SkImageInfo::Make(bm.dimensions(), kGray_8_SkColorType, kUnpremul_SkAlphaType));
planes->fAFull.allocPixels(SkImageInfo::MakeA8(bm.width(), bm.height()));
planes->fUQuarter.allocPixels(SkImageInfo::Make(bm.width()/2, bm.height()/2,
kGray_8_SkColorType, kUnpremul_SkAlphaType));
planes->fVQuarter.allocPixels(SkImageInfo::Make(bm.width()/2, bm.height()/2,
kGray_8_SkColorType, kUnpremul_SkAlphaType));
planes->fFull.allocPixels(SkImageInfo::Make(bm.width(), bm.height(),
kRGBA_F32_SkColorType, kUnpremul_SkAlphaType));
planes->fFull.allocPixels(
SkImageInfo::Make(bm.dimensions(), kRGBA_F32_SkColorType, kUnpremul_SkAlphaType));
planes->fQuarter.allocPixels(SkImageInfo::Make(bm.width()/2, bm.height()/2,
kRGBA_F32_SkColorType, kUnpremul_SkAlphaType));
@ -625,8 +625,7 @@ static SkBitmap make_16(const SkBitmap& src, SkColorType dstCT,
SkBitmap result;
result.allocPixels(SkImageInfo::Make(src.width(), src.height(), dstCT,
kUnpremul_SkAlphaType));
result.allocPixels(SkImageInfo::Make(src.dimensions(), dstCT, kUnpremul_SkAlphaType));
for (int y = 0; y < src.height(); ++y) {
for (int x = 0; x < src.width(); ++x) {

View File

@ -64,7 +64,8 @@ skia_gpu_sources = [
"$_src/gpu/GrClipStackClip.h",
"$_src/gpu/GrClipStackClip.cpp",
"$_src/gpu/GrColor.h",
"$_src/gpu/GrColorSpaceInfo.cpp",
"$_src/gpu/GrColorInfo.cpp",
"$_src/gpu/GrColorInfo.h",
"$_src/gpu/GrColorSpaceXform.cpp",
"$_src/gpu/GrColorSpaceXform.h",
"$_src/gpu/GrContext.cpp",

View File

@ -13,7 +13,7 @@
#include "include/core/SkFlattenable.h"
#include "include/core/SkRefCnt.h"
class GrColorSpaceInfo;
class GrColorInfo;
class GrFragmentProcessor;
class GrRecordingContext;
class SkBitmap;
@ -96,7 +96,7 @@ public:
* A null return indicates that the color filter isn't implemented for the GPU backend.
*/
virtual std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(
GrRecordingContext*, const GrColorSpaceInfo& dstColorSpaceInfo) const;
GrRecordingContext*, const GrColorInfo& dstColorInfo) const;
#endif
bool affectsTransparentBlack() const {

View File

@ -235,7 +235,11 @@ public:
*/
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at,
sk_sp<SkColorSpace> cs = nullptr) {
return SkImageInfo(width, height, ct, at, std::move(cs));
return SkImageInfo({width, height}, ct, at, std::move(cs));
}
static SkImageInfo Make(SkISize dimensions, SkColorType ct, SkAlphaType at,
sk_sp<SkColorSpace> cs = nullptr) {
return SkImageInfo(dimensions, ct, at, std::move(cs));
}
/** Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType,
@ -258,7 +262,7 @@ public:
*/
static SkImageInfo MakeN32(int width, int height, SkAlphaType at,
sk_sp<SkColorSpace> cs = nullptr) {
return Make(width, height, kN32_SkColorType, at, std::move(cs));
return Make({width, height}, kN32_SkColorType, at, std::move(cs));
}
/** Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType,
@ -291,7 +295,7 @@ public:
@return created SkImageInfo
*/
static SkImageInfo MakeN32Premul(int width, int height, sk_sp<SkColorSpace> cs = nullptr) {
return Make(width, height, kN32_SkColorType, kPremul_SkAlphaType, std::move(cs));
return Make({width, height}, kN32_SkColorType, kPremul_SkAlphaType, std::move(cs));
}
/** Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType,
@ -318,7 +322,7 @@ public:
@return created SkImageInfo
*/
static SkImageInfo MakeA8(int width, int height) {
return Make(width, height, kAlpha_8_SkColorType, kPremul_SkAlphaType, nullptr);
return Make({width, height}, kAlpha_8_SkColorType, kPremul_SkAlphaType, nullptr);
}
/** Creates SkImageInfo from integral dimensions width and height, kUnknown_SkColorType,
@ -332,7 +336,7 @@ public:
@return created SkImageInfo
*/
static SkImageInfo MakeUnknown(int width, int height) {
return Make(width, height, kUnknown_SkColorType, kUnknown_SkAlphaType, nullptr);
return Make({width, height}, kUnknown_SkColorType, kUnknown_SkAlphaType, nullptr);
}
/** Creates SkImageInfo from integral dimensions width and height set to zero,
@ -619,9 +623,9 @@ private:
SkColorType fColorType;
SkAlphaType fAlphaType;
SkImageInfo(int width, int height, SkColorType ct, SkAlphaType at, sk_sp<SkColorSpace> cs)
SkImageInfo(SkISize dimensions, SkColorType ct, SkAlphaType at, sk_sp<SkColorSpace> cs)
: fColorSpace(std::move(cs))
, fDimensions{width, height}
, fDimensions(dimensions)
, fColorType(ct)
, fAlphaType(at)
{}

View File

@ -38,8 +38,8 @@ public:
static sk_sp<SkColorFilter> Make();
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(
GrRecordingContext*, const GrColorSpaceInfo&) const override;
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(GrRecordingContext*,
const GrColorInfo&) const override;
#endif
protected:

View File

@ -28,8 +28,8 @@ public:
}
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(
GrRecordingContext*, const GrColorSpaceInfo&) const override;
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(GrRecordingContext*,
const GrColorInfo&) const override;
#endif
static void RegisterFlattenables();

View File

@ -50,8 +50,8 @@ bool SkBitmapRegionCodec::decodeRegion(SkBitmap* bitmap, SkBRDAllocator* allocat
// Create the image info for the decode
SkAlphaType dstAlphaType = fCodec->computeOutputAlphaType(requireUnpremul);
SkImageInfo decodeInfo = SkImageInfo::Make(scaledSize.width(), scaledSize.height(),
dstColorType, dstAlphaType, dstColorSpace);
SkImageInfo decodeInfo =
SkImageInfo::Make(scaledSize, dstColorType, dstAlphaType, dstColorSpace);
// Initialize the destination bitmap
int scaledOutX = 0;

View File

@ -73,8 +73,7 @@ void SkAtlasTextTarget::concat(const SkMatrix& matrix) { this->accessCTM()->preC
//////////////////////////////////////////////////////////////////////////////
static const GrColorSpaceInfo kColorSpaceInfo(GrColorType::kRGBA_8888, kPremul_SkAlphaType,
nullptr);
static const GrColorInfo kColorInfo(GrColorType::kRGBA_8888, kPremul_SkAlphaType, nullptr);
static const SkSurfaceProps kProps(
SkSurfaceProps::kUseDistanceFieldFonts_Flag, kUnknown_SkPixelGeometry);
@ -82,12 +81,11 @@ static const SkSurfaceProps kProps(
class SkInternalAtlasTextTarget : public GrTextTarget, public SkAtlasTextTarget {
public:
SkInternalAtlasTextTarget(sk_sp<SkAtlasTextContext> context,
int width, int height,
SkInternalAtlasTextTarget(sk_sp<SkAtlasTextContext> context, int width, int height,
void* handle)
: GrTextTarget(width, height, kColorSpaceInfo)
: GrTextTarget(width, height, kColorInfo)
, SkAtlasTextTarget(std::move(context), width, height, handle)
, fGlyphPainter(kProps, kColorSpaceInfo) {
, fGlyphPainter(kProps, kColorInfo) {
fOpMemoryPool = fContext->internal().grContext()->priv().refOpMemoryPool();
}

View File

@ -284,8 +284,8 @@ SkBitmapDevice* SkBitmapDevice::Create(const SkImageInfo& origInfo,
SkBitmap coverage;
if (trackCoverage) {
SkImageInfo ci = SkImageInfo::Make(info.width(), info.height(), kAlpha_8_SkColorType,
kPremul_SkAlphaType);
SkImageInfo ci =
SkImageInfo::Make(info.dimensions(), kAlpha_8_SkColorType, kPremul_SkAlphaType);
if (!coverage.tryAllocPixelsFlags(ci, SkBitmap::kZeroPixels_AllocFlag)) {
return nullptr;
}

View File

@ -33,8 +33,8 @@ bool SkColorFilter::onAsAColorMatrix(float matrix[20]) const {
}
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> SkColorFilter::asFragmentProcessor(
GrRecordingContext*, const GrColorSpaceInfo&) const {
std::unique_ptr<GrFragmentProcessor> SkColorFilter::asFragmentProcessor(GrRecordingContext*,
const GrColorInfo&) const {
return nullptr;
}
#endif
@ -110,9 +110,9 @@ public:
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(
GrRecordingContext* context, const GrColorSpaceInfo& dstColorSpaceInfo) const override {
auto innerFP = fInner->asFragmentProcessor(context, dstColorSpaceInfo);
auto outerFP = fOuter->asFragmentProcessor(context, dstColorSpaceInfo);
GrRecordingContext* context, const GrColorInfo& dstColorInfo) const override {
auto innerFP = fInner->asFragmentProcessor(context, dstColorInfo);
auto outerFP = fOuter->asFragmentProcessor(context, dstColorInfo);
if (!innerFP || !outerFP) {
return nullptr;
}
@ -196,8 +196,8 @@ public:
}()) {}
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(
GrRecordingContext*, const GrColorSpaceInfo&) const override {
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(GrRecordingContext*,
const GrColorInfo&) const override {
// wish our caller would let us know if our input was opaque...
GrSRGBEffect::Alpha alpha = GrSRGBEffect::Alpha::kPremul;
switch (fDir) {
@ -310,10 +310,10 @@ public:
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(
GrRecordingContext* context, const GrColorSpaceInfo& dstColorSpaceInfo) const override {
GrRecordingContext* context, const GrColorInfo& dstColorInfo) const override {
return GrMixerEffect::Make(
fCF0->asFragmentProcessor(context, dstColorSpaceInfo),
fCF1 ? fCF1->asFragmentProcessor(context, dstColorSpaceInfo) : nullptr,
fCF0->asFragmentProcessor(context, dstColorInfo),
fCF1 ? fCF1->asFragmentProcessor(context, dstColorInfo) : nullptr,
fWeight);
}
#endif
@ -388,8 +388,8 @@ public:
, fCpuFunction(cpuFunction) {}
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(
GrRecordingContext* context, const GrColorSpaceInfo&) const override {
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(GrRecordingContext* context,
const GrColorInfo&) const override {
return GrSkSLFP::Make(context, fIndex, "Runtime Color Filter", fSkSL,
fInputs ? fInputs->data() : nullptr,
fInputs ? fInputs->size() : 0);

View File

@ -82,7 +82,7 @@ bool SkColorFilter_Matrix::onAppendStages(const SkStageRec& rec, bool shaderIsOp
#if SK_SUPPORT_GPU
#include "src/gpu/effects/generated/GrColorMatrixFragmentProcessor.h"
std::unique_ptr<GrFragmentProcessor> SkColorFilter_Matrix::asFragmentProcessor(
GrRecordingContext*, const GrColorSpaceInfo&) const {
GrRecordingContext*, const GrColorInfo&) const {
if (fDomain == Domain::kHSLA) {
// TODO
return nullptr;

View File

@ -20,8 +20,8 @@ public:
uint32_t getFlags() const override;
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(
GrRecordingContext*, const GrColorSpaceInfo&) const override;
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(GrRecordingContext*,
const GrColorInfo&) const override;
#endif
static void RegisterFlattenables();

View File

@ -381,9 +381,9 @@ class SkNoPixelsDevice : public SkBaseDevice {
public:
SkNoPixelsDevice(const SkIRect& bounds, const SkSurfaceProps& props,
sk_sp<SkColorSpace> colorSpace = nullptr)
: SkBaseDevice(SkImageInfo::Make(bounds.width(), bounds.height(), kUnknown_SkColorType,
kUnknown_SkAlphaType, std::move(colorSpace)), props)
{
: SkBaseDevice(SkImageInfo::Make(bounds.size(), kUnknown_SkColorType,
kUnknown_SkAlphaType, std::move(colorSpace)),
props) {
// this fails if we enable this assert: DiscardableImageMapTest.GetDiscardableImagesInRectMaxImage
//SkASSERT(bounds.width() >= 0 && bounds.height() >= 0);

View File

@ -10,7 +10,7 @@
#if SK_SUPPORT_GPU
#include "include/private/GrRecordingContext.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrColorSpaceInfo.h"
#include "src/gpu/GrColorInfo.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrRenderTargetContext.h"
@ -85,15 +85,14 @@ SkGlyphRunListPainter::SkGlyphRunListPainter(const SkSurfaceProps& props,
: SkGlyphRunListPainter(props, colorType, compute_scaler_context_flags(cs), strikeCache) {}
#if SK_SUPPORT_GPU
SkGlyphRunListPainter::SkGlyphRunListPainter(const SkSurfaceProps& props,
const GrColorSpaceInfo& csi)
SkGlyphRunListPainter::SkGlyphRunListPainter(const SkSurfaceProps& props, const GrColorInfo& csi)
: SkGlyphRunListPainter(props,
kUnknown_SkColorType,
compute_scaler_context_flags(csi.colorSpace()),
SkStrikeCache::GlobalStrikeCache()) {}
SkGlyphRunListPainter::SkGlyphRunListPainter(const GrRenderTargetContext& rtc)
: SkGlyphRunListPainter{rtc.surfaceProps(), rtc.colorSpaceInfo()} {}
: SkGlyphRunListPainter{rtc.surfaceProps(), rtc.colorInfo()} {}
#endif
@ -581,15 +580,14 @@ SkGlyphRunListPainter::ensureBuffers(const SkGlyphRun& glyphRun) {
#if SK_SUPPORT_GPU
// -- GrTextContext --------------------------------------------------------------------------------
SkPMColor4f generate_filtered_color(const SkPaint& paint, const GrColorSpaceInfo& colorSpaceInfo) {
SkPMColor4f generate_filtered_color(const SkPaint& paint, const GrColorInfo& colorInfo) {
SkColor4f filteredColor = paint.getColor4f();
if (auto* xform = colorSpaceInfo.colorSpaceXformFromSRGB()) {
if (auto* xform = colorInfo.colorSpaceXformFromSRGB()) {
filteredColor = xform->apply(filteredColor);
}
if (paint.getColorFilter() != nullptr) {
filteredColor = paint.getColorFilter()->filterColor4f(filteredColor,
colorSpaceInfo.colorSpace(),
colorSpaceInfo.colorSpace());
filteredColor = paint.getColorFilter()->filterColor4f(filteredColor, colorInfo.colorSpace(),
colorInfo.colorSpace());
}
return filteredColor.premul();
}
@ -603,8 +601,8 @@ void GrTextContext::drawGlyphRunList(
// Get the first paint to use as the key paint.
const SkPaint& listPaint = glyphRunList.paint();
SkPMColor4f filteredColor = generate_filtered_color(listPaint, target->colorSpaceInfo());
GrColor color = generate_filtered_color(listPaint, target->colorSpaceInfo()).toBytes_RGBA();
SkPMColor4f filteredColor = generate_filtered_color(listPaint, target->colorInfo());
GrColor color = generate_filtered_color(listPaint, target->colorInfo()).toBytes_RGBA();
// If we have been abandoned, then don't draw
if (context->priv().abandoned()) {
@ -617,7 +615,7 @@ void GrTextContext::drawGlyphRunList(
const SkMaskFilter* mf = listPaint.getMaskFilter();
bool canCache = glyphRunList.canCache() && !(listPaint.getPathEffect() ||
(mf && !as_MFB(mf)->asABlur(&blurRec)));
SkScalerContextFlags scalerContextFlags = ComputeScalerContextFlags(target->colorSpaceInfo());
SkScalerContextFlags scalerContextFlags = ComputeScalerContextFlags(target->colorInfo());
auto grStrikeCache = context->priv().getGrStrikeCache();
GrTextBlobCache* textBlobCache = context->priv().getTextBlobCache();
@ -926,7 +924,7 @@ std::unique_ptr<GrDrawOp> GrTextContext::createOp_TestingOnly(GrRecordingContext
size_t textLen = (int)strlen(text);
SkPMColor4f filteredColor = generate_filtered_color(skPaint, rtc->colorSpaceInfo());
SkPMColor4f filteredColor = generate_filtered_color(skPaint, rtc->colorInfo());
GrColor color = filteredColor.toBytes_RGBA();
auto origin = SkPoint::Make(x, y);
@ -938,8 +936,7 @@ std::unique_ptr<GrDrawOp> GrTextContext::createOp_TestingOnly(GrRecordingContext
if (!glyphRunList.empty()) {
blob = direct->priv().getTextBlobCache()->makeBlob(glyphRunList, color, strikeCache);
// Use the text and textLen below, because we don't want to mess with the paint.
SkScalerContextFlags scalerContextFlags =
ComputeScalerContextFlags(rtc->colorSpaceInfo());
SkScalerContextFlags scalerContextFlags = ComputeScalerContextFlags(rtc->colorInfo());
blob->generateFromGlyphRunList(
*context->priv().caps()->shaderCaps(), textContext->fOptions,
skPaint, scalerContextFlags, viewMatrix, surfaceProps,

View File

@ -16,7 +16,7 @@
#if SK_SUPPORT_GPU
#include "src/gpu/text/GrTextContext.h"
class GrColorSpaceInfo;
class GrColorInfo;
class GrRenderTargetContext;
#endif
@ -43,7 +43,7 @@ public:
#if SK_SUPPORT_GPU
// The following two ctors are used exclusively by the GPU, and will always use the global
// strike cache.
SkGlyphRunListPainter(const SkSurfaceProps&, const GrColorSpaceInfo&);
SkGlyphRunListPainter(const SkSurfaceProps&, const GrColorInfo&);
explicit SkGlyphRunListPainter(const GrRenderTargetContext& renderTargetContext);
#endif // SK_SUPPORT_GPU

View File

@ -387,7 +387,7 @@ static std::unique_ptr<GrRenderTargetContext> reexpand(
return nullptr;
}
GrColorType srcColorType = srcRenderTargetContext->colorSpaceInfo().colorType();
GrColorType srcColorType = srcRenderTargetContext->colorInfo().colorType();
srcRenderTargetContext = nullptr; // no longer needed

View File

@ -462,9 +462,8 @@ sk_sp<SkSpecialImage> SkImageFilter_Base::DrawWithFP(GrRecordingContext* context
return SkSpecialImage::MakeDeferredFromGpu(
context, dstIRect, kNeedNewImageUniqueID_SpecialImage,
renderTargetContext->asTextureProxyRef(),
renderTargetContext->colorSpaceInfo().colorType(),
renderTargetContext->colorSpaceInfo().refColorSpace());
renderTargetContext->asTextureProxyRef(), renderTargetContext->colorInfo().colorType(),
renderTargetContext->colorInfo().refColorSpace());
}
sk_sp<SkSpecialImage> SkImageFilter_Base::ImageToColorSpace(SkSpecialImage* src,

View File

@ -62,8 +62,7 @@ size_t SkImageInfo::computeByteSize(size_t rowBytes) const {
}
SkImageInfo SkImageInfo::MakeS32(int width, int height, SkAlphaType at) {
return SkImageInfo(width, height, kN32_SkColorType, at,
SkColorSpace::MakeSRGB());
return SkImageInfo({width, height}, kN32_SkColorType, at, SkColorSpace::MakeSRGB());
}
bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType,

View File

@ -79,12 +79,12 @@ bool SkModeColorFilter::onAppendStages(const SkStageRec& rec, bool shaderIsOpaqu
#include "src/gpu/effects/generated/GrConstColorProcessor.h"
std::unique_ptr<GrFragmentProcessor> SkModeColorFilter::asFragmentProcessor(
GrRecordingContext*, const GrColorSpaceInfo& dstColorSpaceInfo) const {
GrRecordingContext*, const GrColorInfo& dstColorInfo) const {
if (SkBlendMode::kDst == fMode) {
return nullptr;
}
auto constFP = GrConstColorProcessor::Make(SkColorToPMColor4f(fColor, dstColorSpaceInfo),
auto constFP = GrConstColorProcessor::Make(SkColorToPMColor4f(fColor, dstColorInfo),
GrConstColorProcessor::InputMode::kIgnore);
auto fp = GrXfermodeFragmentProcessor::MakeFromSrcProcessor(std::move(constFP), fMode);
if (!fp) {

View File

@ -20,8 +20,8 @@ public:
uint32_t getFlags() const override;
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(
GrRecordingContext*, const GrColorSpaceInfo&) const override;
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(GrRecordingContext*,
const GrColorInfo&) const override;
#endif
protected:

View File

@ -53,8 +53,8 @@ SkImageGenerator::MakeFromPicture(const SkISize& size, sk_sp<SkPicture> picture,
colorType = kRGBA_F16_SkColorType;
}
SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType,
kPremul_SkAlphaType, std::move(colorSpace));
SkImageInfo info =
SkImageInfo::Make(size, colorType, kPremul_SkAlphaType, std::move(colorSpace));
return std::unique_ptr<SkImageGenerator>(
new SkPictureImageGenerator(info, std::move(picture), matrix, paint));
}

View File

@ -276,8 +276,7 @@ public:
const SkSurfaceProps* props) const override {
// Ignore the requested color type, the raster backend currently only supports N32
colorType = kN32_SkColorType; // TODO: find ways to allow f16
SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, at,
sk_ref_sp(colorSpace));
SkImageInfo info = SkImageInfo::Make(size, colorType, at, sk_ref_sp(colorSpace));
return SkSpecialSurface::MakeRaster(info, props);
}
@ -304,8 +303,7 @@ sk_sp<SkSurface> onMakeTightSurface(SkColorType colorType, const SkColorSpace* c
const SkISize& size, SkAlphaType at) const override {
// Ignore the requested color type, the raster backend currently only supports N32
colorType = kN32_SkColorType; // TODO: find ways to allow f16
SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, at,
sk_ref_sp(colorSpace));
SkImageInfo info = SkImageInfo::Make(size, colorType, at, sk_ref_sp(colorSpace));
return SkSurface::MakeRaster(info);
}
@ -525,8 +523,7 @@ public:
// onMakeSurface() or is this unnecessary?
colorType = colorSpace && colorSpace->gammaIsLinear()
? kRGBA_F16_SkColorType : kRGBA_8888_SkColorType;
SkImageInfo info = SkImageInfo::Make(size.width(), size.height(), colorType, at,
sk_ref_sp(colorSpace));
SkImageInfo info = SkImageInfo::Make(size, colorType, at, sk_ref_sp(colorSpace));
// CONTEXT TODO: remove this use of 'backdoor' to create an SkSurface
return SkSurface::MakeRenderTarget(fContext->priv().backdoor(), SkBudgeted::kYes, info);
}

View File

@ -16,7 +16,7 @@
#if SK_SUPPORT_GPU
#include "include/gpu/GrContext.h"
#include "src/gpu/GrColorSpaceInfo.h"
#include "src/gpu/GrColorInfo.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#endif
@ -36,9 +36,9 @@ public:
~SkHighContrast_Filter() override {}
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(
GrRecordingContext*, const GrColorSpaceInfo&) const override;
#endif
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(GrRecordingContext*,
const GrColorInfo&) const override;
#endif
bool onAppendStages(const SkStageRec& rec, bool shaderIsOpaque) const override;
@ -354,7 +354,7 @@ void GLHighContrastFilterEffect::emitCode(EmitArgs& args) {
}
std::unique_ptr<GrFragmentProcessor> SkHighContrast_Filter::asFragmentProcessor(
GrRecordingContext*, const GrColorSpaceInfo& csi) const {
GrRecordingContext*, const GrColorInfo& csi) const {
bool linearize = !csi.isLinearlyBlended();
return HighContrastFilterEffect::Make(fConfig, linearize);
}

View File

@ -39,7 +39,7 @@ void SkLumaColorFilter::flatten(SkWriteBuffer&) const {}
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> SkLumaColorFilter::asFragmentProcessor(
GrRecordingContext*, const GrColorSpaceInfo&) const {
GrRecordingContext*, const GrColorInfo&) const {
return GrLumaColorFilterEffect::Make();
}
#endif

View File

@ -88,7 +88,7 @@ void SkOverdrawColorFilter::RegisterFlattenables() {
#include "include/private/GrRecordingContext.h"
std::unique_ptr<GrFragmentProcessor> SkOverdrawColorFilter::asFragmentProcessor(
GrRecordingContext* context, const GrColorSpaceInfo&) const {
GrRecordingContext* context, const GrColorInfo&) const {
static int overdrawIndex = GrSkSLFP::NewIndex();
return GrSkSLFP::Make(context, overdrawIndex, "Overdraw", SKSL_OVERDRAW_SRC, fColors,
sizeof(fColors));

View File

@ -85,8 +85,8 @@ public:
~SkTable_ColorFilter() override { delete fBitmap; }
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(
GrRecordingContext*, const GrColorSpaceInfo&) const override;
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(GrRecordingContext*,
const GrColorInfo&) const override;
#endif
enum {
@ -234,7 +234,7 @@ void SkTable_ColorFilter::getTableAsBitmap(SkBitmap* table) const {
#if SK_SUPPORT_GPU
#include "include/private/GrRecordingContext.h"
#include "src/gpu/GrColorSpaceInfo.h"
#include "src/gpu/GrColorInfo.h"
#include "src/gpu/GrFragmentProcessor.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/SkGr.h"
@ -399,15 +399,15 @@ std::unique_ptr<GrFragmentProcessor> ColorTableEffect::TestCreate(GrProcessorTes
));
sk_sp<SkColorSpace> colorSpace = GrTest::TestColorSpace(d->fRandom);
auto fp = filter->asFragmentProcessor(
d->context(), GrColorSpaceInfo(GrColorType::kRGBA_8888, kUnknown_SkAlphaType,
std::move(colorSpace)));
d->context(),
GrColorInfo(GrColorType::kRGBA_8888, kUnknown_SkAlphaType, std::move(colorSpace)));
SkASSERT(fp);
return fp;
}
#endif
std::unique_ptr<GrFragmentProcessor> SkTable_ColorFilter::asFragmentProcessor(
GrRecordingContext* context, const GrColorSpaceInfo&) const {
GrRecordingContext* context, const GrColorInfo&) const {
SkBitmap bitmap;
this->getTableAsBitmap(&bitmap);

View File

@ -422,13 +422,12 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU(
renderTargetContext->drawRect(GrNoClip(), std::move(paint), GrAA::kNo, matrix,
SkRect::Make(bounds));
return SkSpecialImage::MakeDeferredFromGpu(
context,
SkIRect::MakeWH(bounds.width(), bounds.height()),
kNeedNewImageUniqueID_SpecialImage,
renderTargetContext->asTextureProxyRef(),
renderTargetContext->colorSpaceInfo().colorType(),
renderTargetContext->colorSpaceInfo().refColorSpace());
return SkSpecialImage::MakeDeferredFromGpu(context,
SkIRect::MakeWH(bounds.width(), bounds.height()),
kNeedNewImageUniqueID_SpecialImage,
renderTargetContext->asTextureProxyRef(),
renderTargetContext->colorInfo().colorType(),
renderTargetContext->colorInfo().refColorSpace());
}
#endif

View File

@ -687,7 +687,7 @@ sk_sp<SkSpecialImage> SkBlurImageFilterImpl::gpuFilter(
SkIRect::MakeWH(dstBounds.width(), dstBounds.height()),
kNeedNewImageUniqueID_SpecialImage,
renderTargetContext->asTextureProxyRef(),
renderTargetContext->colorSpaceInfo().colorType(),
renderTargetContext->colorInfo().colorType(),
sk_ref_sp(input->getColorSpace()),
ctx.surfaceProps());
}

View File

@ -389,8 +389,8 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffectImpl::onFilterImage(const Context&
SkIRect::MakeWH(bounds.width(), bounds.height()),
kNeedNewImageUniqueID_SpecialImage,
renderTargetContext->asTextureProxyRef(),
renderTargetContext->colorSpaceInfo().colorType(),
renderTargetContext->colorSpaceInfo().refColorSpace());
renderTargetContext->colorInfo().colorType(),
renderTargetContext->colorInfo().refColorSpace());
}
#endif

View File

@ -538,8 +538,8 @@ sk_sp<SkSpecialImage> SkLightingImageFilterInternal::filterImageGPU(
SkIRect::MakeWH(offsetBounds.width(), offsetBounds.height()),
kNeedNewImageUniqueID_SpecialImage,
renderTargetContext->asTextureProxyRef(),
renderTargetContext->colorSpaceInfo().colorType(),
renderTargetContext->colorSpaceInfo().refColorSpace());
renderTargetContext->colorInfo().colorType(),
renderTargetContext->colorInfo().refColorSpace());
}
#endif

View File

@ -796,8 +796,7 @@ sk_sp<SkSpecialImage> SkMorphologyImageFilterImpl::onFilterImage(const Context&
return nullptr;
}
SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(),
inputBM.colorType(), inputBM.alphaType());
SkImageInfo info = SkImageInfo::Make(bounds.size(), inputBM.colorType(), inputBM.alphaType());
SkBitmap dst;
if (!dst.tryAllocPixels(info)) {

View File

@ -317,13 +317,12 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilterImpl::filterImageGPU(
renderTargetContext->drawRect(GrNoClip(), std::move(paint), GrAA::kNo, matrix,
SkRect::Make(bounds));
return SkSpecialImage::MakeDeferredFromGpu(
context,
SkIRect::MakeWH(bounds.width(), bounds.height()),
kNeedNewImageUniqueID_SpecialImage,
renderTargetContext->asTextureProxyRef(),
renderTargetContext->colorSpaceInfo().colorType(),
renderTargetContext->colorSpaceInfo().refColorSpace());
return SkSpecialImage::MakeDeferredFromGpu(context,
SkIRect::MakeWH(bounds.width(), bounds.height()),
kNeedNewImageUniqueID_SpecialImage,
renderTargetContext->asTextureProxyRef(),
renderTargetContext->colorInfo().colorType(),
renderTargetContext->colorInfo().refColorSpace());
}
std::unique_ptr<GrFragmentProcessor> SkXfermodeImageFilterImpl::makeFGFrag(

View File

@ -17,9 +17,9 @@
#include "src/gpu/GrSurfaceContext.h"
#include "src/gpu/SkGr.h"
static GrColorSpaceInfo make_info(const SkBitmap& bm) {
return GrColorSpaceInfo(SkColorTypeToGrColorType(bm.colorType()), bm.alphaType(),
bm.refColorSpace());
static GrColorInfo make_info(const SkBitmap& bm) {
return GrColorInfo(SkColorTypeToGrColorType(bm.colorType()), bm.alphaType(),
bm.refColorSpace());
}
GrBitmapTextureMaker::GrBitmapTextureMaker(GrRecordingContext* context, const SkBitmap& bitmap,

View File

@ -411,8 +411,8 @@ static void draw_shape_with_mask_filter(GrRecordingContext* context,
if (maskRTC) {
filteredMask = maskFilter->filterMaskGPU(context,
maskRTC->asTextureProxyRef(),
maskRTC->colorSpaceInfo().colorType(),
maskRTC->colorSpaceInfo().alphaType(),
maskRTC->colorInfo().colorType(),
maskRTC->colorInfo().alphaType(),
viewMatrix,
maskRect);
SkASSERT(kTopLeft_GrSurfaceOrigin == filteredMask->origin());
@ -459,8 +459,7 @@ void GrBlurUtils::drawShapeWithMaskFilter(GrRecordingContext* context,
}
GrPaint grPaint;
if (!SkPaintToGrPaint(context, renderTargetContext->colorSpaceInfo(), paint, viewMatrix,
&grPaint)) {
if (!SkPaintToGrPaint(context, renderTargetContext->colorInfo(), paint, viewMatrix, &grPaint)) {
return;
}

View File

@ -5,15 +5,15 @@
* found in the LICENSE file.
*/
#include "src/core/SkColorSpacePriv.h"
#include "src/gpu/GrColorSpaceInfo.h"
#include "src/gpu/GrColorInfo.h"
GrColorSpaceInfo::GrColorSpaceInfo(GrColorType colorType,
SkAlphaType alphaType,
sk_sp<SkColorSpace> colorSpace)
#include "src/core/SkColorSpacePriv.h"
GrColorInfo::GrColorInfo(
GrColorType colorType, SkAlphaType alphaType, sk_sp<SkColorSpace> colorSpace)
: fColorSpace(std::move(colorSpace)), fColorType(colorType), fAlphaType(alphaType) {}
GrColorSpaceXform* GrColorSpaceInfo::colorSpaceXformFromSRGB() const {
GrColorSpaceXform* GrColorInfo::colorSpaceXformFromSRGB() const {
// TODO: Make this atomic if we start accessing this on multiple threads.
if (!fInitializedColorSpaceXformFromSRGB) {
// sRGB sources are very common (SkColor, etc...), so we cache that transformation

View File

@ -5,19 +5,21 @@
* found in the LICENSE file.
*/
#ifndef GrColorSpaceInfo_DEFINED
#define GrColorSpaceInfo_DEFINED
#ifndef GrColorInfo_DEFINED
#define GrColorInfo_DEFINED
#include "include/core/SkColorSpace.h"
#include "include/core/SkRefCnt.h"
#include "include/gpu/GrTypes.h"
#include "src/gpu/GrColorSpaceXform.h"
/** Describes the color space properties of a surface context. */
class GrColorSpaceInfo {
/**
* All the info needed to interpret a color: Color type + alpha type + color space. Also caches
* the GrColorSpaceXform from sRGB. */
class GrColorInfo {
public:
GrColorSpaceInfo() = default;
GrColorSpaceInfo(GrColorType, SkAlphaType, sk_sp<SkColorSpace>);
GrColorInfo() = default;
GrColorInfo(GrColorType, SkAlphaType, sk_sp<SkColorSpace>);
bool isLinearlyBlended() const { return fColorSpace && fColorSpace->gammaIsLinear(); }

View File

@ -10,7 +10,7 @@
#include "include/core/SkColor.h"
#include "include/private/GrTypesPriv.h"
#include "src/gpu/GrColorSpaceInfo.h"
#include "src/gpu/GrColorInfo.h"
#include "src/gpu/GrSwizzle.h"
class GrImageInfo;

View File

@ -11,18 +11,18 @@
#include "include/core/SkFilterQuality.h"
#include "include/core/SkMatrix.h"
class GrColorSpaceInfo;
class GrColorInfo;
class GrRecordingContext;
struct GrFPArgs {
GrFPArgs(GrRecordingContext* context,
const SkMatrix* viewMatrix,
SkFilterQuality filterQuality,
const GrColorSpaceInfo* dstColorSpaceInfo)
: fContext(context)
, fViewMatrix(viewMatrix)
, fFilterQuality(filterQuality)
, fDstColorSpaceInfo(dstColorSpaceInfo) {
const GrColorInfo* dstColorInfo)
: fContext(context)
, fViewMatrix(viewMatrix)
, fFilterQuality(filterQuality)
, fDstColorInfo(dstColorInfo) {
SkASSERT(fContext);
SkASSERT(fViewMatrix);
}
@ -46,7 +46,7 @@ struct GrFPArgs {
bool fInputColorIsOpaque = false;
SkFilterQuality fFilterQuality;
const GrColorSpaceInfo* fDstColorSpaceInfo;
const GrColorInfo* fDstColorInfo;
};
class GrFPArgs::WithPreLocalMatrix final : public GrFPArgs {

View File

@ -10,7 +10,7 @@
#include "include/core/SkImageInfo.h"
#include "include/private/GrTypesPriv.h"
#include "src/gpu/GrColorSpaceInfo.h"
#include "src/gpu/GrColorInfo.h"
class GrImageInfo {
public:
@ -88,7 +88,7 @@ public:
bool isValid() const { return fColorInfo.isValid() && this->width() > 0 && this->height() > 0; }
private:
GrColorSpaceInfo fColorInfo = {};
GrColorInfo fColorInfo = {};
SkISize fDimensions;
};

View File

@ -13,10 +13,10 @@
#include "src/image/SkImage_GpuYUVA.h"
#include "src/image/SkImage_Lazy.h"
static GrColorSpaceInfo make_info(const SkImage*& image) {
return GrColorSpaceInfo(SkColorTypeToGrColorType(image->colorType()),
image->alphaType(),
image->refColorSpace());
static GrColorInfo make_info(const SkImage*& image) {
return GrColorInfo(SkColorTypeToGrColorType(image->colorType()),
image->alphaType(),
image->refColorSpace());
}
GrImageTextureMaker::GrImageTextureMaker(GrRecordingContext* context, const SkImage* client,

View File

@ -73,9 +73,9 @@ class GrRenderTargetContext::TextTarget : public GrTextTarget {
public:
TextTarget(GrRenderTargetContext* renderTargetContext)
: GrTextTarget(renderTargetContext->width(), renderTargetContext->height(),
renderTargetContext->colorSpaceInfo())
renderTargetContext->colorInfo())
, fRenderTargetContext(renderTargetContext)
, fGlyphPainter{*renderTargetContext}{}
, fGlyphPainter{*renderTargetContext} {}
void addDrawOp(const GrClip& clip, std::unique_ptr<GrAtlasTextOp> op) override {
fRenderTargetContext->addDrawOp(clip, std::move(op));
@ -90,11 +90,11 @@ public:
void makeGrPaint(GrMaskFormat maskFormat, const SkPaint& skPaint, const SkMatrix& viewMatrix,
GrPaint* grPaint) override {
auto context = fRenderTargetContext->fContext;
const GrColorSpaceInfo& colorSpaceInfo = fRenderTargetContext->colorSpaceInfo();
const GrColorInfo& colorInfo = fRenderTargetContext->colorInfo();
if (kARGB_GrMaskFormat == maskFormat) {
SkPaintToGrPaintWithPrimitiveColor(context, colorSpaceInfo, skPaint, grPaint);
SkPaintToGrPaintWithPrimitiveColor(context, colorInfo, skPaint, grPaint);
} else {
SkPaintToGrPaint(context, colorSpaceInfo, skPaint, viewMatrix, grPaint);
SkPaintToGrPaint(context, colorInfo, skPaint, viewMatrix, grPaint);
}
}
@ -621,7 +621,7 @@ void GrRenderTargetContext::drawTexturedQuad(const GrClip& clip,
const GrClip& finalClip = opt == QuadOptimization::kClipApplied ? GrFixedClip::Disabled()
: clip;
GrAAType aaType = this->chooseAAType(aa);
auto clampType = GrColorTypeClampType(this->colorSpaceInfo().colorType());
auto clampType = GrColorTypeClampType(this->colorInfo().colorType());
auto saturate = clampType == GrClampType::kManual ? GrTextureOp::Saturate::kYes
: GrTextureOp::Saturate::kNo;
// Use the provided domain, although hypothetically we could detect that the cropped local
@ -887,7 +887,7 @@ void GrRenderTargetContext::drawTextureSet(const GrClip& clip, const TextureSetE
// Can use a single op, avoiding GrPaint creation, and can batch across proxies
AutoCheckFlush acf(this->drawingManager());
GrAAType aaType = this->chooseAAType(aa);
auto clampType = GrColorTypeClampType(this->colorSpaceInfo().colorType());
auto clampType = GrColorTypeClampType(this->colorInfo().colorType());
auto saturate = clampType == GrClampType::kManual ? GrTextureOp::Saturate::kYes
: GrTextureOp::Saturate::kNo;
auto op = GrTextureOp::MakeSet(fContext, set, cnt, filter, saturate, aaType, constraint,
@ -914,7 +914,7 @@ void GrRenderTargetContext::drawVertices(const GrClip& clip,
GrAAType aaType = this->chooseAAType(GrAA::kNo);
std::unique_ptr<GrDrawOp> op = GrDrawVerticesOp::Make(
fContext, std::move(paint), std::move(vertices), bones, boneCount, viewMatrix, aaType,
this->colorSpaceInfo().refColorSpaceXformFromSRGB(), overridePrimType);
this->colorInfo().refColorSpaceXformFromSRGB(), overridePrimType);
this->addDrawOp(clip, std::move(op));
}
@ -1517,7 +1517,7 @@ void GrRenderTargetContext::asyncRescaleAndReadPixels(
return;
}
bool needsRescale = srcRect.width() != info.width() || srcRect.height() != info.height();
auto colorTypeOfFinalContext = this->colorSpaceInfo().colorType();
auto colorTypeOfFinalContext = this->colorInfo().colorType();
auto backendFormatOfFinalContext = fRenderTargetProxy->backendFormat();
if (needsRescale) {
colorTypeOfFinalContext = dstCT;
@ -1535,7 +1535,7 @@ void GrRenderTargetContext::asyncRescaleAndReadPixels(
// channels are in the src.
uint32_t dstComponents = GrColorTypeComponentFlags(dstCT);
uint32_t legalReadComponents = GrColorTypeComponentFlags(readInfo.fColorType);
uint32_t srcComponents = GrColorTypeComponentFlags(this->colorSpaceInfo().colorType());
uint32_t srcComponents = GrColorTypeComponentFlags(this->colorInfo().colorType());
if ((~legalReadComponents & dstComponents) & srcComponents) {
callback(context, nullptr, 0);
return;
@ -1550,14 +1550,14 @@ void GrRenderTargetContext::asyncRescaleAndReadPixels(
callback(context, nullptr, 0);
return;
}
SkASSERT(SkColorSpace::Equals(tempRTC->colorSpaceInfo().colorSpace(), info.colorSpace()));
SkASSERT(SkColorSpace::Equals(tempRTC->colorInfo().colorSpace(), info.colorSpace()));
SkASSERT(tempRTC->origin() == kTopLeft_GrSurfaceOrigin);
x = y = 0;
} else {
sk_sp<GrColorSpaceXform> xform =
GrColorSpaceXform::Make(this->colorSpaceInfo().colorSpace(),
this->colorSpaceInfo().alphaType(),
info.colorSpace(), info.alphaType());
sk_sp<GrColorSpaceXform> xform = GrColorSpaceXform::Make(this->colorInfo().colorSpace(),
this->colorInfo().alphaType(),
info.colorSpace(),
info.alphaType());
// Insert a draw to a temporary surface if we need to do a y-flip or color space conversion.
if (this->origin() == kBottomLeft_GrSurfaceOrigin || xform) {
// We flip or color convert by drawing and we don't currently support drawing to
@ -1581,7 +1581,7 @@ void GrRenderTargetContext::asyncRescaleAndReadPixels(
}
tempRTC = direct->priv().makeDeferredRenderTargetContext(
SkBackingFit::kApprox, srcRect.width(), srcRect.height(),
this->colorSpaceInfo().colorType(), info.refColorSpace(), 1, GrMipMapped::kNo,
this->colorInfo().colorType(), info.refColorSpace(), 1, GrMipMapped::kNo,
kTopLeft_GrSurfaceOrigin);
if (!tempRTC) {
callback(context, nullptr, 0);
@ -1610,9 +1610,9 @@ void GrRenderTargetContext::asyncReadPixels(const SkIRect& rect, SkColorType col
if (!transferResult.fTransferBuffer) {
SkAutoPixmapStorage pm;
auto ii = SkImageInfo::Make(rect.width(), rect.height(), colorType,
this->colorSpaceInfo().alphaType(),
this->colorSpaceInfo().refColorSpace());
auto ii = SkImageInfo::Make(rect.size(), colorType,
this->colorInfo().alphaType(),
this->colorInfo().refColorSpace());
pm.alloc(ii);
if (!this->readPixels(ii, pm.writable_addr(), pm.rowBytes(), {rect.fLeft, rect.fTop})) {
callback(context, nullptr, 0);
@ -1690,14 +1690,14 @@ void GrRenderTargetContext::asyncRescaleAndReadPixelsYUV420(
callback(context, nullptr, nullptr);
return;
}
SkASSERT(SkColorSpace::Equals(tempRTC->colorSpaceInfo().colorSpace(), info.colorSpace()));
SkASSERT(SkColorSpace::Equals(tempRTC->colorInfo().colorSpace(), info.colorSpace()));
SkASSERT(tempRTC->origin() == kTopLeft_GrSurfaceOrigin);
x = y = 0;
} else {
// We assume the caller wants kPremul. There is no way to indicate a preference.
sk_sp<GrColorSpaceXform> xform = GrColorSpaceXform::Make(
this->colorSpaceInfo().colorSpace(), this->colorSpaceInfo().alphaType(),
dstColorSpace.get(), kPremul_SkAlphaType);
this->colorInfo().colorSpace(), this->colorInfo().alphaType(), dstColorSpace.get(),
kPremul_SkAlphaType);
if (xform) {
sk_sp<GrTextureProxy> texProxy = this->asTextureProxyRef();
// TODO: Do something if the input is not a texture already.
@ -1707,8 +1707,8 @@ void GrRenderTargetContext::asyncRescaleAndReadPixelsYUV420(
}
SkRect srcRectToDraw = SkRect::Make(srcRect);
tempRTC = direct->priv().makeDeferredRenderTargetContext(
SkBackingFit::kApprox, dstW, dstH, this->colorSpaceInfo().colorType(),
dstColorSpace, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
SkBackingFit::kApprox, dstW, dstH, this->colorInfo().colorType(), dstColorSpace,
1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
if (!tempRTC) {
callback(context, nullptr, nullptr);
return;
@ -2095,7 +2095,7 @@ bool GrRenderTargetContextPriv::drawAndStencilPath(const GrHardClip& clip,
&viewMatrix,
&shape,
aaType,
fRenderTargetContext->colorSpaceInfo().isLinearlyBlended()};
fRenderTargetContext->colorInfo().isLinearlyBlended()};
pr->drawPath(args);
return true;
}
@ -2192,7 +2192,7 @@ void GrRenderTargetContext::drawShapeUsingPathRenderer(const GrClip& clip,
&viewMatrix,
canDrawArgs.fShape,
aaType,
this->colorSpaceInfo().isLinearlyBlended()};
this->colorInfo().isLinearlyBlended()};
pr->drawPath(args);
}
@ -2257,7 +2257,7 @@ void GrRenderTargetContext::addDrawOp(const GrClip& clip, std::unique_ptr<GrDraw
SkASSERT((!usesStencil && !appliedClip.hasStencilClip()) || (fNumStencilSamples > 0));
GrClampType clampType = GrColorTypeClampType(this->colorSpaceInfo().colorType());
GrClampType clampType = GrColorTypeClampType(this->colorInfo().colorType());
// MIXED SAMPLES TODO: If we start using mixed samples for clips we will need to check the clip
// here as well.
bool hasMixedSampledCoverage = (usesHWAA && this->numSamples() <= 1);
@ -2335,7 +2335,7 @@ bool GrRenderTargetContext::setupDstProxy(const GrClip& clip, const GrOp& op,
// MSAA consideration: When there is support for reading MSAA samples in the shader we could
// have per-sample dst values by making the copy multisampled.
GrCaps::DstCopyRestrictions restrictions = this->caps()->getDstCopyRestrictions(
fRenderTargetProxy.get(), this->colorSpaceInfo().colorType());
fRenderTargetProxy.get(), this->colorInfo().colorType());
if (!restrictions.fMustCopyWholeSrc) {
copyRect = clippedRect;

View File

@ -36,7 +36,7 @@ GrSurfaceContext::GrSurfaceContext(GrRecordingContext* context,
GrColorType colorType,
SkAlphaType alphaType,
sk_sp<SkColorSpace> colorSpace)
: fContext(context), fColorSpaceInfo(colorType, alphaType, std::move(colorSpace)) {}
: fContext(context), fColorInfo(colorType, alphaType, std::move(colorSpace)) {}
const GrCaps* GrSurfaceContext::caps() const { return fContext->priv().caps(); }
@ -100,13 +100,13 @@ bool GrSurfaceContext::readPixels(const GrImageInfo& origDstInfo, void* dst, siz
// Our tight row bytes may have been changed by clipping.
tightRowBytes = dstInfo.minRowBytes();
bool premul = this->colorSpaceInfo().alphaType() == kUnpremul_SkAlphaType &&
bool premul = this->colorInfo().alphaType() == kUnpremul_SkAlphaType &&
dstInfo.alphaType() == kPremul_SkAlphaType;
bool unpremul = this->colorSpaceInfo().alphaType() == kPremul_SkAlphaType &&
bool unpremul = this->colorInfo().alphaType() == kPremul_SkAlphaType &&
dstInfo.alphaType() == kUnpremul_SkAlphaType;
bool needColorConversion = SkColorSpaceXformSteps::Required(this->colorSpaceInfo().colorSpace(),
dstInfo.colorSpace());
bool needColorConversion =
SkColorSpaceXformSteps::Required(this->colorInfo().colorSpace(), dstInfo.colorSpace());
const GrCaps* caps = direct->priv().caps();
// This is the getImageData equivalent to the canvas2D putImageData fast path. We probably don't
@ -131,10 +131,9 @@ bool GrSurfaceContext::readPixels(const GrImageInfo& origDstInfo, void* dst, siz
}
if (readFlag == GrCaps::SurfaceReadPixelsSupport::kCopyToTexture2D || canvas2DFastPath) {
GrColorType colorType = canvas2DFastPath ? GrColorType::kRGBA_8888
: this->colorSpaceInfo().colorType();
sk_sp<SkColorSpace> cs = canvas2DFastPath ? nullptr
: this->colorSpaceInfo().refColorSpace();
GrColorType colorType =
canvas2DFastPath ? GrColorType::kRGBA_8888 : this->colorInfo().colorType();
sk_sp<SkColorSpace> cs = canvas2DFastPath ? nullptr : this->colorInfo().refColorSpace();
auto tempCtx = direct->priv().makeDeferredRenderTargetContext(
SkBackingFit::kApprox, dstInfo.width(), dstInfo.height(), colorType, std::move(cs),
@ -177,7 +176,7 @@ bool GrSurfaceContext::readPixels(const GrImageInfo& origDstInfo, void* dst, siz
bool flip = srcProxy->origin() == kBottomLeft_GrSurfaceOrigin;
auto supportedRead = caps->supportedReadPixelsColorType(
this->colorSpaceInfo().colorType(), srcProxy->backendFormat(), dstInfo.colorType());
this->colorInfo().colorType(), srcProxy->backendFormat(), dstInfo.colorType());
bool makeTight = !caps->readPixelsRowBytesSupport() && tightRowBytes != rowBytes;
@ -189,8 +188,8 @@ bool GrSurfaceContext::readPixels(const GrImageInfo& origDstInfo, void* dst, siz
void* readDst = dst;
size_t readRB = rowBytes;
if (convert) {
tmpInfo = {supportedRead.fColorType, this->colorSpaceInfo().alphaType(),
this->colorSpaceInfo().refColorSpace(), dstInfo.width(), dstInfo.height()};
tmpInfo = {supportedRead.fColorType, this->colorInfo().alphaType(),
this->colorInfo().refColorSpace(), dstInfo.width(), dstInfo.height()};
size_t tmpRB = tmpInfo.minRowBytes();
size_t size = tmpRB * tmpInfo.height();
// Chrome MSAN bots require the data to be initialized (hence the ()).
@ -204,7 +203,7 @@ bool GrSurfaceContext::readPixels(const GrImageInfo& origDstInfo, void* dst, siz
direct->priv().flushSurface(srcProxy);
if (!direct->priv().getGpu()->readPixels(srcSurface, pt.fX, pt.fY, dstInfo.width(),
dstInfo.height(), this->colorSpaceInfo().colorType(),
dstInfo.height(), this->colorInfo().colorType(),
supportedRead.fColorType, readDst, readRB)) {
return false;
}
@ -259,13 +258,13 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s
// Our tight row bytes may have been changed by clipping.
tightRowBytes = srcInfo.minRowBytes();
bool premul = this->colorSpaceInfo().alphaType() == kPremul_SkAlphaType &&
srcInfo.alphaType() == kUnpremul_SkAlphaType;
bool unpremul = this->colorSpaceInfo().alphaType() == kUnpremul_SkAlphaType &&
srcInfo.alphaType() == kPremul_SkAlphaType;
bool premul = this->colorInfo().alphaType() == kPremul_SkAlphaType &&
srcInfo.alphaType() == kUnpremul_SkAlphaType;
bool unpremul = this->colorInfo().alphaType() == kUnpremul_SkAlphaType &&
srcInfo.alphaType() == kPremul_SkAlphaType;
bool needColorConversion = SkColorSpaceXformSteps::Required(
srcInfo.colorSpace(), this->colorSpaceInfo().colorSpace());
bool needColorConversion =
SkColorSpaceXformSteps::Required(srcInfo.colorSpace(), this->colorInfo().colorSpace());
const GrCaps* caps = direct->priv().caps();
@ -298,12 +297,12 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s
alphaType = kUnpremul_SkAlphaType;
} else {
desc.fConfig = dstProxy->config();
colorType = this->colorSpaceInfo().colorType();
colorType = this->colorInfo().colorType();
format = dstProxy->backendFormat().makeTexture2D();
if (!format.isValid()) {
return false;
}
alphaType = this->colorSpaceInfo().alphaType();
alphaType = this->colorInfo().alphaType();
}
// It is more efficient for us to write pixels into a top left origin so we prefer that.
@ -321,7 +320,7 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s
return false;
}
auto tempCtx = direct->priv().drawingManager()->makeTextureContext(
tempProxy, colorType, alphaType, this->colorSpaceInfo().refColorSpace());
tempProxy, colorType, alphaType, this->colorInfo().refColorSpace());
if (!tempCtx) {
return false;
}
@ -370,7 +369,7 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s
}
GrColorType allowedColorType =
caps->supportedWritePixelsColorType(this->colorSpaceInfo().colorType(),
caps->supportedWritePixelsColorType(this->colorInfo().colorType(),
dstProxy->backendFormat(),
srcInfo.colorType()).fColorType;
bool flip = dstProxy->origin() == kBottomLeft_GrSurfaceOrigin;
@ -381,9 +380,8 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s
std::unique_ptr<char[]> tmpPixels;
GrColorType srcColorType = srcInfo.colorType();
if (convert) {
GrImageInfo tmpInfo(allowedColorType, this->colorSpaceInfo().alphaType(),
this->colorSpaceInfo().refColorSpace(), srcInfo.width(),
srcInfo.height());
GrImageInfo tmpInfo(allowedColorType, this->colorInfo().alphaType(),
this->colorInfo().refColorSpace(), srcInfo.width(), srcInfo.height());
auto tmpRB = tmpInfo.minRowBytes();
tmpPixels.reset(new char[tmpRB * tmpInfo.height()]);
@ -402,9 +400,9 @@ bool GrSurfaceContext::writePixels(const GrImageInfo& origSrcInfo, const void* s
// TODO: should this policy decision just be moved into the drawing manager?
direct->priv().flushSurface(caps->preferVRAMUseOverFlushes() ? dstProxy : nullptr);
return direct->priv().getGpu()->writePixels(
dstSurface, pt.fX, pt.fY, srcInfo.width(), srcInfo.height(),
this->colorSpaceInfo().colorType(), srcColorType, src, rowBytes);
return direct->priv().getGpu()->writePixels(dstSurface, pt.fX, pt.fY, srcInfo.width(),
srcInfo.height(), this->colorInfo().colorType(),
srcColorType, src, rowBytes);
}
bool GrSurfaceContext::copy(GrSurfaceProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint) {
@ -486,11 +484,11 @@ std::unique_ptr<GrRenderTargetContext> GrSurfaceContext::rescale(
// Assume we should ignore the rescale linear request if the surface has no color space since
// it's unclear how we'd linearize from an unknown color space.
if (rescaleGamma == SkSurface::kLinear && this->colorSpaceInfo().colorSpace() &&
!this->colorSpaceInfo().colorSpace()->gammaIsLinear()) {
auto cs = this->colorSpaceInfo().colorSpace()->makeLinearGamma();
auto xform = GrColorSpaceXform::Make(this->colorSpaceInfo().colorSpace(),
this->colorSpaceInfo().alphaType(), cs.get(),
if (rescaleGamma == SkSurface::kLinear && this->colorInfo().colorSpace() &&
!this->colorInfo().colorSpace()->gammaIsLinear()) {
auto cs = this->colorInfo().colorSpace()->makeLinearGamma();
auto xform = GrColorSpaceXform::Make(this->colorInfo().colorSpace(),
this->colorInfo().alphaType(), cs.get(),
kPremul_SkAlphaType);
// We'll fall back to kRGBA_8888 if half float not supported.
auto linearRTC = fContext->priv().makeDeferredRenderTargetContextWithFallback(
@ -531,16 +529,16 @@ std::unique_ptr<GrRenderTargetContext> GrSurfaceContext::rescale(
--stepsY;
}
auto input = tempA ? tempA.get() : this;
GrColorType colorType = input->colorSpaceInfo().colorType();
auto cs = input->colorSpaceInfo().refColorSpace();
GrColorType colorType = input->colorInfo().colorType();
auto cs = input->colorInfo().refColorSpace();
sk_sp<GrColorSpaceXform> xform;
auto prevAlphaType = input->colorSpaceInfo().alphaType();
auto prevAlphaType = input->colorInfo().alphaType();
if (!stepsX && !stepsY) {
// Might as well fold conversion to final info in the last step.
cs = info.refColorSpace();
colorType = SkColorTypeToGrColorType(info.colorType());
xform = GrColorSpaceXform::Make(input->colorSpaceInfo().colorSpace(),
input->colorSpaceInfo().alphaType(), cs.get(),
xform = GrColorSpaceXform::Make(input->colorInfo().colorSpace(),
input->colorInfo().alphaType(), cs.get(),
info.alphaType());
}
tempB = fContext->priv().makeDeferredRenderTargetContextWithFallback(
@ -608,13 +606,13 @@ GrSurfaceContext::PixelTransferResult GrSurfaceContext::transferPixels(GrColorTy
}
auto proxy = this->asSurfaceProxy();
auto supportedRead = this->caps()->supportedReadPixelsColorType(
this->colorSpaceInfo().colorType(), proxy->backendFormat(), dstCT);
auto supportedRead = this->caps()->supportedReadPixelsColorType(this->colorInfo().colorType(),
proxy->backendFormat(), dstCT);
// Fail if read color type does not have all of dstCT's color channels and those missing color
// channels are in the src.
uint32_t dstComponents = GrColorTypeComponentFlags(dstCT);
uint32_t legalReadComponents = GrColorTypeComponentFlags(supportedRead.fColorType);
uint32_t srcComponents = GrColorTypeComponentFlags(this->colorSpaceInfo().colorType());
uint32_t srcComponents = GrColorTypeComponentFlags(this->colorInfo().colorType());
if ((~legalReadComponents & dstComponents) & srcComponents) {
return {};
}
@ -638,11 +636,11 @@ GrSurfaceContext::PixelTransferResult GrSurfaceContext::transferPixels(GrColorTy
this->height() - rect.fTop);
}
this->drawingManager()->newTransferFromRenderTask(this->asSurfaceProxyRef(), srcRect,
this->colorSpaceInfo().colorType(),
this->colorInfo().colorType(),
supportedRead.fColorType, buffer, 0);
PixelTransferResult result;
result.fTransferBuffer = std::move(buffer);
auto at = this->colorSpaceInfo().alphaType();
auto at = this->colorInfo().alphaType();
if (supportedRead.fColorType != dstCT || flip) {
result.fPixelConverter = [w = rect.width(), h = rect.height(), dstCT, supportedRead, at](
void* dst, const void* src) {

View File

@ -13,7 +13,7 @@
#include "include/core/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSurface.h"
#include "src/gpu/GrColorSpaceInfo.h"
#include "src/gpu/GrColorInfo.h"
#include "src/gpu/GrDataUtils.h"
#include "src/gpu/GrSurfaceProxy.h"
@ -37,7 +37,7 @@ class GrSurfaceContext {
public:
virtual ~GrSurfaceContext() = default;
const GrColorSpaceInfo& colorSpaceInfo() const { return fColorSpaceInfo; }
const GrColorInfo& colorInfo() const { return fColorInfo; }
// TODO: these two calls would be way cooler if this object had a GrSurfaceProxy pointer
int width() const { return this->asSurfaceProxy()->width(); }
@ -158,7 +158,7 @@ private:
return this->copy(src, SkIRect::MakeWH(src->width(), src->height()), SkIPoint::Make(0, 0));
}
GrColorSpaceInfo fColorSpaceInfo;
GrColorInfo fColorInfo;
typedef SkRefCnt INHERITED;
};

View File

@ -13,7 +13,7 @@
#include "include/gpu/GrContext.h"
#include "src/core/SkMakeUnique.h"
#include "src/core/SkRectPriv.h"
#include "src/gpu/GrColorSpaceInfo.h"
#include "src/gpu/GrColorInfo.h"
#include "src/gpu/GrProcessorUnitTest.h"
#include "src/gpu/GrStyle.h"
#include "src/utils/SkDashPathPriv.h"
@ -338,10 +338,10 @@ sk_sp<GrColorSpaceXform> TestColorXform(SkRandom* random) {
TestAsFPArgs::TestAsFPArgs(GrProcessorTestData* d)
: fViewMatrixStorage(TestMatrix(d->fRandom))
, fColorSpaceInfoStorage(skstd::make_unique<GrColorSpaceInfo>(
, fColorInfoStorage(skstd::make_unique<GrColorInfo>(
GrColorType::kRGBA_8888, kPremul_SkAlphaType, TestColorSpace(d->fRandom)))
, fArgs(d->context(), &fViewMatrixStorage, kNone_SkFilterQuality,
fColorSpaceInfoStorage.get()) {}
, fArgs(d->context(), &fViewMatrixStorage, kNone_SkFilterQuality, fColorInfoStorage.get()) {
}
TestAsFPArgs::~TestAsFPArgs() {}

View File

@ -22,7 +22,7 @@
#include "src/gpu/GrSamplerState.h"
#include "src/shaders/SkShaderBase.h"
class GrColorSpaceInfo;
class GrColorInfo;
class GrColorSpaceXform;
struct GrProcessorTestData;
class GrStyle;
@ -60,7 +60,7 @@ public:
private:
SkMatrix fViewMatrixStorage;
std::unique_ptr<GrColorSpaceInfo> fColorSpaceInfoStorage;
std::unique_ptr<GrColorInfo> fColorInfoStorage;
GrFPArgs fArgs;
};

View File

@ -21,7 +21,7 @@ GrTextureAdjuster::GrTextureAdjuster(GrRecordingContext* context,
SkColorSpace* cs,
bool useDecal)
: INHERITED(context, original->width(), original->height(),
GrColorSpaceInfo(colorType, alphaType, sk_ref_sp(cs)), useDecal)
GrColorInfo(colorType, alphaType, sk_ref_sp(cs)), useDecal)
, fOriginal(std::move(original))
, fUniqueID(uniqueID) {}

View File

@ -26,7 +26,7 @@ public:
const GrSamplerState::Filter* filterOrNullForBicubic) override;
protected:
GrTextureMaker(GrRecordingContext* context, int width, int height, const GrColorSpaceInfo& info,
GrTextureMaker(GrRecordingContext* context, int width, int height, const GrColorInfo& info,
bool domainNeedsLocal)
: INHERITED(context, width, height, info, domainNeedsLocal) {}

View File

@ -11,7 +11,7 @@
#include "include/core/SkImageInfo.h"
#include "include/private/GrResourceKey.h"
#include "include/private/SkNoncopyable.h"
#include "src/gpu/GrColorSpaceInfo.h"
#include "src/gpu/GrColorInfo.h"
#include "src/gpu/GrSamplerState.h"
class GrFragmentProcessor;
@ -104,10 +104,10 @@ public:
int width() const { return fWidth; }
int height() const { return fHeight; }
GrColorType colorType() const { return fColorSpaceInfo.colorType(); }
SkAlphaType alphaType() const { return fColorSpaceInfo.alphaType(); }
SkColorSpace* colorSpace() const { return fColorSpaceInfo.colorSpace(); }
bool isAlphaOnly() const { return GrColorTypeIsAlphaOnly(fColorSpaceInfo.colorType()); }
GrColorType colorType() const { return fColorInfo.colorType(); }
SkAlphaType alphaType() const { return fColorInfo.alphaType(); }
SkColorSpace* colorSpace() const { return fColorInfo.colorSpace(); }
bool isAlphaOnly() const { return GrColorTypeIsAlphaOnly(fColorInfo.colorType()); }
bool domainNeedsDecal() const { return fDomainNeedsDecal; }
// If the "texture" samples multiple images that have different resolutions (e.g. YUV420)
virtual bool hasMixedResolutions() const { return false; }
@ -116,11 +116,11 @@ protected:
friend class GrTextureProducer_TestAccess;
GrTextureProducer(GrRecordingContext* context, int width, int height,
const GrColorSpaceInfo& csInfo, bool domainNeedsDecal)
const GrColorInfo& colorInfo, bool domainNeedsDecal)
: fContext(context)
, fWidth(width)
, fHeight(height)
, fColorSpaceInfo(csInfo)
, fColorInfo(colorInfo)
, fDomainNeedsDecal(domainNeedsDecal) {}
/** Helper for creating a key for a copy from an original key. */
@ -191,7 +191,7 @@ private:
GrRecordingContext* fContext;
const int fWidth;
const int fHeight;
const GrColorSpaceInfo fColorSpaceInfo;
const GrColorInfo fColorInfo;
// If true, any domain effect uses kDecal instead of kClamp, and sampler filter uses
// kClampToBorder instead of kClamp.
const bool fDomainNeedsDecal;

View File

@ -87,7 +87,7 @@ sk_sp<SkGpuDevice> SkGpuDevice::Make(GrContext* context,
return nullptr;
}
SkColorType ct = GrColorTypeToSkColorType(renderTargetContext->colorSpaceInfo().colorType());
SkColorType ct = GrColorTypeToSkColorType(renderTargetContext->colorInfo().colorType());
unsigned flags;
if (!context->colorTypeSupportedAsSurface(ct) ||
@ -117,10 +117,10 @@ sk_sp<SkGpuDevice> SkGpuDevice::Make(GrContext* context, SkBudgeted budgeted,
}
static SkImageInfo make_info(GrRenderTargetContext* context, bool opaque) {
SkColorType colorType = GrColorTypeToSkColorType(context->colorSpaceInfo().colorType());
SkColorType colorType = GrColorTypeToSkColorType(context->colorInfo().colorType());
return SkImageInfo::Make(context->width(), context->height(), colorType,
opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType,
context->colorSpaceInfo().refColorSpace());
context->colorInfo().refColorSpace());
}
SkGpuDevice::SkGpuDevice(GrContext* context,
@ -166,13 +166,12 @@ sk_sp<SkSpecialImage> SkGpuDevice::filterTexture(SkSpecialImage* srcImg,
matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top));
const SkIRect clipBounds = this->devClipBounds().makeOffset(-left, -top);
sk_sp<SkImageFilterCache> cache(this->getImageFilterCache());
SkColorType colorType =
GrColorTypeToSkColorType(fRenderTargetContext->colorSpaceInfo().colorType());
SkColorType colorType = GrColorTypeToSkColorType(fRenderTargetContext->colorInfo().colorType());
if (colorType == kUnknown_SkColorType) {
colorType = kRGBA_8888_SkColorType;
}
SkImageFilter_Base::Context ctx(matrix, clipBounds, cache.get(), colorType,
fRenderTargetContext->colorSpaceInfo().colorSpace(), srcImg);
fRenderTargetContext->colorInfo().colorSpace(), srcImg);
return as_IFB(filter)->filterImage(ctx).imageAndOffset(offset);
}
@ -265,8 +264,8 @@ void SkGpuDevice::drawPaint(const SkPaint& paint) {
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPaint", fContext.get());
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint,
this->ctm(), &grPaint)) {
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint, this->ctm(),
&grPaint)) {
return;
}
@ -297,7 +296,7 @@ void SkGpuDevice::drawPoints(SkCanvas::PointMode mode,
if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mode) {
GrStyle style(paint, SkPaint::kStroke_Style);
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint,
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint,
this->ctm(), &grPaint)) {
return;
}
@ -342,8 +341,8 @@ void SkGpuDevice::drawPoints(SkCanvas::PointMode mode,
#endif
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint,
*viewMatrix, &grPaint)) {
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint, *viewMatrix,
&grPaint)) {
return;
}
@ -373,8 +372,8 @@ void SkGpuDevice::drawRect(const SkRect& rect, const SkPaint& paint) {
}
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint,
this->ctm(), &grPaint)) {
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint, this->ctm(),
&grPaint)) {
return;
}
@ -388,8 +387,7 @@ void SkGpuDevice::drawEdgeAAQuad(const SkRect& rect, const SkPoint clip[4],
ASSERT_SINGLE_OWNER
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawEdgeAAQuad", fContext.get());
SkPMColor4f dstColor =
SkColor4fPrepForDst(color, fRenderTargetContext->colorSpaceInfo()).premul();
SkPMColor4f dstColor = SkColor4fPrepForDst(color, fRenderTargetContext->colorInfo()).premul();
GrPaint grPaint;
grPaint.setColor4f(dstColor);
@ -437,8 +435,8 @@ void SkGpuDevice::drawRRect(const SkRRect& rrect, const SkPaint& paint) {
SkASSERT(!style.pathEffect());
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint,
this->ctm(), &grPaint)) {
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint, this->ctm(),
&grPaint)) {
return;
}
@ -462,7 +460,7 @@ void SkGpuDevice::drawDRRect(const SkRRect& outer, const SkRRect& inner, const S
if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect()) {
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint,
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint,
this->ctm(), &grPaint)) {
return;
}
@ -498,8 +496,8 @@ void SkGpuDevice::drawRegion(const SkRegion& region, const SkPaint& paint) {
}
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint,
this->ctm(), &grPaint)) {
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint, this->ctm(),
&grPaint)) {
return;
}
@ -518,8 +516,8 @@ void SkGpuDevice::drawOval(const SkRect& oval, const SkPaint& paint) {
}
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint,
this->ctm(), &grPaint)) {
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint, this->ctm(),
&grPaint)) {
return;
}
@ -536,8 +534,8 @@ void SkGpuDevice::drawArc(const SkRect& oval, SkScalar startAngle,
return;
}
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint,
this->ctm(), &grPaint)) {
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint, this->ctm(),
&grPaint)) {
return;
}
@ -592,7 +590,7 @@ void SkGpuDevice::drawStrokedLine(const SkPoint points[2],
m.postConcat(this->ctm());
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), newPaint, m,
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), newPaint, m,
&grPaint)) {
return;
}
@ -622,7 +620,7 @@ void SkGpuDevice::drawPath(const SkPath& origSrcPath, const SkPaint& paint, bool
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawPath", fContext.get());
if (!paint.getMaskFilter()) {
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), paint,
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), paint,
this->ctm(), &grPaint)) {
return;
}
@ -969,9 +967,9 @@ void SkGpuDevice::drawBitmapTile(const SkBitmap& bitmap,
}
fp = GrColorSpaceXformEffect::Make(std::move(fp), bitmap.colorSpace(), bitmap.alphaType(),
fRenderTargetContext->colorSpaceInfo().colorSpace());
fRenderTargetContext->colorInfo().colorSpace());
GrPaint grPaint;
if (!SkPaintToGrPaintWithTexture(this->context(), fRenderTargetContext->colorSpaceInfo(), paint,
if (!SkPaintToGrPaintWithTexture(this->context(), fRenderTargetContext->colorInfo(), paint,
viewMatrix, std::move(fp),
kAlpha_8_SkColorType == bitmap.colorType(), &grPaint)) {
return;
@ -1040,7 +1038,7 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special, int left, int top, const
auto fp = GrSimpleTextureEffect::Make(std::move(proxy), SkMatrix::I());
fp = GrColorSpaceXformEffect::Make(std::move(fp), result->getColorSpace(), result->alphaType(),
fRenderTargetContext->colorSpaceInfo().colorSpace());
fRenderTargetContext->colorInfo().colorSpace());
if (GrPixelConfigIsAlphaOnly(config)) {
fp = GrFragmentProcessor::MakeInputPremulAndMulByOutput(std::move(fp));
} else {
@ -1052,7 +1050,7 @@ void SkGpuDevice::drawSpecial(SkSpecialImage* special, int left, int top, const
}
GrPaint grPaint;
if (!SkPaintToGrPaintReplaceShader(this->context(), fRenderTargetContext->colorSpaceInfo(),
if (!SkPaintToGrPaintReplaceShader(this->context(), fRenderTargetContext->colorInfo(),
tmpUnfiltered, std::move(fp), &grPaint)) {
return;
}
@ -1351,12 +1349,12 @@ void SkGpuDevice::drawProducerLattice(GrTextureProducer* producer,
paint.writable()->setColor(SkColorSetARGB(origPaint.getAlpha(), 0xFF, 0xFF, 0xFF));
}
GrPaint grPaint;
if (!SkPaintToGrPaintWithPrimitiveColor(this->context(), fRenderTargetContext->colorSpaceInfo(),
if (!SkPaintToGrPaintWithPrimitiveColor(this->context(), fRenderTargetContext->colorInfo(),
*paint, &grPaint)) {
return;
}
auto dstColorSpace = fRenderTargetContext->colorSpaceInfo().colorSpace();
auto dstColorSpace = fRenderTargetContext->colorInfo().colorSpace();
const GrSamplerState::Filter filter = compute_lattice_filter_mode(*paint);
auto proxy = producer->refTextureProxyForParams(&filter, nullptr);
if (!proxy) {
@ -1403,26 +1401,26 @@ void SkGpuDevice::drawBitmapLattice(const SkBitmap& bitmap,
this->drawProducerLattice(&maker, std::move(iter), dst, paint);
}
static bool init_vertices_paint(GrContext* context, const GrColorSpaceInfo& colorSpaceInfo,
static bool init_vertices_paint(GrContext* context, const GrColorInfo& colorInfo,
const SkPaint& skPaint, const SkMatrix& matrix, SkBlendMode bmode,
bool hasTexs, bool hasColors, GrPaint* grPaint) {
if (hasTexs && skPaint.getShader()) {
if (hasColors) {
// When there are texs and colors the shader and colors are combined using bmode.
return SkPaintToGrPaintWithXfermode(context, colorSpaceInfo, skPaint, matrix, bmode,
return SkPaintToGrPaintWithXfermode(context, colorInfo, skPaint, matrix, bmode,
grPaint);
} else {
// We have a shader, but no colors to blend it against.
return SkPaintToGrPaint(context, colorSpaceInfo, skPaint, matrix, grPaint);
return SkPaintToGrPaint(context, colorInfo, skPaint, matrix, grPaint);
}
} else {
if (hasColors) {
// We have colors, but either have no shader or no texture coords (which implies that
// we should ignore the shader).
return SkPaintToGrPaintWithPrimitiveColor(context, colorSpaceInfo, skPaint, grPaint);
return SkPaintToGrPaintWithPrimitiveColor(context, colorInfo, skPaint, grPaint);
} else {
// No colors and no shaders. Just draw with the paint color.
return SkPaintToGrPaintNoShader(context, colorSpaceInfo, skPaint, grPaint);
return SkPaintToGrPaintNoShader(context, colorInfo, skPaint, grPaint);
}
}
}
@ -1442,7 +1440,7 @@ void SkGpuDevice::wireframeVertices(SkVertices::VertexMode vmode, int vertexCoun
GrPaint grPaint;
// we ignore the shader since we have no texture coordinates.
if (!SkPaintToGrPaintNoShader(this->context(), fRenderTargetContext->colorSpaceInfo(), copy,
if (!SkPaintToGrPaintNoShader(this->context(), fRenderTargetContext->colorInfo(), copy,
&grPaint)) {
return;
}
@ -1509,8 +1507,8 @@ void SkGpuDevice::drawVertices(const SkVertices* vertices, const SkVertices::Bon
paint);
return;
}
if (!init_vertices_paint(fContext.get(), fRenderTargetContext->colorSpaceInfo(), paint,
this->ctm(), mode, hasTexs, hasColors, &grPaint)) {
if (!init_vertices_paint(fContext.get(), fRenderTargetContext->colorInfo(), paint, this->ctm(),
mode, hasTexs, hasColors, &grPaint)) {
return;
}
fRenderTargetContext->drawVertices(this->clip(), std::move(grPaint), this->ctm(),
@ -1544,13 +1542,13 @@ void SkGpuDevice::drawAtlas(const SkImage* atlas, const SkRSXform xform[],
GrPaint grPaint;
if (colors) {
if (!SkPaintToGrPaintWithXfermode(this->context(), fRenderTargetContext->colorSpaceInfo(),
p, this->ctm(), (SkBlendMode)mode, &grPaint)) {
if (!SkPaintToGrPaintWithXfermode(this->context(), fRenderTargetContext->colorInfo(), p,
this->ctm(), (SkBlendMode)mode, &grPaint)) {
return;
}
} else {
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorSpaceInfo(), p,
this->ctm(), &grPaint)) {
if (!SkPaintToGrPaint(this->context(), fRenderTargetContext->colorInfo(), p, this->ctm(),
&grPaint)) {
return;
}
}
@ -1631,7 +1629,7 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
cinfo.fInfo.width(),
cinfo.fInfo.height(),
SkColorTypeToGrColorType(cinfo.fInfo.colorType()),
fRenderTargetContext->colorSpaceInfo().refColorSpace(),
fRenderTargetContext->colorInfo().refColorSpace(),
fRenderTargetContext->numSamples(),
GrMipMapped::kNo,
kBottomLeft_GrSurfaceOrigin,

View File

@ -176,7 +176,7 @@ static void draw_texture(GrRenderTargetContext* rtc, const GrClip& clip, const S
const SkPoint dstClip[4], GrAA aa, GrQuadAAFlags aaFlags,
SkCanvas::SrcRectConstraint constraint, sk_sp<GrTextureProxy> proxy,
SkAlphaType alphaType, SkColorSpace* colorSpace) {
const GrColorSpaceInfo& dstInfo(rtc->colorSpaceInfo());
const GrColorInfo& dstInfo(rtc->colorInfo());
auto textureXform =
GrColorSpaceXform::Make(colorSpace , alphaType,
dstInfo.colorSpace(), kPremul_SkAlphaType);
@ -304,14 +304,14 @@ static void draw_texture_producer(GrContext* context, GrRenderTargetContext* rtc
auto fp = producer->createFragmentProcessor(textureMatrix, src, constraintMode,
coordsAllInsideSrcRect, filterMode);
fp = GrColorSpaceXformEffect::Make(std::move(fp), producer->colorSpace(), producer->alphaType(),
rtc->colorSpaceInfo().colorSpace());
rtc->colorInfo().colorSpace());
if (!fp) {
return;
}
GrPaint grPaint;
if (!SkPaintToGrPaintWithTexture(context, rtc->colorSpaceInfo(), paint, ctm,
std::move(fp), producer->isAlphaOnly(), &grPaint)) {
if (!SkPaintToGrPaintWithTexture(context, rtc->colorInfo(), paint, ctm, std::move(fp),
producer->isAlphaOnly(), &grPaint)) {
return;
}
@ -496,7 +496,7 @@ void SkGpuDevice::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[], int co
if (n > 0) {
auto textureXform = GrColorSpaceXform::Make(
set[base].fImage->colorSpace(), set[base].fImage->alphaType(),
fRenderTargetContext->colorSpaceInfo().colorSpace(), kPremul_SkAlphaType);
fRenderTargetContext->colorInfo().colorSpace(), kPremul_SkAlphaType);
fRenderTargetContext->drawTextureSet(this->clip(), textures.get() + base, n,
filter, mode, GrAA::kYes, constraint, this->ctm(),
std::move(textureXform));

View File

@ -213,16 +213,16 @@ sk_sp<GrTextureProxy> GrMakeCachedImageProxy(GrProxyProvider* proxyProvider,
///////////////////////////////////////////////////////////////////////////////
SkPMColor4f SkColorToPMColor4f(SkColor c, const GrColorSpaceInfo& colorSpaceInfo) {
SkPMColor4f SkColorToPMColor4f(SkColor c, const GrColorInfo& colorInfo) {
SkColor4f color = SkColor4f::FromColor(c);
if (auto* xform = colorSpaceInfo.colorSpaceXformFromSRGB()) {
if (auto* xform = colorInfo.colorSpaceXformFromSRGB()) {
color = xform->apply(color);
}
return color.premul();
}
SkColor4f SkColor4fPrepForDst(SkColor4f color, const GrColorSpaceInfo& colorSpaceInfo) {
if (auto* xform = colorSpaceInfo.colorSpaceXformFromSRGB()) {
SkColor4f SkColor4fPrepForDst(SkColor4f color, const GrColorInfo& colorInfo) {
if (auto* xform = colorInfo.colorSpaceXformFromSRGB()) {
color = xform->apply(color);
}
return color;
@ -330,16 +330,16 @@ static inline int32_t dither_range_type_for_config(GrColorType dstColorType) {
#endif
static inline bool skpaint_to_grpaint_impl(GrRecordingContext* context,
const GrColorSpaceInfo& colorSpaceInfo,
const GrColorInfo& dstColorInfo,
const SkPaint& skPaint,
const SkMatrix& viewM,
std::unique_ptr<GrFragmentProcessor>* shaderProcessor,
SkBlendMode* primColorMode,
GrPaint* grPaint) {
// Convert SkPaint color to 4f format in the destination color space
SkColor4f origColor = SkColor4fPrepForDst(skPaint.getColor4f(), colorSpaceInfo);
SkColor4f origColor = SkColor4fPrepForDst(skPaint.getColor4f(), dstColorInfo);
GrFPArgs fpArgs(context, &viewM, skPaint.getFilterQuality(), &colorSpaceInfo);
GrFPArgs fpArgs(context, &viewM, skPaint.getFilterQuality(), &dstColorInfo);
// Setup the initial color considering the shader, the SkPaint color, and the presence or not
// of per-vertex colors.
@ -428,10 +428,10 @@ static inline bool skpaint_to_grpaint_impl(GrRecordingContext* context,
SkColorFilter* colorFilter = skPaint.getColorFilter();
if (colorFilter) {
if (applyColorFilterToPaintColor) {
SkColorSpace* dstCS = colorSpaceInfo.colorSpace();
SkColorSpace* dstCS = dstColorInfo.colorSpace();
grPaint->setColor4f(colorFilter->filterColor4f(origColor, dstCS, dstCS).premul());
} else {
auto cfFP = colorFilter->asFragmentProcessor(context, colorSpaceInfo);
auto cfFP = colorFilter->asFragmentProcessor(context, dstColorInfo);
if (cfFP) {
grPaint->addColorFragmentProcessor(std::move(cfFP));
} else {
@ -458,7 +458,7 @@ static inline bool skpaint_to_grpaint_impl(GrRecordingContext* context,
#ifndef SK_IGNORE_GPU_DITHER
// Conservative default, in case GrPixelConfigToColorType() fails.
GrColorType ct = colorSpaceInfo.colorType();
GrColorType ct = dstColorInfo.colorType();
if (SkPaintPriv::ShouldDither(skPaint, GrColorTypeToSkColorType(ct)) &&
grPaint->numColorFragmentProcessors() > 0) {
int32_t ditherRange = dither_range_type_for_config(ct);
@ -472,7 +472,7 @@ static inline bool skpaint_to_grpaint_impl(GrRecordingContext* context,
}
}
#endif
if (GrColorTypeClampType(colorSpaceInfo.colorType()) == GrClampType::kManual) {
if (GrColorTypeClampType(dstColorInfo.colorType()) == GrClampType::kManual) {
if (grPaint->numColorFragmentProcessors()) {
grPaint->addColorFragmentProcessor(GrSaturateProcessor::Make());
} else {
@ -486,50 +486,50 @@ static inline bool skpaint_to_grpaint_impl(GrRecordingContext* context,
return true;
}
bool SkPaintToGrPaint(GrRecordingContext* context, const GrColorSpaceInfo& colorSpaceInfo,
bool SkPaintToGrPaint(GrRecordingContext* context, const GrColorInfo& dstColorInfo,
const SkPaint& skPaint, const SkMatrix& viewM, GrPaint* grPaint) {
return skpaint_to_grpaint_impl(context, colorSpaceInfo, skPaint, viewM, nullptr, nullptr,
return skpaint_to_grpaint_impl(context, dstColorInfo, skPaint, viewM, nullptr, nullptr,
grPaint);
}
/** Replaces the SkShader (if any) on skPaint with the passed in GrFragmentProcessor. */
bool SkPaintToGrPaintReplaceShader(GrRecordingContext* context,
const GrColorSpaceInfo& colorSpaceInfo,
const GrColorInfo& dstColorInfo,
const SkPaint& skPaint,
std::unique_ptr<GrFragmentProcessor> shaderFP,
GrPaint* grPaint) {
if (!shaderFP) {
return false;
}
return skpaint_to_grpaint_impl(context, colorSpaceInfo, skPaint, SkMatrix::I(), &shaderFP,
return skpaint_to_grpaint_impl(context, dstColorInfo, skPaint, SkMatrix::I(), &shaderFP,
nullptr, grPaint);
}
/** Ignores the SkShader (if any) on skPaint. */
bool SkPaintToGrPaintNoShader(GrRecordingContext* context,
const GrColorSpaceInfo& colorSpaceInfo,
const GrColorInfo& dstColorInfo,
const SkPaint& skPaint,
GrPaint* grPaint) {
// Use a ptr to a nullptr to to indicate that the SkShader is ignored and not replaced.
std::unique_ptr<GrFragmentProcessor> nullShaderFP(nullptr);
return skpaint_to_grpaint_impl(context, colorSpaceInfo, skPaint, SkMatrix::I(), &nullShaderFP,
return skpaint_to_grpaint_impl(context, dstColorInfo, skPaint, SkMatrix::I(), &nullShaderFP,
nullptr, grPaint);
}
/** Blends the SkPaint's shader (or color if no shader) with a per-primitive color which must
be setup as a vertex attribute using the specified SkBlendMode. */
bool SkPaintToGrPaintWithXfermode(GrRecordingContext* context,
const GrColorSpaceInfo& colorSpaceInfo,
const GrColorInfo& dstColorInfo,
const SkPaint& skPaint,
const SkMatrix& viewM,
SkBlendMode primColorMode,
GrPaint* grPaint) {
return skpaint_to_grpaint_impl(context, colorSpaceInfo, skPaint, viewM, nullptr, &primColorMode,
return skpaint_to_grpaint_impl(context, dstColorInfo, skPaint, viewM, nullptr, &primColorMode,
grPaint);
}
bool SkPaintToGrPaintWithTexture(GrRecordingContext* context,
const GrColorSpaceInfo& colorSpaceInfo,
const GrColorInfo& dstColorInfo,
const SkPaint& paint,
const SkMatrix& viewM,
std::unique_ptr<GrFragmentProcessor> fp,
@ -538,8 +538,8 @@ bool SkPaintToGrPaintWithTexture(GrRecordingContext* context,
std::unique_ptr<GrFragmentProcessor> shaderFP;
if (textureIsAlphaOnly) {
if (const auto* shader = as_SB(paint.getShader())) {
shaderFP = shader->asFragmentProcessor(GrFPArgs(
context, &viewM, paint.getFilterQuality(), &colorSpaceInfo));
shaderFP = shader->asFragmentProcessor(
GrFPArgs(context, &viewM, paint.getFilterQuality(), &dstColorInfo));
if (!shaderFP) {
return false;
}
@ -556,11 +556,10 @@ bool SkPaintToGrPaintWithTexture(GrRecordingContext* context,
}
}
return SkPaintToGrPaintReplaceShader(context, colorSpaceInfo, paint, std::move(shaderFP),
return SkPaintToGrPaintReplaceShader(context, dstColorInfo, paint, std::move(shaderFP),
grPaint);
}
////////////////////////////////////////////////////////////////////////////////////////////////
GrSamplerState::Filter GrSkFilterQualityToGrFilterMode(int imageWidth, int imageHeight,

View File

@ -23,7 +23,7 @@
#include "src/gpu/GrSamplerState.h"
class GrCaps;
class GrColorSpaceInfo;
class GrColorInfo;
class GrColorSpaceXform;
class GrContext;
class GrFragmentProcessor;
@ -60,10 +60,10 @@ static inline GrColor SkColorToUnpremulGrColor(SkColor c) {
}
/** Similar, but using SkPMColor4f. */
SkPMColor4f SkColorToPMColor4f(SkColor, const GrColorSpaceInfo&);
SkPMColor4f SkColorToPMColor4f(SkColor, const GrColorInfo&);
/** Converts an SkColor4f to the destination color space. */
SkColor4f SkColor4fPrepForDst(SkColor4f, const GrColorSpaceInfo&);
SkColor4f SkColor4fPrepForDst(SkColor4f, const GrColorInfo&);
/** Returns true if half-floats are required to store the color in a vertex (and half-floats
are supported). */
@ -80,14 +80,14 @@ static inline bool SkPMColor4fNeedsWideColor(SkPMColor4f color, GrClampType clam
/** Converts an SkPaint to a GrPaint for a given GrRecordingContext. The matrix is required in order
to convert the SkShader (if any) on the SkPaint. The primitive itself has no color. */
bool SkPaintToGrPaint(GrRecordingContext*,
const GrColorSpaceInfo& dstColorSpaceInfo,
const GrColorInfo& dstColorInfo,
const SkPaint& skPaint,
const SkMatrix& viewM,
GrPaint* grPaint);
/** Same as above but ignores the SkShader (if any) on skPaint. */
bool SkPaintToGrPaintNoShader(GrRecordingContext*,
const GrColorSpaceInfo& dstColorSpaceInfo,
const GrColorInfo& dstColorInfo,
const SkPaint& skPaint,
GrPaint* grPaint);
@ -95,7 +95,7 @@ bool SkPaintToGrPaintNoShader(GrRecordingContext*,
should expect an unpremul input color and produce a premultiplied output color. There is
no primitive color. */
bool SkPaintToGrPaintReplaceShader(GrRecordingContext*,
const GrColorSpaceInfo& dstColorSpaceInfo,
const GrColorInfo& dstColorInfo,
const SkPaint& skPaint,
std::unique_ptr<GrFragmentProcessor> shaderFP,
GrPaint* grPaint);
@ -103,7 +103,7 @@ bool SkPaintToGrPaintReplaceShader(GrRecordingContext*,
/** Blends the SkPaint's shader (or color if no shader) with the color which specified via a
GrOp's GrPrimitiveProcesssor. */
bool SkPaintToGrPaintWithXfermode(GrRecordingContext*,
const GrColorSpaceInfo& dstColorSpaceInfo,
const GrColorInfo& dstColorInfo,
const SkPaint& skPaint,
const SkMatrix& viewM,
SkBlendMode primColorMode,
@ -114,17 +114,17 @@ bool SkPaintToGrPaintWithXfermode(GrRecordingContext*,
unpremultiplied so that interpolation is done in unpremul space. The paint's alpha will be
applied to the primitive color after interpolation. */
inline bool SkPaintToGrPaintWithPrimitiveColor(GrRecordingContext* context,
const GrColorSpaceInfo& dstColorSpaceInfo,
const GrColorInfo& dstColorInfo,
const SkPaint& skPaint,
GrPaint* grPaint) {
return SkPaintToGrPaintWithXfermode(context, dstColorSpaceInfo, skPaint, SkMatrix::I(),
return SkPaintToGrPaintWithXfermode(context, dstColorInfo, skPaint, SkMatrix::I(),
SkBlendMode::kDst, grPaint);
}
/** This is used when there may or may not be a shader, and the caller wants to plugin a texture
lookup. If there is a shader, then its output will only be used if the texture is alpha8. */
bool SkPaintToGrPaintWithTexture(GrRecordingContext*,
const GrColorSpaceInfo& dstColorSpaceInfo,
const GrColorInfo& dstColorInfo,
const SkPaint& skPaint,
const SkMatrix& viewM,
std::unique_ptr<GrFragmentProcessor> fp,

View File

@ -77,8 +77,8 @@ uniform half blurRadius;
auto rtc2 =
SkGpuBlurUtils::GaussianBlur(context,
std::move(srcProxy),
rtc->colorSpaceInfo().colorType(),
rtc->colorSpaceInfo().alphaType(),
rtc->colorInfo().colorType(),
rtc->colorInfo().alphaType(),
SkIPoint::Make(0, 0),
nullptr,
SkIRect::MakeWH(size.fWidth, size.fHeight),

View File

@ -77,8 +77,8 @@ public:
}
auto rtc2 = SkGpuBlurUtils::GaussianBlur(context,
std::move(srcProxy),
rtc->colorSpaceInfo().colorType(),
rtc->colorSpaceInfo().alphaType(),
rtc->colorInfo().colorType(),
rtc->colorInfo().alphaType(),
SkIPoint::Make(0, 0),
nullptr,
SkIRect::MakeWH(size.fWidth, size.fHeight),

View File

@ -24,7 +24,7 @@
#include "include/private/GrRecordingContext.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrColor.h"
#include "src/gpu/GrColorSpaceInfo.h"
#include "src/gpu/GrColorInfo.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/SkGr.h"
@ -45,7 +45,7 @@ static std::unique_ptr<GrFragmentProcessor> make_textured_colorizer(const SkPMCo
// Use 8888 or F16, depending on the destination config.
// TODO: Use 1010102 for opaque gradients, at least if destination is 1010102?
SkColorType colorType = kRGBA_8888_SkColorType;
if (GrColorTypeIsWiderThan(args.fDstColorSpaceInfo->colorType(), 8)) {
if (GrColorTypeIsWiderThan(args.fDstColorInfo->colorType(), 8)) {
auto f16Format = args.fContext->priv().caps()->getDefaultBackendFormat(
GrColorType::kRGBA_F16, GrRenderable::kNo);
if (f16Format.isValid()) {
@ -167,7 +167,7 @@ static std::unique_ptr<GrFragmentProcessor> make_gradient(const SkGradientShader
bool allOpaque = true;
SkAutoSTMalloc<4, SkPMColor4f> colors(shader.fColorCount);
SkColor4fXformer xformedColors(shader.fOrigColors4f, shader.fColorCount,
shader.fColorSpace.get(), args.fDstColorSpaceInfo->colorSpace());
shader.fColorSpace.get(), args.fDstColorInfo->colorSpace());
for (int i = 0; i < shader.fColorCount; i++) {
const SkColor4f& upmColor = xformedColors.fColors[i];
colors[i] = inputPremul ? upmColor.premul()

View File

@ -176,8 +176,7 @@ inline std::unique_ptr<GrAtlasTextOp> GrTextBlob::makeOp(
// TODO: Can we be even smarter based on the dest transfer function?
op = GrAtlasTextOp::MakeDistanceField(
target->getContext(), std::move(grPaint), glyphCount, distanceAdjustTable,
target->colorSpaceInfo().isLinearlyBlended(),
SkPaintPriv::ComputeLuminanceColor(paint),
target->colorInfo().isLinearlyBlended(), SkPaintPriv::ComputeLuminanceColor(paint),
props, info.isAntiAliased(), info.hasUseLCDText());
} else {
op = GrAtlasTextOp::MakeBitmap(target->getContext(), std::move(grPaint), format, glyphCount,

View File

@ -70,12 +70,11 @@ SkColor GrTextContext::ComputeCanonicalColor(const SkPaint& paint, bool lcd) {
return canonicalColor;
}
SkScalerContextFlags GrTextContext::ComputeScalerContextFlags(
const GrColorSpaceInfo& colorSpaceInfo) {
SkScalerContextFlags GrTextContext::ComputeScalerContextFlags(const GrColorInfo& colorInfo) {
// If we're doing linear blending, then we can disable the gamma hacks.
// Otherwise, leave them on. In either case, we still want the contrast boost:
// TODO: Can we be even smarter about mask gamma based on the dest transfer function?
if (colorSpaceInfo.isLinearlyBlended()) {
if (colorInfo.isLinearlyBlended()) {
return SkScalerContextFlags::kBoostContrast;
} else {
return SkScalerContextFlags::kFakeGammaAndBoostContrast;

View File

@ -80,7 +80,7 @@ private:
// sets up the descriptor on the blob and returns a detached cache. Client must attach
static SkColor ComputeCanonicalColor(const SkPaint&, bool lcd);
// Determines if we need to use fake gamma (and contrast boost):
static SkScalerContextFlags ComputeScalerContextFlags(const GrColorSpaceInfo&);
static SkScalerContextFlags ComputeScalerContextFlags(const GrColorInfo&);
const GrDistanceFieldAdjustTable* dfAdjustTable() const { return fDistanceAdjustTable.get(); }

View File

@ -9,7 +9,7 @@
#define GrTextTarget_DEFINED
#include "include/core/SkPaint.h"
#include "src/gpu/GrColorSpaceInfo.h"
#include "src/gpu/GrColorInfo.h"
class GrAtlasTextOp;
class GrClip;
@ -28,7 +28,7 @@ public:
int height() const { return fHeight; }
const GrColorSpaceInfo& colorSpaceInfo() const { return fColorSpaceInfo; }
const GrColorInfo& colorInfo() const { return fColorInfo; }
virtual void addDrawOp(const GrClip&, std::unique_ptr<GrAtlasTextOp> op) = 0;
@ -43,14 +43,14 @@ public:
virtual SkGlyphRunListPainter* glyphPainter() = 0;
protected:
GrTextTarget(int width, int height, const GrColorSpaceInfo& colorSpaceInfo)
: fWidth(width), fHeight(height), fColorSpaceInfo(colorSpaceInfo) {
SkASSERT(kPremul_SkAlphaType == colorSpaceInfo.alphaType());
GrTextTarget(int width, int height, const GrColorInfo& colorInfo)
: fWidth(width), fHeight(height), fColorInfo(colorInfo) {
SkASSERT(kPremul_SkAlphaType == colorInfo.alphaType());
}
private:
int fWidth;
int fHeight;
const GrColorSpaceInfo& fColorSpaceInfo;
const GrColorInfo& fColorInfo;
};
#endif // GrTextTarget_DEFINED

View File

@ -83,13 +83,13 @@ bool GrVkSecondaryCBDrawContext::characterize(SkSurfaceCharacterization* charact
// We current don't support textured GrVkSecondaryCBDrawContexts.
SkASSERT(!rtc->asTextureProxy());
SkColorType ct = GrColorTypeToSkColorType(rtc->colorSpaceInfo().colorType());
SkColorType ct = GrColorTypeToSkColorType(rtc->colorInfo().colorType());
if (ct == kUnknown_SkColorType) {
return false;
}
SkImageInfo ii = SkImageInfo::Make(rtc->width(), rtc->height(), ct, kPremul_SkAlphaType,
rtc->colorSpaceInfo().refColorSpace());
rtc->colorInfo().refColorSpace());
GrBackendFormat format = rtc->asRenderTargetProxy()->backendFormat();
@ -132,7 +132,7 @@ bool GrVkSecondaryCBDrawContext::isCompatible(
return false;
}
SkColorType rtColorType = GrColorTypeToSkColorType(rtc->colorSpaceInfo().colorType());
SkColorType rtColorType = GrColorTypeToSkColorType(rtc->colorInfo().colorType());
if (rtColorType == kUnknown_SkColorType) {
return false;
}
@ -148,8 +148,7 @@ bool GrVkSecondaryCBDrawContext::isCompatible(
characterization.height() == rtc->height() &&
characterization.colorType() == rtColorType &&
characterization.sampleCount() == rtc->numSamples() &&
SkColorSpace::Equals(characterization.colorSpace(),
rtc->colorSpaceInfo().colorSpace()) &&
SkColorSpace::Equals(characterization.colorSpace(), rtc->colorInfo().colorSpace()) &&
characterization.isProtected() == isProtected &&
characterization.surfaceProps() == rtc->surfaceProps();
}

View File

@ -228,7 +228,7 @@ sk_sp<SkImage> SkImage_Gpu::ConvertYUVATexturesToRGB(GrContext* ctx, SkYUVColorS
// MDB: this call is okay bc we know 'renderTargetContext' was exact
return sk_make_sp<SkImage_Gpu>(sk_ref_sp(ctx), kNeedNewImageUniqueID, at,
renderTargetContext->asTextureProxyRef(),
renderTargetContext->colorSpaceInfo().refColorSpace());
renderTargetContext->colorInfo().refColorSpace());
}
sk_sp<SkImage> SkImage::MakeFromYUVATexturesCopy(GrContext* ctx,

View File

@ -193,7 +193,7 @@ bool SkSurface_Gpu::onCharacterize(SkSurfaceCharacterization* characterization)
bool mipmapped = rtc->asTextureProxy() ? GrMipMapped::kYes == rtc->asTextureProxy()->mipMapped()
: false;
SkColorType ct = GrColorTypeToSkColorType(rtc->colorSpaceInfo().colorType());
SkColorType ct = GrColorTypeToSkColorType(rtc->colorInfo().colorType());
if (ct == kUnknown_SkColorType) {
return false;
}
@ -204,7 +204,7 @@ bool SkSurface_Gpu::onCharacterize(SkSurfaceCharacterization* characterization)
SkASSERT(!usesGLFBO0 || !SkToBool(rtc->asTextureProxy()));
SkImageInfo ii = SkImageInfo::Make(rtc->width(), rtc->height(), ct, kPremul_SkAlphaType,
rtc->colorSpaceInfo().refColorSpace());
rtc->colorInfo().refColorSpace());
GrBackendFormat format = rtc->asSurfaceProxy()->backendFormat();
@ -292,7 +292,7 @@ bool SkSurface_Gpu::onIsCompatible(const SkSurfaceCharacterization& characteriza
return false;
}
SkColorType rtcColorType = GrColorTypeToSkColorType(rtc->colorSpaceInfo().colorType());
SkColorType rtcColorType = GrColorTypeToSkColorType(rtc->colorInfo().colorType());
if (rtcColorType == kUnknown_SkColorType) {
return false;
}
@ -303,12 +303,10 @@ bool SkSurface_Gpu::onIsCompatible(const SkSurfaceCharacterization& characteriza
characterization.cacheMaxResourceBytes() <= maxResourceBytes &&
characterization.origin() == rtc->origin() &&
characterization.backendFormat() == rtc->asSurfaceProxy()->backendFormat() &&
characterization.width() == rtc->width() &&
characterization.height() == rtc->height() &&
characterization.width() == rtc->width() && characterization.height() == rtc->height() &&
characterization.colorType() == rtcColorType &&
characterization.sampleCount() == rtc->numSamples() &&
SkColorSpace::Equals(characterization.colorSpace(),
rtc->colorSpaceInfo().colorSpace()) &&
SkColorSpace::Equals(characterization.colorSpace(), rtc->colorInfo().colorSpace()) &&
characterization.isProtected() == isProtected &&
characterization.surfaceProps() == rtc->surfaceProps();
}
@ -563,20 +561,20 @@ bool SkSurface_Gpu::onReplaceBackendTexture(const GrBackendTexture& backendTextu
SkASSERT(oldTexture->asRenderTarget());
int sampleCnt = oldTexture->asRenderTarget()->numSamples();
GrColorType grColorType = SkColorTypeToGrColorType(this->getCanvas()->imageInfo().colorType());
auto colorSpace = sk_ref_sp(oldRTC->colorSpaceInfo().colorSpace());
auto colorSpace = sk_ref_sp(oldRTC->colorInfo().colorSpace());
if (!validate_backend_texture(context->priv().caps(), backendTexture,
sampleCnt, grColorType, true)) {
return false;
}
auto rtc = context->priv().makeBackendTextureRenderTargetContext(
backendTexture,
origin,
sampleCnt,
oldRTC->colorSpaceInfo().colorType(),
std::move(colorSpace),
&this->props(),
releaseProc,
releaseContext);
auto rtc =
context->priv().makeBackendTextureRenderTargetContext(backendTexture,
origin,
sampleCnt,
oldRTC->colorInfo().colorType(),
std::move(colorSpace),
&this->props(),
releaseProc,
releaseContext);
if (!rtc) {
return false;
}

View File

@ -58,7 +58,7 @@ std::unique_ptr<GrFragmentProcessor> SkColorFilterShader::asFragmentProcessor(
return nullptr;
}
auto fp2 = fFilter->asFragmentProcessor(args.fContext, *args.fDstColorSpaceInfo);
auto fp2 = fFilter->asFragmentProcessor(args.fContext, *args.fDstColorInfo);
if (!fp2) {
return fp1;
}

View File

@ -92,21 +92,21 @@ bool SkColor4Shader::onAppendStages(const SkStageRec& rec) const {
#if SK_SUPPORT_GPU
#include "src/gpu/GrColorSpaceInfo.h"
#include "src/gpu/GrColorInfo.h"
#include "src/gpu/GrColorSpaceXform.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/effects/generated/GrConstColorProcessor.h"
std::unique_ptr<GrFragmentProcessor> SkColorShader::asFragmentProcessor(
const GrFPArgs& args) const {
SkPMColor4f color = SkColorToPMColor4f(fColor, *args.fDstColorSpaceInfo);
SkPMColor4f color = SkColorToPMColor4f(fColor, *args.fDstColorInfo);
return GrConstColorProcessor::Make(color, GrConstColorProcessor::InputMode::kModulateA);
}
std::unique_ptr<GrFragmentProcessor> SkColor4Shader::asFragmentProcessor(
const GrFPArgs& args) const {
SkColorSpaceXformSteps steps{ fColorSpace.get(), kUnpremul_SkAlphaType,
args.fDstColorSpaceInfo->colorSpace(), kUnpremul_SkAlphaType };
SkColorSpaceXformSteps steps{ fColorSpace.get(), kUnpremul_SkAlphaType,
args.fDstColorInfo->colorSpace(), kUnpremul_SkAlphaType };
SkColor4f color = fColor;
steps.apply(color.vec());
return GrConstColorProcessor::Make(color.premul(),

View File

@ -165,7 +165,7 @@ sk_sp<SkShader> SkImageShader::Make(sk_sp<SkImage> image,
#include "include/private/GrRecordingContext.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrColorSpaceInfo.h"
#include "src/gpu/GrColorInfo.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/SkGr.h"
#include "src/gpu/effects/GrBicubicEffect.h"
@ -251,8 +251,7 @@ std::unique_ptr<GrFragmentProcessor> SkImageShader::asFragmentProcessor(
}
}
inner = GrColorSpaceXformEffect::Make(std::move(inner), fImage->colorSpace(),
fImage->alphaType(),
args.fDstColorSpaceInfo->colorSpace());
fImage->alphaType(), args.fDstColorInfo->colorSpace());
if (isAlphaOnly) {
return inner;
} else if (args.fInputColorIsOpaque) {

View File

@ -22,7 +22,7 @@
#if SK_SUPPORT_GPU
#include "include/private/GrRecordingContext.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrColorSpaceInfo.h"
#include "src/gpu/GrColorInfo.h"
#include "src/gpu/GrFragmentProcessor.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/SkGr.h"
@ -345,19 +345,19 @@ std::unique_ptr<GrFragmentProcessor> SkPictureShader::asFragmentProcessor(
}
auto lm = this->totalLocalMatrix(args.fPreLocalMatrix, args.fPostLocalMatrix);
SkColorType dstColorType = GrColorTypeToSkColorType(args.fDstColorSpaceInfo->colorType());
SkColorType dstColorType = GrColorTypeToSkColorType(args.fDstColorInfo->colorType());
if (dstColorType == kUnknown_SkColorType) {
dstColorType = kRGBA_8888_SkColorType;
}
sk_sp<SkShader> bitmapShader(this->refBitmapShader(*args.fViewMatrix, &lm, dstColorType,
args.fDstColorSpaceInfo->colorSpace(),
args.fDstColorInfo->colorSpace(),
maxTextureSize));
if (!bitmapShader) {
return nullptr;
}
// We want to *reset* args.fPreLocalMatrix, not compose it.
GrFPArgs newArgs(args.fContext, args.fViewMatrix, args.fFilterQuality, args.fDstColorSpaceInfo);
GrFPArgs newArgs(args.fContext, args.fViewMatrix, args.fFilterQuality, args.fDstColorInfo);
newArgs.fPreLocalMatrix = lm.get();
return as_SB(bitmapShader)->asFragmentProcessor(newArgs);

View File

@ -18,7 +18,7 @@
#if SK_SUPPORT_GPU
#include "include/private/GrRecordingContext.h"
#include "src/gpu/GrCaps.h"
#include "src/gpu/GrColorSpaceInfo.h"
#include "src/gpu/GrColorInfo.h"
#include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/SkGr.h"

View File

@ -42,8 +42,8 @@ public:
}
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(
GrRecordingContext*, const GrColorSpaceInfo&) const override;
std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(GrRecordingContext*,
const GrColorInfo&) const override;
#endif
protected:
@ -67,7 +67,7 @@ sk_sp<SkFlattenable> SkGaussianColorFilter::CreateProc(SkReadBuffer&) {
#if SK_SUPPORT_GPU
std::unique_ptr<GrFragmentProcessor> SkGaussianColorFilter::asFragmentProcessor(
GrRecordingContext*, const GrColorSpaceInfo&) const {
GrRecordingContext*, const GrColorInfo&) const {
return GrBlurredEdgeFragmentProcessor::Make(GrBlurredEdgeFragmentProcessor::Mode::kGaussian);
}
#endif

View File

@ -54,8 +54,7 @@ static void fill_surface(SkSurface* surf, SkColorType colorType, PackUnpremulPro
}
}
const SkImageInfo info = SkImageInfo::Make(bmp.width(), bmp.height(),
colorType, kUnpremul_SkAlphaType);
const SkImageInfo info = SkImageInfo::Make(bmp.dimensions(), colorType, kUnpremul_SkAlphaType);
surf->writePixels({info, bmp.getPixels(), bmp.rowBytes()}, 0, 0);
}

View File

@ -276,7 +276,7 @@ static BitmapInit nextBMI(BitmapInit bmi) {
static void init_bitmap(SkBitmap* bitmap, const SkIRect& rect, BitmapInit init, SkColorType ct,
SkAlphaType at) {
SkImageInfo info = SkImageInfo::Make(rect.width(), rect.height(), ct, at);
SkImageInfo info = SkImageInfo::Make(rect.size(), ct, at);
size_t rowBytes = 0;
switch (init) {
case kTight_BitmapInit:
@ -706,8 +706,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(AsyncReadPixels, reporter, ctxInfo) {
SkAutoPixmapStorage result;
Context context;
context.fPixmap = &result;
info = SkImageInfo::Make(rect.width(), rect.height(), readCT,
kPremul_SkAlphaType, readCS);
info = SkImageInfo::Make(rect.size(), readCT, kPremul_SkAlphaType, readCS);
result.alloc(info);
memset(result.writable_addr(), 0xAB, result.computeByteSize());
// Rescale quality and linearity don't matter since we're doing a non-

View File

@ -693,8 +693,8 @@ static std::unique_ptr<GrFragmentProcessor> create_linear_gradient_processor(GrC
SkColor colors[2] = { SK_ColorGREEN, SK_ColorBLUE };
sk_sp<SkShader> shader = SkGradientShader::MakeLinear(
pts, colors, nullptr, SK_ARRAY_COUNT(colors), SkTileMode::kClamp);
GrColorSpaceInfo colorSpaceInfo(GrColorType::kRGBA_8888, kPremul_SkAlphaType, nullptr);
GrFPArgs args(ctx, &SkMatrix::I(), SkFilterQuality::kLow_SkFilterQuality, &colorSpaceInfo);
GrColorInfo colorInfo(GrColorType::kRGBA_8888, kPremul_SkAlphaType, nullptr);
GrFPArgs args(ctx, &SkMatrix::I(), SkFilterQuality::kLow_SkFilterQuality, &colorInfo);
return as_SB(shader)->asFragmentProcessor(args);
}

View File

@ -676,7 +676,7 @@ bool DrawCommand::flatten(const SkImage& image,
size_t rowBytes = 4 * image.width();
SkAutoMalloc buffer(rowBytes * image.height());
SkImageInfo dstInfo =
SkImageInfo::Make(image.width(), image.height(), kN32_SkColorType, kPremul_SkAlphaType);
SkImageInfo::Make(image.dimensions(), kN32_SkColorType, kPremul_SkAlphaType);
if (!image.readPixels(dstInfo, buffer.get(), rowBytes, 0, 0)) {
SkDebugf("readPixels failed\n");
return false;

View File

@ -139,8 +139,8 @@ SkSurface* Request::createCPUSurface() {
auto colorSpace = kRGBA_F16_SkColorType == cap.fColorType
? SkColorSpace::MakeSRGBLinear()
: SkColorSpace::MakeSRGB();
SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fColorType,
kPremul_SkAlphaType, cap.fSRGB ? colorSpace : nullptr);
SkImageInfo info = SkImageInfo::Make(bounds.size(), cap.fColorType, kPremul_SkAlphaType,
cap.fSRGB ? colorSpace : nullptr);
return SkSurface::MakeRaster(info).release();
}
@ -151,8 +151,8 @@ SkSurface* Request::createGPUSurface() {
auto colorSpace = kRGBA_F16_SkColorType == cap.fColorType
? SkColorSpace::MakeSRGBLinear()
: SkColorSpace::MakeSRGB();
SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fColorType,
kPremul_SkAlphaType, cap.fSRGB ? colorSpace: nullptr);
SkImageInfo info = SkImageInfo::Make(bounds.size(), cap.fColorType, kPremul_SkAlphaType,
cap.fSRGB ? colorSpace : nullptr);
SkSurface* surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info).release();
return surface;
}

View File

@ -91,8 +91,7 @@ static SkBitmap decode(sk_sp<SkData> data) {
if (auto codec = SkCodec::MakeFromData(std::move(data))) {
SkISize size = codec->getInfo().dimensions();
SkASSERT(!size.isEmpty());
SkImageInfo info = SkImageInfo::Make(size.width(), size.height(),
skqp::kColorType, skqp::kAlphaType);
SkImageInfo info = SkImageInfo::Make(size, skqp::kColorType, skqp::kAlphaType);
bitmap.allocPixels(info);
if (SkCodec::kSuccess != codec->getPixels(bitmap.pixmap())) {
bitmap.reset();