Remove (unused) GrBlend.cpp, and some GrColor helpers

Bug: skia:
Change-Id: I9a99cb28fd239371ca21b4a918e802606afe9da0
Reviewed-on: https://skia-review.googlesource.com/155840
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Brian Osman 2018-09-20 11:04:00 -04:00 committed by Skia Commit-Bot
parent 7b11354810
commit 653c6b5b8e
4 changed files with 1 additions and 166 deletions

View File

@ -54,7 +54,6 @@ skia_gpu_sources = [
"$_src/gpu/GrAHardwareBufferImageGenerator.h",
"$_src/gpu/GrBitmapTextureMaker.cpp",
"$_src/gpu/GrBitmapTextureMaker.h",
"$_src/gpu/GrBlend.cpp",
"$_src/gpu/GrBlurUtils.cpp",
"$_src/gpu/GrBlurUtils.h",
"$_src/gpu/GrBuffer.cpp",

View File

@ -9,8 +9,7 @@
#ifndef GrBlend_DEFINED
#define GrBlend_DEFINED
#include "GrTypes.h"
#include "../private/SkTLogic.h"
#include "SkTypes.h"
/**
* Equations for alpha-blending.

View File

@ -95,15 +95,6 @@ static inline void GrColorIsPMAssert(GrColor SkDEBUGCODE(c)) {
#endif
}
/** Inverts each color channel. */
static inline GrColor GrInvertColor(GrColor c) {
U8CPU a = GrColorUnpackA(c);
U8CPU r = GrColorUnpackR(c);
U8CPU g = GrColorUnpackG(c);
U8CPU b = GrColorUnpackB(c);
return GrColorPackRGBA(0xff - r, 0xff - g, 0xff - b, 0xff - a);
}
static inline GrColor GrColorMul(GrColor c0, GrColor c1) {
U8CPU r = SkMulDiv255Round(GrColorUnpackR(c0), GrColorUnpackR(c1));
U8CPU g = SkMulDiv255Round(GrColorUnpackG(c0), GrColorUnpackG(c1));
@ -112,14 +103,6 @@ static inline GrColor GrColorMul(GrColor c0, GrColor c1) {
return GrColorPackRGBA(r, g, b, a);
}
static inline GrColor GrColorSatAdd(GrColor c0, GrColor c1) {
unsigned r = SkTMin<unsigned>(GrColorUnpackR(c0) + GrColorUnpackR(c1), 0xff);
unsigned g = SkTMin<unsigned>(GrColorUnpackG(c0) + GrColorUnpackG(c1), 0xff);
unsigned b = SkTMin<unsigned>(GrColorUnpackB(c0) + GrColorUnpackB(c1), 0xff);
unsigned a = SkTMin<unsigned>(GrColorUnpackA(c0) + GrColorUnpackA(c1), 0xff);
return GrColorPackRGBA(r, g, b, a);
}
/** Converts a GrColor to an rgba array of GrGLfloat */
static inline void GrColorToRGBAFloat(GrColor color, float rgba[4]) {
static const float ONE_OVER_255 = 1.f / 255.f;
@ -270,25 +253,4 @@ struct GrColor4f {
}
};
/**
* Flags used for bitfields of color components. They are defined so that the bit order reflects the
* GrColor shift order.
*/
enum GrColorComponentFlags {
kR_GrColorComponentFlag = 1 << (GrColor_SHIFT_R / 8),
kG_GrColorComponentFlag = 1 << (GrColor_SHIFT_G / 8),
kB_GrColorComponentFlag = 1 << (GrColor_SHIFT_B / 8),
kA_GrColorComponentFlag = 1 << (GrColor_SHIFT_A / 8),
kNone_GrColorComponentFlags = 0,
kRGB_GrColorComponentFlags = (kR_GrColorComponentFlag | kG_GrColorComponentFlag |
kB_GrColorComponentFlag),
kRGBA_GrColorComponentFlags = (kR_GrColorComponentFlag | kG_GrColorComponentFlag |
kB_GrColorComponentFlag | kA_GrColorComponentFlag)
};
GR_MAKE_BITFIELD_OPS(GrColorComponentFlags)
#endif

View File

@ -1,125 +0,0 @@
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "GrBlend.h"
#include "../private/GrColor.h"
/**
* MaskedColor is used to evaluate the color and valid color component flags through the
* blending equation. Could possibly extend this to be used more broadly.
*/
class MaskedColor {
public:
MaskedColor(GrColor color, GrColorComponentFlags flags)
: fColor(color)
, fFlags(flags) {}
MaskedColor() {}
void set(GrColor color, GrColorComponentFlags flags) {
fColor = color;
fFlags = flags;
}
static MaskedColor Invert(const MaskedColor& in) {
return MaskedColor(GrInvertColor(in.fColor), in.fFlags);
}
static MaskedColor ExtractAlpha(const MaskedColor& in) {
GrColorComponentFlags flags = (in.fFlags & kA_GrColorComponentFlag) ?
kRGBA_GrColorComponentFlags : kNone_GrColorComponentFlags;
return MaskedColor(GrColorPackA4(GrColorUnpackA(in.fColor)), flags);
}
static MaskedColor ExtractInverseAlpha(const MaskedColor& in) {
GrColorComponentFlags flags = (in.fFlags & kA_GrColorComponentFlag) ?
kRGBA_GrColorComponentFlags : kNone_GrColorComponentFlags;
return MaskedColor(GrColorPackA4(0xFF - GrColorUnpackA(in.fColor)), flags);
}
static MaskedColor Mul(const MaskedColor& a, const MaskedColor& b) {
GrColorComponentFlags outFlags = (a.fFlags & b.fFlags) | a.componentsWithValue(0) |
b.componentsWithValue(0);
return MaskedColor(GrColorMul(a.fColor, b.fColor), outFlags);
}
static MaskedColor SatAdd(const MaskedColor& a, const MaskedColor& b) {
GrColorComponentFlags outFlags = (a.fFlags & b.fFlags) | a.componentsWithValue(0xFF) |
b.componentsWithValue(0xFF);
return MaskedColor(GrColorSatAdd(a.fColor, b.fColor), outFlags);
}
GrColor color() const { return fColor; }
GrColorComponentFlags validFlags () const { return fFlags; }
private:
GrColorComponentFlags componentsWithValue(unsigned value) const {
GrColorComponentFlags flags = kNone_GrColorComponentFlags;
if ((kR_GrColorComponentFlag & fFlags) && value == GrColorUnpackR(fColor)) {
flags |= kR_GrColorComponentFlag;
}
if ((kG_GrColorComponentFlag & fFlags) && value == GrColorUnpackG(fColor)) {
flags |= kG_GrColorComponentFlag;
}
if ((kB_GrColorComponentFlag & fFlags) && value == GrColorUnpackB(fColor)) {
flags |= kB_GrColorComponentFlag;
}
if ((kA_GrColorComponentFlag & fFlags) && value == GrColorUnpackA(fColor)) {
flags |= kA_GrColorComponentFlag;
}
return flags;
}
GrColor fColor;
GrColorComponentFlags fFlags;
};
static MaskedColor get_term(GrBlendCoeff coeff, const MaskedColor& src, const MaskedColor& dst,
const MaskedColor& value) {
switch (coeff) {
case kZero_GrBlendCoeff:
return MaskedColor(0, kRGBA_GrColorComponentFlags);
case kOne_GrBlendCoeff:
return value;
case kDC_GrBlendCoeff:
return MaskedColor::Mul(dst, value);
case kIDC_GrBlendCoeff:
return MaskedColor::Mul(MaskedColor::Invert(dst), value);
case kDA_GrBlendCoeff:
return MaskedColor::Mul(MaskedColor::ExtractAlpha(dst), value);
case kIDA_GrBlendCoeff:
return MaskedColor::Mul(MaskedColor::ExtractInverseAlpha(dst), value);
case kSC_GrBlendCoeff:
return MaskedColor::Mul(src, value);
case kISC_GrBlendCoeff:
return MaskedColor::Mul(MaskedColor::Invert(src), value);
case kSA_GrBlendCoeff:
return MaskedColor::Mul(MaskedColor::ExtractAlpha(src), value);
case kISA_GrBlendCoeff:
return MaskedColor::Mul(MaskedColor::ExtractInverseAlpha(src), value);
default:
SK_ABORT("Illegal coefficient");
return MaskedColor();
}
}
void GrGetCoeffBlendKnownComponents(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff,
GrColor srcColor, GrColorComponentFlags srcColorFlags,
GrColor dstColor, GrColorComponentFlags dstColorFlags,
GrColor* outColor,
GrColorComponentFlags* outFlags) {
MaskedColor src(srcColor, srcColorFlags);
MaskedColor dst(dstColor, dstColorFlags);
MaskedColor srcTerm = get_term(srcCoeff, src, dst, src);
MaskedColor dstTerm = get_term(dstCoeff, src, dst, dst);
MaskedColor output = MaskedColor::SatAdd(srcTerm, dstTerm);
*outColor = output.color();
*outFlags = output.validFlags();
}