本文整理汇总了C++中SkGetPackedA32函数的典型用法代码示例。如果您正苦于以下问题:C++ SkGetPackedA32函数的具体用法?C++ SkGetPackedA32怎么用?C++ SkGetPackedA32使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SkGetPackedA32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: S32A_D565_Blend_01
static inline bool S32A_D565_Blend_01(SkPMColor sc, uint16_t dc, U8CPU alpha) {
unsigned dst_scale = 255 - SkMulDiv255Round(SkGetPackedA32(sc), alpha);
unsigned dr = SkMulS16(SkGetPackedR32(sc), alpha) + SkMulS16(SkGetPackedR16(dc) << 3, dst_scale);
unsigned dg = SkMulS16(SkGetPackedG32(sc), alpha) + SkMulS16(SkGetPackedG16(dc) << 2, dst_scale);
unsigned rr = SkDiv255Round(dr) >> 3;
unsigned rg = SkDiv255Round(dg) >> 2;
if (rr <= 31 && rg <= 63) {
return true;
}
return false;
}
示例2: SkPMColorToColor
SkColor SkPMColorToColor(SkPMColor pm)
{
if (0 == pm)
return 0;
unsigned a = SkGetPackedA32(pm);
uint32_t scale = (255 << 16) / a;
return SkColorSetARGB(a,
InvScaleByte(SkGetPackedR32(pm), scale),
InvScaleByte(SkGetPackedG32(pm), scale),
InvScaleByte(SkGetPackedB32(pm), scale));
}
示例3: extract_argb8888_data
static SkStream* extract_argb8888_data(const SkBitmap& bitmap,
const SkIRect& srcRect,
bool extractAlpha,
bool* isOpaque,
bool* isTransparent) {
size_t streamSize = extractAlpha ? srcRect.width() * srcRect.height()
: get_uncompressed_size(bitmap, srcRect);
SkStream* stream = SkNEW_ARGS(SkMemoryStream, (streamSize));
uint8_t* dst = (uint8_t*)stream->getMemoryBase();
const SkUnPreMultiply::Scale* scaleTable = SkUnPreMultiply::GetScaleTable();
for (int y = srcRect.fTop; y < srcRect.fBottom; y++) {
uint32_t* src = bitmap.getAddr32(0, y);
for (int x = srcRect.fLeft; x < srcRect.fRight; x++) {
SkPMColor c = src[x];
U8CPU alpha = SkGetPackedA32(c);
if (extractAlpha) {
*isOpaque &= alpha == SK_AlphaOPAQUE;
*isTransparent &= alpha == SK_AlphaTRANSPARENT;
*dst++ = alpha;
} else {
if (SK_AlphaTRANSPARENT == alpha) {
// It is necessary to average the color component of
// transparent pixels with their surrounding neighbors
// since the PDF renderer may separately re-sample the
// alpha and color channels when the image is not
// displayed at its native resolution. Since an alpha of
// zero gives no information about the color component,
// the pathological case is a white image with sharp
// transparency bounds - the color channel goes to black,
// and the should-be-transparent pixels are rendered
// as grey because of the separate soft mask and color
// resizing.
c = get_argb8888_neighbor_avg_color(bitmap, x, y);
*dst++ = SkGetPackedR32(c);
*dst++ = SkGetPackedG32(c);
*dst++ = SkGetPackedB32(c);
} else {
SkUnPreMultiply::Scale s = scaleTable[alpha];
*dst++ = SkUnPreMultiply::ApplyScale(s, SkGetPackedR32(c));
*dst++ = SkUnPreMultiply::ApplyScale(s, SkGetPackedG32(c));
*dst++ = SkUnPreMultiply::ApplyScale(s, SkGetPackedB32(c));
}
}
}
}
SkASSERT(dst == streamSize + (uint8_t*)stream->getMemoryBase());
return stream;
}
示例4: SkGetPackedA32
bool Image::ConvertToRGBA(Image *nimg,
unsigned char *rgba,
bool flipY,
bool premultiply)
{
int length;
int k;
const unsigned char *pixels;
int width;
nimg->m_Image->lockPixels();
if ((pixels
= static_cast<const unsigned char *>(nimg->m_Image->getPixels()))
== NULL) {
nimg->m_Image->unlockPixels();
return false;
}
width = nimg->getWidth();
length = width * nimg->getHeight() * 4;
width *= 4;
k = flipY ? length - width : 0;
for (int i = 0; i < length; i += 4) {
const uint32_t pixel = *reinterpret_cast<const uint32_t *>(&pixels[i]);
int alpha = SkGetPackedA32(pixel);
if (alpha != 0 && alpha != 255 && !premultiply) {
SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(pixel);
rgba[k + 0] = SkColorGetR(unmultiplied);
rgba[k + 1] = SkColorGetG(unmultiplied);
rgba[k + 2] = SkColorGetB(unmultiplied);
rgba[k + 3] = alpha;
} else {
rgba[k + 0] = SkGetPackedR32(pixel);
rgba[k + 1] = SkGetPackedG32(pixel);
rgba[k + 2] = SkGetPackedB32(pixel);
rgba[k + 3] = alpha;
}
if (flipY && (i + 4) % width == 0) {
k = length - (i + 4) - width;
} else {
k += 4;
}
}
return true;
}
示例5: xferA8
virtual void xferA8(SK_RESTRICT SkAlpha dst[],
const SK_RESTRICT SkPMColor src[], int count,
const SK_RESTRICT SkAlpha aa[]) {
SkASSERT(dst && src && count >= 0);
if (NULL == aa) {
for (int i = count - 1; i >= 0; --i) {
dst[i] = SkToU8(SkGetPackedA32(src[i]));
}
} else {
for (int i = count - 1; i >= 0; --i) {
unsigned a = aa[i];
if (0 != a) {
unsigned srcA = SkGetPackedA32(src[i]);
if (a == 0xFF) {
dst[i] = SkToU8(srcA);
} else {
dst[i] = SkToU8(SkAlphaBlend(srcA, dst[i], a));
}
}
}
}
}
示例6: S32A_D565_Blend_2
static inline bool S32A_D565_Blend_2(SkPMColor sc, uint16_t dc, U8CPU alpha) {
unsigned dst_scale = 255*255 - SkGetPackedA32(sc) * alpha;
alpha *= 255;
unsigned dr = (SkGetPackedR32(sc) >> 3) * alpha + SkGetPackedR16(dc) * dst_scale;
unsigned dg = (SkGetPackedG32(sc) >> 2) * alpha + SkGetPackedG16(dc) * dst_scale;
unsigned rr = SkDiv65025Round(dr);
unsigned rg = SkDiv65025Round(dg);
if (rr <= 31 && rg <= 63) {
return true;
}
return false;
}
示例7: alphaBlendNonPremultiplied
void alphaBlendNonPremultiplied(blink::ImageFrame& src,
blink::ImageFrame& dst,
int canvasY,
int left,
int width) {
for (int x = 0; x < width; ++x) {
int canvasX = left + x;
blink::ImageFrame::PixelData& pixel = *src.getAddr(canvasX, canvasY);
if (SkGetPackedA32(pixel) != 0xff) {
blink::ImageFrame::PixelData prevPixel = *dst.getAddr(canvasX, canvasY);
pixel = blendSrcOverDstNonPremultiplied(pixel, prevPixel);
}
}
}
示例8: cubicBlend
inline SkPMColor cubicBlend(const SkScalar c[16], SkScalar t, SkPMColor c0, SkPMColor c1, SkPMColor c2, SkPMColor c3) {
SkScalar t2 = t * t, t3 = t2 * t;
SkScalar cc[4];
// FIXME: For the fractx case, this should be refactored out of this function.
cc[0] = c[0] + SkScalarMul(c[1], t) + SkScalarMul(c[2], t2) + SkScalarMul(c[3], t3);
cc[1] = c[4] + SkScalarMul(c[5], t) + SkScalarMul(c[6], t2) + SkScalarMul(c[7], t3);
cc[2] = c[8] + SkScalarMul(c[9], t) + SkScalarMul(c[10], t2) + SkScalarMul(c[11], t3);
cc[3] = c[12] + SkScalarMul(c[13], t) + SkScalarMul(c[14], t2) + SkScalarMul(c[15], t3);
SkScalar a = SkScalarClampMax(SkScalarMul(cc[0], SkGetPackedA32(c0)) + SkScalarMul(cc[1], SkGetPackedA32(c1)) + SkScalarMul(cc[2], SkGetPackedA32(c2)) + SkScalarMul(cc[3], SkGetPackedA32(c3)), 255);
SkScalar r = SkScalarMul(cc[0], SkGetPackedR32(c0)) + SkScalarMul(cc[1], SkGetPackedR32(c1)) + SkScalarMul(cc[2], SkGetPackedR32(c2)) + SkScalarMul(cc[3], SkGetPackedR32(c3));
SkScalar g = SkScalarMul(cc[0], SkGetPackedG32(c0)) + SkScalarMul(cc[1], SkGetPackedG32(c1)) + SkScalarMul(cc[2], SkGetPackedG32(c2)) + SkScalarMul(cc[3], SkGetPackedG32(c3));
SkScalar b = SkScalarMul(cc[0], SkGetPackedB32(c0)) + SkScalarMul(cc[1], SkGetPackedB32(c1)) + SkScalarMul(cc[2], SkGetPackedB32(c2)) + SkScalarMul(cc[3], SkGetPackedB32(c3));
return SkPackARGB32(SkScalarRoundToInt(a),
SkScalarRoundToInt(SkScalarClampMax(r, a)),
SkScalarRoundToInt(SkScalarClampMax(g, a)),
SkScalarRoundToInt(SkScalarClampMax(b, a)));
}
示例9: S32A_D565_Blend_02
static inline bool S32A_D565_Blend_02(SkPMColor sc, uint16_t dc, U8CPU alpha) {
unsigned dst_scale = 255 - SkMulDiv255Round(SkGetPackedA32(sc), alpha);
unsigned dr = SkMulS16(SkGetPackedR32(sc), alpha) + SkMulS16(GetPackedR16As32(dc), dst_scale);
unsigned dg = SkMulS16(SkGetPackedG32(sc), alpha) + SkMulS16(GetPackedG16As32(dc), dst_scale);
unsigned db = SkMulS16(SkGetPackedB32(sc), alpha) + SkMulS16(GetPackedB16As32(dc), dst_scale);
int rc = SkPack888ToRGB16(SkDiv255Round(dr),
SkDiv255Round(dg),
SkDiv255Round(db));
unsigned rr = SkGetPackedR16(rc);
unsigned rg = SkGetPackedG16(rc);
if (rr <= 31 && rg <= 63) {
return true;
}
return false;
}
示例10: D16_S32A_Blend_Pixel_helper
static inline void D16_S32A_Blend_Pixel_helper(uint16_t* dst, SkPMColor sc,
unsigned src_scale) {
uint16_t dc = *dst;
unsigned sa = SkGetPackedA32(sc);
unsigned dr, dg, db;
if (255 == sa) {
dr = SkAlphaBlend(SkPacked32ToR16(sc), SkGetPackedR16(dc), src_scale);
dg = SkAlphaBlend(SkPacked32ToG16(sc), SkGetPackedG16(dc), src_scale);
db = SkAlphaBlend(SkPacked32ToB16(sc), SkGetPackedB16(dc), src_scale);
} else {
unsigned dst_scale = 255 - SkAlphaMul(sa, src_scale);
dr = (SkPacked32ToR16(sc) * src_scale + SkGetPackedR16(dc) * dst_scale) >> 8;
dg = (SkPacked32ToG16(sc) * src_scale + SkGetPackedG16(dc) * dst_scale) >> 8;
db = (SkPacked32ToB16(sc) * src_scale + SkGetPackedB16(dc) * dst_scale) >> 8;
}
*dst = SkPackRGB16(dr, dg, db);
}
示例11: filterSpan
virtual void filterSpan(const SkPMColor shader[], int count,
SkPMColor result[]) {
unsigned scaleR = SkAlpha255To256(SkColorGetR(fMul));
unsigned scaleG = SkAlpha255To256(SkColorGetG(fMul));
unsigned scaleB = SkAlpha255To256(SkColorGetB(fMul));
for (int i = 0; i < count; i++) {
SkPMColor c = shader[i];
if (c) {
unsigned a = SkGetPackedA32(c);
unsigned r = SkAlphaMul(SkGetPackedR32(c), scaleR);
unsigned g = SkAlphaMul(SkGetPackedG32(c), scaleG);
unsigned b = SkAlphaMul(SkGetPackedB32(c), scaleB);
c = SkPackARGB32(a, r, g, b);
}
result[i] = c;
}
}
示例12: check_gamma
bool check_gamma(uint32_t src, uint32_t dst, bool toSRGB, float error,
uint32_t* expected) {
bool result = true;
uint32_t expectedColor = src & 0xff000000;
// Alpha should always be exactly preserved.
if ((src & 0xff000000) != (dst & 0xff000000)) {
result = false;
}
// need to unpremul before we can perform srgb magic
float invScale = 0;
float alpha = SkGetPackedA32(src);
if (alpha) {
invScale = 255.0f / alpha;
}
for (int c = 0; c < 3; ++c) {
float srcComponent = ((src & (0xff << (c * 8))) >> (c * 8)) * invScale;
float lower = SkTMax(0.f, srcComponent - error);
float upper = SkTMin(255.f, srcComponent + error);
if (toSRGB) {
lower = linear_to_srgb(lower / 255.f);
upper = linear_to_srgb(upper / 255.f);
} else {
lower = srgb_to_linear(lower / 255.f);
upper = srgb_to_linear(upper / 255.f);
}
lower *= alpha;
upper *= alpha;
SkASSERT(lower >= 0.f && lower <= 255.f);
SkASSERT(upper >= 0.f && upper <= 255.f);
uint8_t dstComponent = (dst & (0xff << (c * 8))) >> (c * 8);
if (dstComponent < SkScalarFloorToInt(lower) ||
dstComponent > SkScalarCeilToInt(upper)) {
result = false;
}
uint8_t expectedComponent = SkScalarRoundToInt((lower + upper) * 0.5f);
expectedColor |= expectedComponent << (c * 8);
}
*expected = expectedColor;
return result;
}
示例13: extract_alpha
static void extract_alpha(const SkMask& dst,
const SkPMColor* srcRow, size_t srcRB) {
int width = dst.fBounds.width();
int height = dst.fBounds.height();
int dstRB = dst.fRowBytes;
uint8_t* dstRow = dst.fImage;
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
dstRow[x] = SkGetPackedA32(srcRow[x]);
}
// zero any padding on each row
for (int x = width; x < dstRB; ++x) {
dstRow[x] = 0;
}
dstRow += dstRB;
srcRow = (const SkPMColor*)((const char*)srcRow + srcRB);
}
}
示例14: xfer32
virtual void xfer32(SK_RESTRICT SkPMColor dst[],
const SK_RESTRICT SkPMColor src[], int count,
const SK_RESTRICT SkAlpha aa[]) {
SkASSERT(dst && src);
if (count <= 0) {
return;
}
if (NULL != aa) {
return this->INHERITED::xfer32(dst, src, count, aa);
}
do {
unsigned a = SkGetPackedA32(*src);
*dst = SkAlphaMulQ(*dst, SkAlpha255To256(255 - a));
dst++;
src++;
} while (--count != 0);
}
示例15: 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);
}
}