Remove some more GrColor references
Bug: skia: Change-Id: I395395b1cd81a1d45ca779b2273015c8ed9fb882 Reviewed-on: https://skia-review.googlesource.com/c/168361 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
parent
e70c6b13dd
commit
00b2939890
@ -11,10 +11,8 @@
|
|||||||
#ifndef GrColor_DEFINED
|
#ifndef GrColor_DEFINED
|
||||||
#define GrColor_DEFINED
|
#define GrColor_DEFINED
|
||||||
|
|
||||||
#include "GrTypes.h"
|
|
||||||
#include "SkColor.h"
|
#include "SkColor.h"
|
||||||
#include "SkColorPriv.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
|
* 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_ILLEGAL (~(0xFF << GrColor_SHIFT_A))
|
||||||
|
|
||||||
#define GrColor_WHITE 0xFFFFFFFF
|
#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) {
|
static inline GrColor GrColorMul(GrColor c0, GrColor c1) {
|
||||||
U8CPU r = SkMulDiv255Round(GrColorUnpackR(c0), GrColorUnpackR(c1));
|
U8CPU r = SkMulDiv255Round(GrColorUnpackR(c0), GrColorUnpackR(c1));
|
||||||
@ -109,9 +90,4 @@ static inline float GrNormalizeByteToFloat(uint8_t value) {
|
|||||||
return value * ONE_OVER_255;
|
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
|
#endif
|
||||||
|
@ -50,11 +50,6 @@ public:
|
|||||||
void setColor4f(const SkPMColor4f& color) { fColor = color; }
|
void setColor4f(const SkPMColor4f& color) { fColor = color; }
|
||||||
const SkPMColor4f& getColor4f() const { return fColor; }
|
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) {
|
void setXPFactory(const GrXPFactory* xpFactory) {
|
||||||
fXPFactory = xpFactory;
|
fXPFactory = xpFactory;
|
||||||
fTrivial &= !SkToBool(xpFactory);
|
fTrivial &= !SkToBool(xpFactory);
|
||||||
|
@ -126,7 +126,6 @@ static inline GrColor GrRandomColor(SkRandom* random) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GrColorIsPMAssert(color);
|
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,12 +400,12 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We can ignore origColor here - alpha is unchanged by gamma
|
// We can ignore origColor here - alpha is unchanged by gamma
|
||||||
GrColor paintAlpha = GrColorPackA4(skPaint.getAlpha());
|
float paintAlpha = skPaint.getColor4f().fA;
|
||||||
if (GrColor_WHITE != paintAlpha) {
|
if (1.0f != paintAlpha) {
|
||||||
// No gamut conversion - paintAlpha is a (linear) alpha value, splatted to all
|
// 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.
|
// color channels. It's value should be treated as the same in ANY color space.
|
||||||
grPaint->addColorFragmentProcessor(GrConstColorProcessor::Make(
|
grPaint->addColorFragmentProcessor(GrConstColorProcessor::Make(
|
||||||
SkPMColor4f::FromBytes_RGBA(paintAlpha),
|
{ paintAlpha, paintAlpha, paintAlpha, paintAlpha },
|
||||||
GrConstColorProcessor::InputMode::kModulateRGBA));
|
GrConstColorProcessor::InputMode::kModulateRGBA));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -430,12 +430,12 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
|
|||||||
grPaint->setColor4f(opaqueColor);
|
grPaint->setColor4f(opaqueColor);
|
||||||
|
|
||||||
// We can ignore origColor here - alpha is unchanged by gamma
|
// We can ignore origColor here - alpha is unchanged by gamma
|
||||||
GrColor paintAlpha = GrColorPackA4(skPaint.getAlpha());
|
float paintAlpha = skPaint.getColor4f().fA;
|
||||||
if (GrColor_WHITE != paintAlpha) {
|
if (1.0f != paintAlpha) {
|
||||||
// No gamut conversion - paintAlpha is a (linear) alpha value, splatted to all
|
// 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.
|
// color channels. It's value should be treated as the same in ANY color space.
|
||||||
grPaint->addColorFragmentProcessor(GrConstColorProcessor::Make(
|
grPaint->addColorFragmentProcessor(GrConstColorProcessor::Make(
|
||||||
SkPMColor4f::FromBytes_RGBA(paintAlpha),
|
{ paintAlpha, paintAlpha, paintAlpha, paintAlpha },
|
||||||
GrConstColorProcessor::InputMode::kModulateRGBA));
|
GrConstColorProcessor::InputMode::kModulateRGBA));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -669,7 +669,7 @@ GR_DRAW_OP_TEST_DEFINE(ShadowRRectOp) {
|
|||||||
SkScalar blurWidth = random->nextSScalar1() * 72.f;
|
SkScalar blurWidth = random->nextSScalar1() * 72.f;
|
||||||
bool isCircle = random->nextBool();
|
bool isCircle = random->nextBool();
|
||||||
// This op doesn't use a full GrPaint, just a color.
|
// This op doesn't use a full GrPaint, just a color.
|
||||||
GrColor color = paint.getColor();
|
GrColor color = paint.getColor4f().toBytes_RGBA();
|
||||||
if (isCircle) {
|
if (isCircle) {
|
||||||
SkRect circle = GrTest::TestSquare(random);
|
SkRect circle = GrTest::TestSquare(random);
|
||||||
SkRRect rrect = SkRRect::MakeOval(circle);
|
SkRRect rrect = SkRRect::MakeOval(circle);
|
||||||
|
@ -576,8 +576,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (GrColorIsOpaque(input) && fp->preservesOpaqueInput() &&
|
if (input4f.isOpaque() && fp->preservesOpaqueInput() && !output4f.isOpaque()) {
|
||||||
!GrColorIsOpaque(output)) {
|
|
||||||
passing = false;
|
passing = false;
|
||||||
|
|
||||||
if (opaqueMessage.isEmpty()) {
|
if (opaqueMessage.isEmpty()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user