| Index: src/core/SkConfig8888.h
|
| diff --git a/src/core/SkConfig8888.h b/src/core/SkConfig8888.h
|
| index 97a3433ad24281f289d50c3b00c708a8066c9cf7..041773e6df433c22297bb2dd82d9d625b02c862a 100644
|
| --- a/src/core/SkConfig8888.h
|
| +++ b/src/core/SkConfig8888.h
|
| @@ -5,27 +5,75 @@
|
| * found in the LICENSE file.
|
| */
|
|
|
| -#ifndef SkPixelInfo_DEFINED
|
| -#define SkPixelInfo_DEFINED
|
| +#ifndef SkConfig8888_DEFINED
|
| +#define SkConfig8888_DEFINED
|
|
|
| -#include "SkImageInfo.h"
|
| +#include "SkCanvas.h"
|
| +#include "SkColorPriv.h"
|
|
|
| -struct SkPixelInfo {
|
| - SkColorType fColorType;
|
| - SkAlphaType fAlphaType;
|
| - size_t fRowBytes;
|
| -};
|
| +/**
|
| + * Converts pixels from one Config8888 to another Config8888
|
| + */
|
| +void SkConvertConfig8888Pixels(uint32_t* dstPixels,
|
| + size_t dstRowBytes,
|
| + SkCanvas::Config8888 dstConfig,
|
| + const uint32_t* srcPixels,
|
| + size_t srcRowBytes,
|
| + SkCanvas::Config8888 srcConfig,
|
| + int width,
|
| + int height);
|
| +
|
| +/**
|
| + * Packs a, r, g, b, values into byte order specified by config.
|
| + */
|
| +uint32_t SkPackConfig8888(SkCanvas::Config8888 config,
|
| + uint32_t a,
|
| + uint32_t r,
|
| + uint32_t g,
|
| + uint32_t b);
|
| +
|
| +///////////////////////////////////////////////////////////////////////////////
|
| +// Implementation
|
| +
|
| +namespace {
|
|
|
| -struct SkDstPixelInfo : SkPixelInfo {
|
| - void* fPixels;
|
| -};
|
| +/**
|
| + Copies all pixels from a bitmap to a dst ptr with a given rowBytes and
|
| + Config8888. The bitmap must have kARGB_8888_Config.
|
| + */
|
| +
|
| +static inline void SkCopyBitmapToConfig8888(uint32_t* dstPixels,
|
| + size_t dstRowBytes,
|
| + SkCanvas::Config8888 dstConfig8888,
|
| + const SkBitmap& srcBmp) {
|
| + SkASSERT(SkBitmap::kARGB_8888_Config == srcBmp.config());
|
| + SkAutoLockPixels alp(srcBmp);
|
| + int w = srcBmp.width();
|
| + int h = srcBmp.height();
|
| + size_t srcRowBytes = srcBmp.rowBytes();
|
| + const uint32_t* srcPixels = reinterpret_cast<uint32_t*>(srcBmp.getPixels());
|
| +
|
| + SkConvertConfig8888Pixels(dstPixels, dstRowBytes, dstConfig8888, srcPixels, srcRowBytes, SkCanvas::kNative_Premul_Config8888, w, h);
|
| +}
|
| +
|
| +/**
|
| + Copies over all pixels in a bitmap from a src ptr with a given rowBytes and
|
| + Config8888. The bitmap must have pixels and be kARGB_8888_Config.
|
| + */
|
| +static inline void SkCopyConfig8888ToBitmap(const SkBitmap& dstBmp,
|
| + const uint32_t* srcPixels,
|
| + size_t srcRowBytes,
|
| + SkCanvas::Config8888 srcConfig8888) {
|
| + SkASSERT(SkBitmap::kARGB_8888_Config == dstBmp.config());
|
| + SkAutoLockPixels alp(dstBmp);
|
| + int w = dstBmp.width();
|
| + int h = dstBmp.height();
|
| + size_t dstRowBytes = dstBmp.rowBytes();
|
| + uint32_t* dstPixels = reinterpret_cast<uint32_t*>(dstBmp.getPixels());
|
|
|
| -struct SkSrcPixelInfo : SkPixelInfo {
|
| - const void* fPixels;
|
| + SkConvertConfig8888Pixels(dstPixels, dstRowBytes, SkCanvas::kNative_Premul_Config8888, srcPixels, srcRowBytes, srcConfig8888, w, h);
|
| +}
|
|
|
| - // Guaranteed to work even if src.fPixels and dst.fPixels are the same
|
| - // (but not if they overlap partially)
|
| - bool convertPixelsTo(SkDstPixelInfo* dst, int width, int height) const;
|
| -};
|
| +}
|
|
|
| #endif
|
|
|