本文整理汇总了C++中SkShader::shadeSpan方法的典型用法代码示例。如果您正苦于以下问题:C++ SkShader::shadeSpan方法的具体用法?C++ SkShader::shadeSpan怎么用?C++ SkShader::shadeSpan使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkShader
的用法示例。
在下文中一共展示了SkShader::shadeSpan方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shadeSpan
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);
}
}
示例2: SkASSERT
void SkARGB32_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) {
// we only handle kA8 with an xfermode
if (fXfermode && (SkMask::kA8_Format != mask.fFormat)) {
this->INHERITED::blitMask(mask, clip);
return;
}
SkASSERT(mask.fBounds.contains(clip));
SkBlitMask::RowProc proc = NULL;
if (!fXfermode) {
unsigned flags = 0;
if (fShader->getFlags() & SkShader::kOpaqueAlpha_Flag) {
flags |= SkBlitMask::kSrcIsOpaque_RowFlag;
}
proc = SkBlitMask::RowFactory(SkBitmap::kARGB_8888_Config, mask.fFormat,
(SkBlitMask::RowFlags)flags);
if (NULL == proc) {
this->INHERITED::blitMask(mask, clip);
return;
}
}
const int x = clip.fLeft;
const int width = clip.width();
int y = clip.fTop;
int height = clip.height();
char* dstRow = (char*)fDevice.getAddr32(x, y);
const size_t dstRB = fDevice.rowBytes();
const uint8_t* maskRow = (const uint8_t*)mask.getAddr(x, y);
const size_t maskRB = mask.fRowBytes;
SkShader* shader = fShader;
SkPMColor* span = fBuffer;
if (fXfermode) {
SkASSERT(SkMask::kA8_Format == mask.fFormat);
SkXfermode* xfer = fXfermode;
do {
shader->shadeSpan(x, y, span, width);
xfer->xfer32((SkPMColor*)dstRow, span, width, maskRow);
dstRow += dstRB;
maskRow += maskRB;
y += 1;
} while (--height > 0);
} else {
do {
shader->shadeSpan(x, y, span, width);
proc(dstRow, maskRow, span, width);
dstRow += dstRB;
maskRow += maskRB;
y += 1;
} while (--height > 0);
}
}
示例3: if
void SkARGB32_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
const int16_t runs[]) {
SkPMColor* span = fBuffer;
uint32_t* device = fDevice.getAddr32(x, y);
SkShader* shader = fShader;
if (fXfermode) {
for (;;) {
SkXfermode* xfer = fXfermode;
int count = *runs;
if (count <= 0)
break;
int aa = *antialias;
if (aa) {
shader->shadeSpan(x, y, span, count);
if (aa == 255) {
xfer->xfer32(device, span, count, NULL);
} else {
// count is almost always 1
for (int i = count - 1; i >= 0; --i) {
xfer->xfer32(&device[i], &span[i], 1, antialias);
}
}
}
device += count;
runs += count;
antialias += count;
x += count;
}
} else if (fShader->getFlags() & SkShader::kOpaqueAlpha_Flag) {
for (;;) {
int count = *runs;
if (count <= 0) {
break;
}
int aa = *antialias;
if (aa) {
if (aa == 255) {
// cool, have the shader draw right into the device
shader->shadeSpan(x, y, device, count);
} else {
shader->shadeSpan(x, y, span, count);
fProc32Blend(device, span, count, aa);
}
}
device += count;
runs += count;
antialias += count;
x += count;
}
} else { // no xfermode but the shader not opaque
for (;;) {
int count = *runs;
if (count <= 0) {
break;
}
int aa = *antialias;
if (aa) {
fShader->shadeSpan(x, y, span, count);
if (aa == 255) {
fProc32(device, span, count, 255);
} else {
fProc32Blend(device, span, count, aa);
}
}
device += count;
runs += count;
antialias += count;
x += count;
}
}
}