本文整理汇总了C++中SkAlphaMulQ函数的典型用法代码示例。如果您正苦于以下问题:C++ SkAlphaMulQ函数的具体用法?C++ SkAlphaMulQ怎么用?C++ SkAlphaMulQ使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SkAlphaMulQ函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SkAlphaMulQ
void SkARGB32_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
if (alpha == 0 || fSrcA == 0) {
return;
}
uint32_t* device = fDevice.getAddr32(x, y);
uint32_t color = fPMColor;
if (alpha != 255) {
color = SkAlphaMulQ(color, SkAlpha255To256(alpha));
}
unsigned dst_scale = 255 - SkGetPackedA32(color);
uint32_t prevDst = ~device[0];
uint32_t result SK_INIT_TO_AVOID_WARNING;
uint32_t rowBytes = fDevice.rowBytes();
while (--height >= 0) {
uint32_t dst = device[0];
if (dst != prevDst) {
result = color + SkAlphaMulQ(dst, dst_scale);
prevDst = dst;
}
device[0] = result;
device = (uint32_t*)((char*)device + rowBytes);
}
}
示例2: SkASSERT
void SkARGB32_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
const int16_t runs[]) {
if (fSrcA == 0) {
return;
}
uint32_t color = fPMColor;
uint32_t* device = fDevice.getAddr32(x, y);
unsigned opaqueMask = fSrcA; // if fSrcA is 0xFF, then we will catch the fast opaque case
for (;;) {
int count = runs[0];
SkASSERT(count >= 0);
if (count <= 0) {
return;
}
unsigned aa = antialias[0];
if (aa) {
if ((opaqueMask & aa) == 255) {
sk_memset32(device, color, count);
} else {
uint32_t sc = SkAlphaMulQ(color, aa);
unsigned dst_scale = 255 - SkGetPackedA32(sc);
int n = count;
do {
--n;
device[n] = sc + SkAlphaMulQ(device[n], dst_scale);
} while (n > 0);
}
}
runs += count;
antialias += count;
device += count;
}
}
示例3: SkAlpha255To256
void SkComposeShader::ComposeShaderContext::shadeSpan(int x, int y, SkPMColor result[], int count) {
SkShader::Context* shaderContextA = fShaderContextA;
SkShader::Context* shaderContextB = fShaderContextB;
SkBlendMode mode = static_cast<const SkComposeShader&>(fShader).fMode;
unsigned scale = SkAlpha255To256(this->getPaintAlpha());
SkPMColor tmp[TMP_COLOR_COUNT];
SkXfermode* xfer = SkXfermode::Peek(mode);
if (nullptr == xfer) { // implied SRC_OVER
// TODO: when we have a good test-case, should use SkBlitRow::Proc32
// for these loops
do {
int n = count;
if (n > TMP_COLOR_COUNT) {
n = TMP_COLOR_COUNT;
}
shaderContextA->shadeSpan(x, y, result, n);
shaderContextB->shadeSpan(x, y, tmp, n);
if (256 == scale) {
for (int i = 0; i < n; i++) {
result[i] = SkPMSrcOver(tmp[i], result[i]);
}
} else {
for (int i = 0; i < n; i++) {
result[i] = SkAlphaMulQ(SkPMSrcOver(tmp[i], result[i]),
scale);
}
}
result += n;
x += n;
count -= n;
} while (count > 0);
} else { // use mode for the composition
do {
int n = count;
if (n > TMP_COLOR_COUNT) {
n = TMP_COLOR_COUNT;
}
shaderContextA->shadeSpan(x, y, result, n);
shaderContextB->shadeSpan(x, y, tmp, n);
xfer->xfer32(result, tmp, n, nullptr);
if (256 != scale) {
for (int i = 0; i < n; i++) {
result[i] = SkAlphaMulQ(result[i], scale);
}
}
result += n;
x += n;
count -= n;
} while (count > 0);
}
}
示例4: SkAlpha255To256
void SkComposeShader::shadeSpan(int x, int y, SkPMColor result[], int count) {
SkShader* shaderA = fShaderA;
SkShader* shaderB = fShaderB;
SkXfermode* mode = fMode;
unsigned scale = SkAlpha255To256(this->getPaintAlpha());
SkPMColor tmp[TMP_COLOR_COUNT];
if (NULL == mode) { // implied SRC_OVER
// TODO: when we have a good test-case, should use SkBlitRow::Proc32
// for these loops
do {
int n = count;
if (n > TMP_COLOR_COUNT) {
n = TMP_COLOR_COUNT;
}
shaderA->shadeSpan(x, y, result, n);
shaderB->shadeSpan(x, y, tmp, n);
if (256 == scale) {
for (int i = 0; i < n; i++) {
result[i] = SkPMSrcOver(tmp[i], result[i]);
}
} else {
for (int i = 0; i < n; i++) {
result[i] = SkAlphaMulQ(SkPMSrcOver(tmp[i], result[i]),
scale);
}
}
result += n;
x += n;
count -= n;
} while (count > 0);
} else { // use mode for the composition
do {
int n = count;
if (n > TMP_COLOR_COUNT) {
n = TMP_COLOR_COUNT;
}
shaderA->shadeSpan(x, y, result, n);
shaderB->shadeSpan(x, y, tmp, n);
mode->xfer32(result, tmp, n, NULL);
if (256 == scale) {
for (int i = 0; i < n; i++) {
result[i] = SkAlphaMulQ(result[i], scale);
}
}
result += n;
x += n;
count -= n;
} while (count > 0);
}
}
示例5: srcover_modeproc
// kSrcOver_Mode, //!< [Sa + Da - Sa*Da, Sc + (1 - Sa)*Dc]
static SkPMColor srcover_modeproc(SkPMColor src, SkPMColor dst) {
#if 0
// this is the old, more-correct way, but it doesn't guarantee that dst==255
// will always stay opaque
return src + SkAlphaMulQ(dst, SkAlpha255To256(255 - SkGetPackedA32(src)));
#else
// this is slightly faster, but more importantly guarantees that dst==255
// will always stay opaque
return src + SkAlphaMulQ(dst, 256 - SkGetPackedA32(src));
#endif
}
示例6: SkASSERT
void SkARGB32_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
const int16_t runs[]) {
if (fSrcA == 0) {
return;
}
uint32_t color = fPMColor;
uint32_t* device = fDevice.writable_addr32(x, y);
unsigned opaqueMask = fSrcA; // if fSrcA is 0xFF, then we will catch the fast opaque case
for (;;) {
int count = runs[0];
SkASSERT(count >= 0);
if (count <= 0) {
return;
}
unsigned aa = antialias[0];
if (aa) {
if ((opaqueMask & aa) == 255) {
sk_memset32(device, color, count);
} else {
uint32_t sc = SkAlphaMulQ(color, SkAlpha255To256(aa));
SkBlitRow::Color32(device, device, count, sc);
}
}
runs += count;
antialias += count;
device += count;
}
}
示例7: SkASSERT
void SkARGB32_Black_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
const int16_t runs[]) {
uint32_t* device = fDevice.getAddr32(x, y);
SkPMColor black = (SkPMColor)(SK_A32_MASK << SK_A32_SHIFT);
for (;;) {
int count = runs[0];
SkASSERT(count >= 0);
if (count <= 0) {
return;
}
unsigned aa = antialias[0];
if (aa) {
if (aa == 255) {
sk_memset32(device, black, count);
} else {
SkPMColor src = aa << SK_A32_SHIFT;
unsigned dst_scale = 256 - aa;
int n = count;
do {
--n;
device[n] = src + SkAlphaMulQ(device[n], dst_scale);
} while (n > 0);
}
}
runs += count;
antialias += count;
device += count;
}
}
示例8: extract_verts
// extract the result vertices and indices from the GrAAConvexTessellator
static void extract_verts(const GrAAConvexTessellator& tess,
void* vertices,
size_t vertexStride,
GrColor color,
uint16_t firstIndex,
uint16_t* idxs,
bool tweakAlphaForCoverage) {
intptr_t verts = reinterpret_cast<intptr_t>(vertices);
for (int i = 0; i < tess.numPts(); ++i) {
*((SkPoint*)((intptr_t)verts + i * vertexStride)) = tess.point(i);
}
// Make 'verts' point to the colors
verts += sizeof(SkPoint);
for (int i = 0; i < tess.numPts(); ++i) {
if (tweakAlphaForCoverage) {
SkASSERT(SkScalarRoundToInt(255.0f * tess.coverage(i)) <= 255);
unsigned scale = SkScalarRoundToInt(255.0f * tess.coverage(i));
GrColor scaledColor = (0xff == scale) ? color : SkAlphaMulQ(color, scale);
*reinterpret_cast<GrColor*>(verts + i * vertexStride) = scaledColor;
} else {
*reinterpret_cast<GrColor*>(verts + i * vertexStride) = color;
*reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor)) =
tess.coverage(i);
}
}
for (int i = 0; i < tess.numIndices(); ++i) {
idxs[i] = tess.index(i) + firstIndex;
}
}
示例9: SkAlpha255To256
void SkTransparentShader::TransparentShaderContext::shadeSpan(int x, int y, SkPMColor span[],
int count) {
unsigned scale = SkAlpha255To256(this->getPaintAlpha());
switch (fDevice->colorType()) {
case kN32_SkColorType:
if (scale == 256) {
SkPMColor* src = fDevice->getAddr32(x, y);
if (src != span) {
memcpy(span, src, count * sizeof(SkPMColor));
}
} else {
const SkPMColor* src = fDevice->getAddr32(x, y);
for (int i = count - 1; i >= 0; --i) {
span[i] = SkAlphaMulQ(src[i], scale);
}
}
break;
case kRGB_565_SkColorType: {
const uint16_t* src = fDevice->getAddr16(x, y);
if (scale == 256) {
for (int i = count - 1; i >= 0; --i) {
span[i] = SkPixel16ToPixel32(src[i]);
}
} else {
unsigned alpha = this->getPaintAlpha();
for (int i = count - 1; i >= 0; --i) {
uint16_t c = src[i];
unsigned r = SkPacked16ToR32(c);
unsigned g = SkPacked16ToG32(c);
unsigned b = SkPacked16ToB32(c);
span[i] = SkPackARGB32( alpha,
SkAlphaMul(r, scale),
SkAlphaMul(g, scale),
SkAlphaMul(b, scale));
}
}
break;
}
case kAlpha_8_SkColorType: {
const uint8_t* src = fDevice->getAddr8(x, y);
if (scale == 256) {
for (int i = count - 1; i >= 0; --i) {
span[i] = SkPackARGB32(src[i], 0, 0, 0);
}
} else {
for (int i = count - 1; i >= 0; --i) {
span[i] = SkPackARGB32(SkAlphaMul(src[i], scale), 0, 0, 0);
}
}
break;
}
default:
SkDEBUGFAIL("colorType not supported as a destination device");
break;
}
}
示例10: SkAlphaMulQ
void SkARGB32_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
if (alpha == 0 || fSrcA == 0) {
return;
}
uint32_t* device = fDevice.getAddr32(x, y);
uint32_t color = fPMColor;
if (alpha != 255) {
color = SkAlphaMulQ(color, SkAlpha255To256(alpha));
}
unsigned dst_scale = 255 - SkGetPackedA32(color);
uint32_t rowBytes = fDevice.rowBytes();
while (--height >= 0) {
device[0] = color + SkAlphaMulQ(device[0], dst_scale);
device = (uint32_t*)((char*)device + rowBytes);
}
}
示例11: xfer32
virtual void xfer32(SK_RESTRICT SkPMColor dst[],
const SK_RESTRICT SkPMColor[], int count,
const SK_RESTRICT SkAlpha aa[]) {
SkASSERT(dst && count >= 0);
if (NULL == aa) {
memset(dst, 0, count << 2);
} else {
for (int i = count - 1; i >= 0; --i) {
unsigned a = aa[i];
if (0xFF == a) {
dst[i] = 0;
} else if (a != 0) {
dst[i] = SkAlphaMulQ(dst[i], SkAlpha255To256(255 - a));
}
}
}
}
示例12: dstout_modeproc
// kDstOut_Mode, //!< [Da * (1 - Sa), Dc * (1 - Sa)]
static SkPMColor dstout_modeproc(SkPMColor src, SkPMColor dst) {
return SkAlphaMulQ(dst, SkAlpha255To256(255 - SkGetPackedA32(src)));
}
示例13: srcin_modeproc
// kSrcIn_Mode, //!< [Sa * Da, Sc * Da]
static SkPMColor srcin_modeproc(SkPMColor src, SkPMColor dst) {
return SkAlphaMulQ(src, SkAlpha255To256(SkGetPackedA32(dst)));
}
示例14: dstover_modeproc
// kDstOver_Mode, //!< [Sa + Da - Sa*Da, Dc + (1 - Da)*Sc]
static SkPMColor dstover_modeproc(SkPMColor src, SkPMColor dst) {
// this is the reverse of srcover, just flipping src and dst
// see srcover's comment about the 256 for opaqueness guarantees
return dst + SkAlphaMulQ(src, 256 - SkGetPackedA32(dst));
}
示例15: generateAAStrokeRectGeometry
void generateAAStrokeRectGeometry(void* vertices,
size_t offset,
size_t vertexStride,
int outerVertexNum,
int innerVertexNum,
GrColor color,
const SkRect& devOutside,
const SkRect& devOutsideAssist,
const SkRect& devInside,
bool miterStroke,
bool tweakAlphaForCoverage) const {
intptr_t verts = reinterpret_cast<intptr_t>(vertices) + offset;
// We create vertices for four nested rectangles. There are two ramps from 0 to full
// coverage, one on the exterior of the stroke and the other on the interior.
// The following pointers refer to the four rects, from outermost to innermost.
SkPoint* fan0Pos = reinterpret_cast<SkPoint*>(verts);
SkPoint* fan1Pos = reinterpret_cast<SkPoint*>(verts + outerVertexNum * vertexStride);
SkPoint* fan2Pos = reinterpret_cast<SkPoint*>(verts + 2 * outerVertexNum * vertexStride);
SkPoint* fan3Pos = reinterpret_cast<SkPoint*>(verts +
(2 * outerVertexNum + innerVertexNum) *
vertexStride);
#ifndef SK_IGNORE_THIN_STROKED_RECT_FIX
// TODO: this only really works if the X & Y margins are the same all around
// the rect (or if they are all >= 1.0).
SkScalar inset = SkMinScalar(SK_Scalar1, devOutside.fRight - devInside.fRight);
inset = SkMinScalar(inset, devInside.fLeft - devOutside.fLeft);
inset = SkMinScalar(inset, devInside.fTop - devOutside.fTop);
if (miterStroke) {
inset = SK_ScalarHalf * SkMinScalar(inset, devOutside.fBottom - devInside.fBottom);
} else {
inset = SK_ScalarHalf * SkMinScalar(inset, devOutsideAssist.fBottom -
devInside.fBottom);
}
SkASSERT(inset >= 0);
#else
SkScalar inset = SK_ScalarHalf;
#endif
if (miterStroke) {
// outermost
set_inset_fan(fan0Pos, vertexStride, devOutside, -SK_ScalarHalf, -SK_ScalarHalf);
// inner two
set_inset_fan(fan1Pos, vertexStride, devOutside, inset, inset);
set_inset_fan(fan2Pos, vertexStride, devInside, -inset, -inset);
// innermost
set_inset_fan(fan3Pos, vertexStride, devInside, SK_ScalarHalf, SK_ScalarHalf);
} else {
SkPoint* fan0AssistPos = reinterpret_cast<SkPoint*>(verts + 4 * vertexStride);
SkPoint* fan1AssistPos = reinterpret_cast<SkPoint*>(verts +
(outerVertexNum + 4) *
vertexStride);
// outermost
set_inset_fan(fan0Pos, vertexStride, devOutside, -SK_ScalarHalf, -SK_ScalarHalf);
set_inset_fan(fan0AssistPos, vertexStride, devOutsideAssist, -SK_ScalarHalf,
-SK_ScalarHalf);
// outer one of the inner two
set_inset_fan(fan1Pos, vertexStride, devOutside, inset, inset);
set_inset_fan(fan1AssistPos, vertexStride, devOutsideAssist, inset, inset);
// inner one of the inner two
set_inset_fan(fan2Pos, vertexStride, devInside, -inset, -inset);
// innermost
set_inset_fan(fan3Pos, vertexStride, devInside, SK_ScalarHalf, SK_ScalarHalf);
}
// Make verts point to vertex color and then set all the color and coverage vertex attrs
// values. The outermost rect has 0 coverage
verts += sizeof(SkPoint);
for (int i = 0; i < outerVertexNum; ++i) {
if (tweakAlphaForCoverage) {
*reinterpret_cast<GrColor*>(verts + i * vertexStride) = 0;
} else {
*reinterpret_cast<GrColor*>(verts + i * vertexStride) = color;
*reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor)) = 0;
}
}
// scale is the coverage for the the inner two rects.
int scale;
if (inset < SK_ScalarHalf) {
scale = SkScalarFloorToInt(512.0f * inset / (inset + SK_ScalarHalf));
SkASSERT(scale >= 0 && scale <= 255);
} else {
scale = 0xff;
}
float innerCoverage = GrNormalizeByteToFloat(scale);
GrColor scaledColor = (0xff == scale) ? color : SkAlphaMulQ(color, scale);
verts += outerVertexNum * vertexStride;
for (int i = 0; i < outerVertexNum + innerVertexNum; ++i) {
if (tweakAlphaForCoverage) {
*reinterpret_cast<GrColor*>(verts + i * vertexStride) = scaledColor;
} else {
*reinterpret_cast<GrColor*>(verts + i * vertexStride) = color;
*reinterpret_cast<float*>(verts + i * vertexStride + sizeof(GrColor)) =
innerCoverage;
}
}
//.........这里部分代码省略.........