remove all references to legacy Config8888

BUG=skia:
R=bsalomon@google.com

Review URL: https://codereview.chromium.org/211043002

git-svn-id: http://skia.googlecode.com/svn/trunk@13952 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2014-03-26 13:44:58 +00:00
parent da0ceb2299
commit f20fc24a7d
13 changed files with 1 additions and 328 deletions

View File

@ -188,16 +188,6 @@ protected:
return pr;
}
/**
* Implements readPixels API. The caller will ensure that:
* 1. bitmap has pixel config kARGB_8888_Config.
* 2. bitmap has pixels.
* 3. The rectangle (x, y, x + bitmap->width(), y + bitmap->height()) is
* contained in the device bounds.
*/
#ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
virtual bool onReadPixels(const SkBitmap&, int x, int y, SkCanvas::Config8888) SK_OVERRIDE;
#endif
virtual bool onReadPixels(const SkImageInfo&, void*, size_t, int x, int y) SK_OVERRIDE;
virtual bool onWritePixels(const SkImageInfo&, const void*, size_t, int, int) SK_OVERRIDE;
virtual void* onAccessPixels(SkImageInfo* info, size_t* rowBytes) SK_OVERRIDE;

View File

@ -18,14 +18,6 @@
#include "SkRegion.h"
#include "SkXfermode.h"
//#define SK_SUPPORT_LEGACY_READPIXELSCONFIG
#ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
#ifndef SK_SUPPORT_LEGACY_CONFIG8888
#define SK_SUPPORT_LEGACY_CONFIG8888
#endif
#endif
// if not defined, we always assume ClipToLayer for saveLayer()
//#define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
@ -237,83 +229,6 @@ public:
*/
const void* peekPixels(SkImageInfo* info, size_t* rowBytes);
#ifdef SK_SUPPORT_LEGACY_CONFIG8888
/**
* This enum can be used with read/writePixels to perform a pixel ops to or
* from an 8888 config other than Skia's native config (SkPMColor). There
* are three byte orders supported: native, BGRA, and RGBA. Each has a
* premultiplied and unpremultiplied variant.
*
* Components of a 8888 pixel can be packed/unpacked from a 32bit word using
* either byte offsets or shift values. Byte offsets are endian-invariant
* while shifts are not. BGRA and RGBA configs are defined by byte
* orderings. The native config is defined by shift values (SK_A32_SHIFT,
* ..., SK_B32_SHIFT).
*/
enum Config8888 {
/**
* Skia's native order specified by:
* SK_A32_SHIFT, SK_R32_SHIFT, SK_G32_SHIFT, and SK_B32_SHIFT
*
* kNative_Premul_Config8888 is equivalent to SkPMColor
* kNative_Unpremul_Config8888 has the same component order as SkPMColor
* but is not premultiplied.
*/
kNative_Premul_Config8888,
kNative_Unpremul_Config8888,
/**
* low byte to high byte: B, G, R, A.
*/
kBGRA_Premul_Config8888,
kBGRA_Unpremul_Config8888,
/**
* low byte to high byte: R, G, B, A.
*/
kRGBA_Premul_Config8888,
kRGBA_Unpremul_Config8888
};
#endif
#ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
/**
* On success (returns true), copy the canvas pixels into the bitmap.
* On failure, the bitmap parameter is left unchanged and false is
* returned.
*
* The canvas' pixels are converted to the bitmap's config. The only
* supported config is kARGB_8888_Config, though this is likely to be
* relaxed in the future. The meaning of config kARGB_8888_Config is
* modified by the enum param config8888. The default value interprets
* kARGB_8888_Config as SkPMColor
*
* If the bitmap has pixels already allocated, the canvas pixels will be
* written there. If not, bitmap->allocPixels() will be called
* automatically. If the bitmap is backed by a texture readPixels will
* fail.
*
* The actual pixels written is the intersection of the canvas' bounds, and
* the rectangle formed by the bitmap's width,height and the specified x,y.
* If bitmap pixels extend outside of that intersection, they will not be
* modified.
*
* Other failure conditions:
* * If the canvas is backed by a non-raster device (e.g. PDF) then
* readPixels will fail.
* * If bitmap is texture-backed then readPixels will fail. (This may be
* relaxed in the future.)
*
* Example that reads the entire canvas into a bitmap using the native
* SkPMColor:
* SkISize size = canvas->getDeviceSize();
* bitmap->setConfig(SkBitmap::kARGB_8888_Config, size.fWidth,
* size.fHeight);
* if (canvas->readPixels(bitmap, 0, 0)) {
* // use the pixels
* }
*/
bool readPixels(SkBitmap* bitmap, int x, int y, Config8888 config8888);
#endif
/**
* Copy the pixels from the base-layer into the specified buffer (pixels + rowBytes),
* converting them into the requested format (SkImageInfo). The base-layer pixels are read
@ -846,7 +761,7 @@ public:
width/height will be the edge color replicated.
If a shader is present on the paint it will be ignored, except in the
case where the bitmap is kA8_Config. In that case, the color is
case where the bitmap is kAlpha_8_SkColorType. In that case, the color is
generated by the shader.
@param bitmap The bitmap to be drawn

View File

@ -287,38 +287,6 @@ protected:
virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y,
const SkPaint&) = 0;
#ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
/**
* On success (returns true), copy the device pixels into the bitmap.
* On failure, the bitmap parameter is left unchanged and false is
* returned.
*
* The device's pixels are converted to the bitmap's config. The only
* supported config is kARGB_8888_Config, though this is likely to be
* relaxed in the future. The meaning of config kARGB_8888_Config is
* modified by the enum param config8888. The default value interprets
* kARGB_8888_Config as SkPMColor
*
* If the bitmap has pixels already allocated, the device pixels will be
* written there. If not, bitmap->allocPixels() will be called
* automatically. If the bitmap is backed by a texture readPixels will
* fail.
*
* The actual pixels written is the intersection of the device's bounds,
* and the rectangle formed by the bitmap's width,height and the specified
* x,y. If bitmap pixels extend outside of that intersection, they will not
* be modified.
*
* Other failure conditions:
* * If the device is not a raster device (e.g. PDF) then readPixels will
* fail.
* * If bitmap is texture-backed then readPixels will fail. (This may be
* relaxed in the future.)
*/
bool readPixels(SkBitmap* bitmap,
int x, int y,
SkCanvas::Config8888 config8888);
#endif
bool readPixels(const SkImageInfo&, void* dst, size_t rowBytes, int x, int y);
///////////////////////////////////////////////////////////////////////////
@ -363,12 +331,6 @@ protected:
const SkImageFilter::Context& ctx,
SkBitmap* result, SkIPoint* offset) = 0;
#ifdef SK_SUPPORT_LEGACY_CONFIG8888
// This is equal kBGRA_Premul_Config8888 or kRGBA_Premul_Config8888 if
// either is identical to kNative_Premul_Config8888. Otherwise, -1.
static const SkCanvas::Config8888 kPMColorAlias;
#endif
protected:
// default impl returns NULL
virtual SkSurface* newSurface(const SkImageInfo&);
@ -376,17 +338,6 @@ protected:
// default impl returns NULL
virtual const void* peekPixels(SkImageInfo*, size_t* rowBytes);
/**
* Implements readPixels API. The caller will ensure that:
* 1. bitmap has pixel config kARGB_8888_Config.
* 2. bitmap has pixels.
* 3. The rectangle (x, y, x + bitmap->width(), y + bitmap->height()) is
* contained in the device bounds.
*/
#ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
virtual bool onReadPixels(const SkBitmap& bitmap, int x, int y, SkCanvas::Config8888);
#endif
/**
* The caller is responsible for "pre-clipping" the dst. The impl can assume that the dst
* image at the specified x,y offset will fit within the device's bounds.

View File

@ -141,13 +141,6 @@ protected:
int x, int y,
const SkPaint& paint) SK_OVERRIDE;
#ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
virtual bool onReadPixels(const SkBitmap& bitmap,
int x,
int y,
SkCanvas::Config8888) SK_OVERRIDE;
#endif
virtual bool allowImageFilter(const SkImageFilter*) SK_OVERRIDE;
private:

View File

@ -153,9 +153,6 @@ public:
protected:
#ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
virtual bool onReadPixels(const SkBitmap&, int x, int y, SkCanvas::Config8888) SK_OVERRIDE;
#endif
virtual bool onReadPixels(const SkImageInfo&, void*, size_t, int, int) SK_OVERRIDE;
virtual bool onWritePixels(const SkImageInfo&, const void*, size_t, int, int) SK_OVERRIDE;

View File

@ -208,10 +208,6 @@ public:
}
protected:
#ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
virtual bool onReadPixels(const SkBitmap& bitmap, int x, int y,
SkCanvas::Config8888) SK_OVERRIDE;
#endif
virtual bool allowImageFilter(const SkImageFilter*) SK_OVERRIDE;
private:

View File

@ -173,34 +173,6 @@ bool SkBitmapDevice::allowImageFilter(const SkImageFilter*) {
return true;
}
#ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
bool SkBitmapDevice::onReadPixels(const SkBitmap& bitmap,
int x, int y,
SkCanvas::Config8888 config8888) {
SkASSERT(SkBitmap::kARGB_8888_Config == bitmap.config());
SkASSERT(!bitmap.isNull());
SkASSERT(SkIRect::MakeWH(this->width(), this->height()).contains(SkIRect::MakeXYWH(x, y,
bitmap.width(),
bitmap.height())));
SkIRect srcRect = SkIRect::MakeXYWH(x, y, bitmap.width(), bitmap.height());
const SkBitmap& src = this->accessBitmap(false);
SkBitmap subset;
if (!src.extractSubset(&subset, srcRect)) {
return false;
}
if (kPMColor_SkColorType != subset.colorType()) {
// It'd be preferable to do this directly to bitmap.
subset.copyTo(&subset, kPMColor_SkColorType);
}
SkAutoLockPixels alp(bitmap);
uint32_t* bmpPixels = reinterpret_cast<uint32_t*>(bitmap.getPixels());
SkCopyBitmapToConfig8888(bmpPixels, bitmap.rowBytes(), config8888, subset);
return true;
}
#endif
void* SkBitmapDevice::onAccessPixels(SkImageInfo* info, size_t* rowBytes) {
if (fBitmap.getPixels()) {
*info = fBitmap.info();

View File

@ -667,18 +667,6 @@ SkBaseDevice* SkCanvas::setRootDevice(SkBaseDevice* device) {
return device;
}
#ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
bool SkCanvas::readPixels(SkBitmap* bitmap,
int x, int y,
Config8888 config8888) {
SkBaseDevice* device = this->getDevice();
if (!device) {
return false;
}
return device->readPixels(bitmap, x, y, config8888);
}
#endif
bool SkCanvas::readPixels(SkBitmap* bitmap, int x, int y) {
if (kUnknown_SkColorType == bitmap->colorType() || bitmap->getTexture()) {
return false;

View File

@ -102,54 +102,6 @@ const SkBitmap& SkBaseDevice::accessBitmap(bool changePixels) {
return bitmap;
}
#ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
bool SkBaseDevice::readPixels(SkBitmap* bitmap, int x, int y,
SkCanvas::Config8888 config8888) {
if (SkBitmap::kARGB_8888_Config != bitmap->config() ||
NULL != bitmap->getTexture()) {
return false;
}
const SkBitmap& src = this->accessBitmap(false);
SkIRect srcRect = SkIRect::MakeXYWH(x, y, bitmap->width(),
bitmap->height());
SkIRect devbounds = SkIRect::MakeWH(src.width(), src.height());
if (!srcRect.intersect(devbounds)) {
return false;
}
SkBitmap tmp;
SkBitmap* bmp;
if (bitmap->isNull()) {
if (!tmp.allocPixels(SkImageInfo::MakeN32Premul(bitmap->width(),
bitmap->height()))) {
return false;
}
bmp = &tmp;
} else {
bmp = bitmap;
}
SkIRect subrect = srcRect;
subrect.offset(-x, -y);
SkBitmap bmpSubset;
bmp->extractSubset(&bmpSubset, subrect);
bool result = this->onReadPixels(bmpSubset,
srcRect.fLeft,
srcRect.fTop,
config8888);
if (result && bmp == &tmp) {
tmp.swap(*bitmap);
}
return result;
}
bool SkBaseDevice::onReadPixels(const SkBitmap&, int x, int y, SkCanvas::Config8888) {
return false;
}
#endif
SkSurface* SkBaseDevice::newSurface(const SkImageInfo&) { return NULL; }
const void* SkBaseDevice::peekPixels(SkImageInfo*, size_t*) { return NULL; }

View File

@ -2408,13 +2408,6 @@ void SkXPSDevice::drawDevice(const SkDraw& d, SkBaseDevice* dev,
"Could not add layer to current visuals.");
}
#ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
bool SkXPSDevice::onReadPixels(const SkBitmap& bitmap, int x, int y,
SkCanvas::Config8888) {
return false;
}
#endif
SkBaseDevice* SkXPSDevice::onCreateDevice(const SkImageInfo&, Usage) {
//Conditional for bug compatibility with PDF device.
#if 0

View File

@ -343,59 +343,6 @@ void SkGpuDevice::makeRenderTargetCurrent() {
///////////////////////////////////////////////////////////////////////////////
#ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
namespace {
GrPixelConfig config8888_to_grconfig_and_flags(SkCanvas::Config8888 config8888, uint32_t* flags) {
switch (config8888) {
case SkCanvas::kNative_Premul_Config8888:
*flags = 0;
return kSkia8888_GrPixelConfig;
case SkCanvas::kNative_Unpremul_Config8888:
*flags = GrContext::kUnpremul_PixelOpsFlag;
return kSkia8888_GrPixelConfig;
case SkCanvas::kBGRA_Premul_Config8888:
*flags = 0;
return kBGRA_8888_GrPixelConfig;
case SkCanvas::kBGRA_Unpremul_Config8888:
*flags = GrContext::kUnpremul_PixelOpsFlag;
return kBGRA_8888_GrPixelConfig;
case SkCanvas::kRGBA_Premul_Config8888:
*flags = 0;
return kRGBA_8888_GrPixelConfig;
case SkCanvas::kRGBA_Unpremul_Config8888:
*flags = GrContext::kUnpremul_PixelOpsFlag;
return kRGBA_8888_GrPixelConfig;
default:
GrCrash("Unexpected Config8888.");
*flags = 0; // suppress warning
return kSkia8888_GrPixelConfig;
}
}
}
bool SkGpuDevice::onReadPixels(const SkBitmap& bitmap,
int x, int y,
SkCanvas::Config8888 config8888) {
DO_DEFERRED_CLEAR();
SkASSERT(SkBitmap::kARGB_8888_Config == bitmap.config());
SkASSERT(!bitmap.isNull());
SkASSERT(SkIRect::MakeWH(this->width(), this->height()).contains(SkIRect::MakeXYWH(x, y, bitmap.width(), bitmap.height())));
SkAutoLockPixels alp(bitmap);
GrPixelConfig config;
uint32_t flags;
config = config8888_to_grconfig_and_flags(config8888, &flags);
return fContext->readRenderTargetPixels(fRenderTarget,
x, y,
bitmap.width(),
bitmap.height(),
config,
bitmap.getPixels(),
bitmap.rowBytes(),
flags);
}
#endif
bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
int x, int y) {
DO_DEFERRED_CLEAR();

View File

@ -2307,13 +2307,6 @@ void SkPDFDevice::internalDrawBitmap(const SkMatrix& origMatrix,
&content.entry()->fContent);
}
#ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y,
SkCanvas::Config8888) {
return false;
}
#endif
bool SkPDFDevice::allowImageFilter(const SkImageFilter*) {
return false;
}

View File

@ -171,11 +171,6 @@ public:
protected:
virtual const SkBitmap& onAccessBitmap() SK_OVERRIDE;
#ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
virtual bool onReadPixels(const SkBitmap& bitmap,
int x, int y,
SkCanvas::Config8888 config8888) SK_OVERRIDE;
#endif
virtual bool onReadPixels(const SkImageInfo&, void*, size_t, int x, int y) SK_OVERRIDE;
virtual bool onWritePixels(const SkImageInfo&, const void*, size_t, int x, int y) SK_OVERRIDE;
@ -509,15 +504,6 @@ SkSurface* SkDeferredDevice::newSurface(const SkImageInfo& info) {
return this->immediateDevice()->newSurface(info);
}
#ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
bool SkDeferredDevice::onReadPixels(
const SkBitmap& bitmap, int x, int y, SkCanvas::Config8888 config8888) {
this->flushPendingCommands(kNormal_PlaybackMode);
return fImmediateCanvas->readPixels(const_cast<SkBitmap*>(&bitmap),
x, y, config8888);
}
#endif
bool SkDeferredDevice::onReadPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
int x, int y) {
this->flushPendingCommands(kNormal_PlaybackMode);