From 00b29398901e556bf9f2854aa602c20f5e11deba Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Mon, 5 Nov 2018 15:42:43 -0500 Subject: [PATCH] Remove some more GrColor references Bug: skia: Change-Id: I395395b1cd81a1d45ca779b2273015c8ed9fb882 Reviewed-on: https://skia-review.googlesource.com/c/168361 Commit-Queue: Brian Osman Reviewed-by: Mike Klein --- include/private/GrColor.h | 24 ------------------------ src/gpu/GrPaint.h | 5 ----- src/gpu/GrTestUtils.h | 1 - src/gpu/SkGr.cpp | 12 ++++++------ src/gpu/ops/GrShadowRRectOp.cpp | 2 +- tests/ProcessorTest.cpp | 3 +-- 6 files changed, 8 insertions(+), 39 deletions(-) diff --git a/include/private/GrColor.h b/include/private/GrColor.h index ab03ab228c..f2f449f7e5 100644 --- a/include/private/GrColor.h +++ b/include/private/GrColor.h @@ -11,10 +11,8 @@ #ifndef GrColor_DEFINED #define GrColor_DEFINED -#include "GrTypes.h" #include "SkColor.h" #include "SkColorPriv.h" -#include "SkUnPreMultiply.h" /** * GrColor is 4 bytes for R, G, B, A, in a specific order defined below. Whether the color is @@ -77,23 +75,6 @@ static inline GrColor GrColorPackA4(unsigned a) { #define GrColor_ILLEGAL (~(0xFF << GrColor_SHIFT_A)) #define GrColor_WHITE 0xFFFFFFFF -#define GrColor_TRANSPARENT_BLACK 0x0 - -/** - * Assert in debug builds that a GrColor is premultiplied. - */ -static inline void GrColorIsPMAssert(GrColor SkDEBUGCODE(c)) { -#ifdef SK_DEBUG - unsigned a = GrColorUnpackA(c); - unsigned r = GrColorUnpackR(c); - unsigned g = GrColorUnpackG(c); - unsigned b = GrColorUnpackB(c); - - SkASSERT(r <= a); - SkASSERT(g <= a); - SkASSERT(b <= a); -#endif -} static inline GrColor GrColorMul(GrColor c0, GrColor c1) { U8CPU r = SkMulDiv255Round(GrColorUnpackR(c0), GrColorUnpackR(c1)); @@ -109,9 +90,4 @@ static inline float GrNormalizeByteToFloat(uint8_t value) { return value * ONE_OVER_255; } -/** Determines whether the color is opaque or not. */ -static inline bool GrColorIsOpaque(GrColor color) { - return (color & (0xFFU << GrColor_SHIFT_A)) == (0xFFU << GrColor_SHIFT_A); -} - #endif diff --git a/src/gpu/GrPaint.h b/src/gpu/GrPaint.h index f6173b7614..b900c24aa2 100644 --- a/src/gpu/GrPaint.h +++ b/src/gpu/GrPaint.h @@ -50,11 +50,6 @@ public: void setColor4f(const SkPMColor4f& color) { fColor = color; } const SkPMColor4f& getColor4f() const { return fColor; } - /** - * Legacy getter, until all code handles 4f directly. - */ - GrColor getColor() const { return fColor.toBytes_RGBA(); } - void setXPFactory(const GrXPFactory* xpFactory) { fXPFactory = xpFactory; fTrivial &= !SkToBool(xpFactory); diff --git a/src/gpu/GrTestUtils.h b/src/gpu/GrTestUtils.h index 2e8eb06550..79c85408a2 100644 --- a/src/gpu/GrTestUtils.h +++ b/src/gpu/GrTestUtils.h @@ -126,7 +126,6 @@ static inline GrColor GrRandomColor(SkRandom* random) { break; } } - GrColorIsPMAssert(color); return color; } diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 1157ec5161..168cce639e 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -400,12 +400,12 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context, } // We can ignore origColor here - alpha is unchanged by gamma - GrColor paintAlpha = GrColorPackA4(skPaint.getAlpha()); - if (GrColor_WHITE != paintAlpha) { + float paintAlpha = skPaint.getColor4f().fA; + if (1.0f != paintAlpha) { // No gamut conversion - paintAlpha is a (linear) alpha value, splatted to all // color channels. It's value should be treated as the same in ANY color space. grPaint->addColorFragmentProcessor(GrConstColorProcessor::Make( - SkPMColor4f::FromBytes_RGBA(paintAlpha), + { paintAlpha, paintAlpha, paintAlpha, paintAlpha }, GrConstColorProcessor::InputMode::kModulateRGBA)); } } else { @@ -430,12 +430,12 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context, grPaint->setColor4f(opaqueColor); // We can ignore origColor here - alpha is unchanged by gamma - GrColor paintAlpha = GrColorPackA4(skPaint.getAlpha()); - if (GrColor_WHITE != paintAlpha) { + float paintAlpha = skPaint.getColor4f().fA; + if (1.0f != paintAlpha) { // No gamut conversion - paintAlpha is a (linear) alpha value, splatted to all // color channels. It's value should be treated as the same in ANY color space. grPaint->addColorFragmentProcessor(GrConstColorProcessor::Make( - SkPMColor4f::FromBytes_RGBA(paintAlpha), + { paintAlpha, paintAlpha, paintAlpha, paintAlpha }, GrConstColorProcessor::InputMode::kModulateRGBA)); } } else { diff --git a/src/gpu/ops/GrShadowRRectOp.cpp b/src/gpu/ops/GrShadowRRectOp.cpp index d92f2a3cff..52816ccd13 100644 --- a/src/gpu/ops/GrShadowRRectOp.cpp +++ b/src/gpu/ops/GrShadowRRectOp.cpp @@ -669,7 +669,7 @@ GR_DRAW_OP_TEST_DEFINE(ShadowRRectOp) { SkScalar blurWidth = random->nextSScalar1() * 72.f; bool isCircle = random->nextBool(); // This op doesn't use a full GrPaint, just a color. - GrColor color = paint.getColor(); + GrColor color = paint.getColor4f().toBytes_RGBA(); if (isCircle) { SkRect circle = GrTest::TestSquare(random); SkRRect rrect = SkRRect::MakeOval(circle); diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp index d0da21fe3c..e76099ca5f 100644 --- a/tests/ProcessorTest.cpp +++ b/tests/ProcessorTest.cpp @@ -576,8 +576,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor } } } - if (GrColorIsOpaque(input) && fp->preservesOpaqueInput() && - !GrColorIsOpaque(output)) { + if (input4f.isOpaque() && fp->preservesOpaqueInput() && !output4f.isOpaque()) { passing = false; if (opaqueMessage.isEmpty()) {