зеркало из https://github.com/mozilla/moz-skia.git
move SkImage::ColorType into SkColorType
objective -- move clients over to SkImage tasks - use SkImageInfo instead of SkBitmap::Config - add support for colortables to SkImage - add drawImage to SkCanvas - return SkImage from readPixels This CL works towards the first task R=robertphillips@google.com Review URL: https://codereview.chromium.org/54363008 git-svn-id: http://skia.googlecode.com/svn/trunk@12077 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
05d56ebbf3
Коммит
2bd8b81005
|
@ -34,10 +34,10 @@ protected:
|
|||
virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
|
||||
// The canvas is not actually used for this test except to provide
|
||||
// configuration information: gpu, multisampling, size, etc?
|
||||
SkImage::Info info;
|
||||
SkImageInfo info;
|
||||
info.fWidth = kSurfaceWidth;
|
||||
info.fHeight = kSurfaceHeight;
|
||||
info.fColorType = SkImage::kPMColor_ColorType;
|
||||
info.fColorType = kPMColor_SkColorType;
|
||||
info.fAlphaType = kPremul_SkAlphaType;
|
||||
const SkRect fullCanvasRect = SkRect::MakeWH(
|
||||
SkIntToScalar(kSurfaceWidth), SkIntToScalar(kSurfaceHeight));
|
||||
|
|
|
@ -16,10 +16,10 @@ SkImageWidget::SkImageWidget(SkDebugger *debugger)
|
|||
, fDebugger(debugger) {
|
||||
this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cccccc;}");
|
||||
|
||||
SkImage::Info info;
|
||||
SkImageInfo info;
|
||||
info.fWidth = kImageWidgetWidth;
|
||||
info.fHeight = kImageWidgetHeight;
|
||||
info.fColorType = SkImage::kPMColor_ColorType;
|
||||
info.fColorType = kPMColor_SkColorType;
|
||||
info.fAlphaType = kPremul_SkAlphaType;
|
||||
|
||||
fSurface = SkSurface::NewRasterDirect(info, fPixels, 4 * kImageWidgetWidth);
|
||||
|
|
|
@ -178,8 +178,8 @@ protected:
|
|||
// since we draw into this directly, we need to start fresh
|
||||
sk_bzero(fBuffer, fBufferSize);
|
||||
|
||||
SkImage::Info info = {
|
||||
W, H, SkImage::kPMColor_ColorType, kPremul_SkAlphaType
|
||||
SkImageInfo info = {
|
||||
W, H, kPMColor_SkColorType, kPremul_SkAlphaType
|
||||
};
|
||||
SkAutoTUnref<SkSurface> surf0(SkSurface::NewRasterDirect(info, fBuffer, RB));
|
||||
SkAutoTUnref<SkSurface> surf1(SkSurface::NewRaster(info));
|
||||
|
|
|
@ -117,10 +117,10 @@ protected:
|
|||
|
||||
static SkSurface* compat_surface(SkCanvas* canvas, const SkISize& size,
|
||||
bool skipGPU) {
|
||||
SkImage::Info info = {
|
||||
SkImageInfo info = {
|
||||
size.width(),
|
||||
size.height(),
|
||||
SkImage::kPMColor_ColorType,
|
||||
kPMColor_SkColorType,
|
||||
kPremul_SkAlphaType
|
||||
};
|
||||
#if SK_SUPPORT_GPU
|
||||
|
|
|
@ -23,6 +23,30 @@ class GrTexture;
|
|||
// need for TileMode
|
||||
#include "SkShader.h"
|
||||
|
||||
enum SkColorType {
|
||||
kAlpha_8_SkColorType,
|
||||
kRGB_565_SkColorType,
|
||||
kRGBA_8888_SkColorType,
|
||||
kBGRA_8888_SkColorType,
|
||||
|
||||
#if SK_PMCOLOR_BYTE_ORDER(B,G,R,A)
|
||||
kPMColor_SkColorType = kBGRA_8888_SkColorType,
|
||||
#elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A)
|
||||
kPMColor_SkColorType = kRGBA_8888_SkColorType,
|
||||
#else
|
||||
#error "SK_*32_SHFIT values must correspond to BGRA or RGBA byte order"
|
||||
#endif
|
||||
|
||||
kLastEnum_SkColorType = kBGRA_8888_SkColorType
|
||||
};
|
||||
|
||||
struct SkImageInfo {
|
||||
int fWidth;
|
||||
int fHeight;
|
||||
SkColorType fColorType;
|
||||
SkAlphaType fAlphaType;
|
||||
};
|
||||
|
||||
/**
|
||||
* SkImage is an abstraction for drawing a rectagle of pixels, though the
|
||||
* particular type of image could be actually storing its data on the GPU, or
|
||||
|
@ -37,36 +61,27 @@ class SK_API SkImage : public SkRefCnt {
|
|||
public:
|
||||
SK_DECLARE_INST_COUNT(SkImage)
|
||||
|
||||
enum ColorType {
|
||||
kAlpha_8_ColorType,
|
||||
kRGB_565_ColorType,
|
||||
kRGBA_8888_ColorType,
|
||||
kBGRA_8888_ColorType,
|
||||
#ifdef SK_SUPPORT_LEGACY_COLORTYPE
|
||||
typedef SkColorType ColorType;
|
||||
|
||||
#if SK_PMCOLOR_BYTE_ORDER(B,G,R,A)
|
||||
kPMColor_ColorType = kBGRA_8888_ColorType,
|
||||
#elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A)
|
||||
kPMColor_ColorType = kRGBA_8888_ColorType,
|
||||
#else
|
||||
#error "SK_*32_SHFIT values must correspond to BGRA or RGBA byte order"
|
||||
static const SkColorType kAlpha_8_ColorType = kAlpha_8_SkColorType;
|
||||
static const SkColorType kRGB_565_ColorType = kRGB_565_SkColorType;
|
||||
static const SkColorType kRGBA_8888_ColorType = kRGBA_8888_SkColorType;
|
||||
static const SkColorType kBGRA_8888_ColorType = kBGRA_8888_SkColorType;
|
||||
static const SkColorType kPMColor_ColorType = kPMColor_SkColorType;
|
||||
static const SkColorType kLastEnum_ColorType = kLastEnum_SkColorType;
|
||||
#endif
|
||||
|
||||
kLastEnum_ColorType = kBGRA_8888_ColorType
|
||||
};
|
||||
|
||||
#ifdef SK_SUPPORT_LEGACY_ALPHATYPE
|
||||
typedef SkAlphaType AlphaType;
|
||||
|
||||
static const SkAlphaType kIgnore_AlphaType = kIgnore_SkAlphaType;
|
||||
static const SkAlphaType kOpaque_AlphaType = kOpaque_SkAlphaType;
|
||||
static const SkAlphaType kPremul_AlphaType = kPremul_SkAlphaType;
|
||||
static const SkAlphaType kUnpremul_AlphaType = kUnpremul_SkAlphaType;
|
||||
#endif
|
||||
|
||||
struct Info {
|
||||
int fWidth;
|
||||
int fHeight;
|
||||
ColorType fColorType;
|
||||
SkAlphaType fAlphaType;
|
||||
};
|
||||
typedef SkImageInfo Info;
|
||||
|
||||
static SkImage* NewRasterCopy(const Info&, const void* pixels, size_t rowBytes);
|
||||
static SkImage* NewRasterData(const Info&, SkData* pixels, size_t rowBytes);
|
||||
|
|
|
@ -377,7 +377,7 @@ public:
|
|||
* Sample usage:
|
||||
* <code>
|
||||
* // Determine the image's info: width/height/config
|
||||
* SkImage::Info info;
|
||||
* SkImageInfo info;
|
||||
* bool success = DecodeMemoryToTarget(src, size, &info, NULL);
|
||||
* if (!success) return;
|
||||
* // Allocate space for the result:
|
||||
|
@ -389,7 +389,7 @@ public:
|
|||
* success = DecodeMemoryToTarget(src, size, &info, &target);
|
||||
* </code>
|
||||
*/
|
||||
static bool DecodeMemoryToTarget(const void* buffer, size_t size, SkImage::Info* info,
|
||||
static bool DecodeMemoryToTarget(const void* buffer, size_t size, SkImageInfo* info,
|
||||
const SkBitmapFactory::Target* target);
|
||||
|
||||
/** Decode the image stored in the specified SkStreamRewindable, and store the result
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
* If the requested surface cannot be created, or the request is not a
|
||||
* supported configuration, NULL will be returned.
|
||||
*/
|
||||
static SkSurface* NewRasterDirect(const SkImage::Info&, void* pixels, size_t rowBytes);
|
||||
static SkSurface* NewRasterDirect(const SkImageInfo&, void* pixels, size_t rowBytes);
|
||||
|
||||
/**
|
||||
* Return a new surface, with the memory for the pixels automatically
|
||||
|
@ -44,16 +44,16 @@ public:
|
|||
* If the requested surface cannot be created, or the request is not a
|
||||
* supported configuration, NULL will be returned.
|
||||
*/
|
||||
static SkSurface* NewRaster(const SkImage::Info&);
|
||||
static SkSurface* NewRaster(const SkImageInfo&);
|
||||
|
||||
/**
|
||||
* Helper version of NewRaster. It creates a SkImage::Info with the
|
||||
* Helper version of NewRaster. It creates a SkImageInfo with the
|
||||
* specified width and height, and populates the rest of info to match
|
||||
* pixels in SkPMColor format.
|
||||
*/
|
||||
static SkSurface* NewRasterPMColor(int width, int height) {
|
||||
SkImage::Info info = {
|
||||
width, height, SkImage::kPMColor_ColorType, kPremul_SkAlphaType
|
||||
SkImageInfo info = {
|
||||
width, height, kPMColor_SkColorType, kPremul_SkAlphaType
|
||||
};
|
||||
return NewRaster(info);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public:
|
|||
* Return a new surface whose contents will be drawn to an offscreen
|
||||
* render target, allocated by the surface.
|
||||
*/
|
||||
static SkSurface* NewRenderTarget(GrContext*, const SkImage::Info&, int sampleCount = 0);
|
||||
static SkSurface* NewRenderTarget(GrContext*, const SkImageInfo&, int sampleCount = 0);
|
||||
|
||||
int width() const { return fWidth; }
|
||||
int height() const { return fHeight; }
|
||||
|
@ -133,7 +133,7 @@ public:
|
|||
* ... // draw using canvasB
|
||||
* canvasA->drawSurface(surfaceB); // <--- this will always be optimal!
|
||||
*/
|
||||
SkSurface* newSurface(const SkImage::Info&);
|
||||
SkSurface* newSurface(const SkImageInfo&);
|
||||
|
||||
/**
|
||||
* Returns an image of the current state of the surface pixels up to this
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
/**
|
||||
* Signature for a function to decode an image from encoded data.
|
||||
*/
|
||||
typedef bool (*DecodeProc)(const void* data, size_t length, SkImage::Info*, const Target*);
|
||||
typedef bool (*DecodeProc)(const void* data, size_t length, SkImageInfo*, const Target*);
|
||||
|
||||
/**
|
||||
* Create a bitmap factory which uses DecodeProc for decoding.
|
||||
|
@ -67,18 +67,18 @@ public:
|
|||
bool installPixelRef(SkData*, SkBitmap*);
|
||||
|
||||
/**
|
||||
* An object for selecting an SkImageCache to use based on an SkImage::Info.
|
||||
* An object for selecting an SkImageCache to use based on an SkImageInfo.
|
||||
*/
|
||||
class CacheSelector : public SkRefCnt {
|
||||
|
||||
public:
|
||||
SK_DECLARE_INST_COUNT(CacheSelector)
|
||||
/**
|
||||
* Return an SkImageCache to use based on the provided SkImage::Info. If the caller decides
|
||||
* Return an SkImageCache to use based on the provided SkImageInfo. If the caller decides
|
||||
* to hang on to the result, it will call ref, so the implementation should not add a ref
|
||||
* as a result of this call.
|
||||
*/
|
||||
virtual SkImageCache* selectCache(const SkImage::Info&) = 0;
|
||||
virtual SkImageCache* selectCache(const SkImageInfo&) = 0;
|
||||
|
||||
private:
|
||||
typedef SkRefCnt INHERITED;
|
||||
|
|
|
@ -26,8 +26,8 @@ JNIEXPORT void JNICALL Java_com_example_HelloSkiaActivity_drawIntoBitmap(JNIEnv*
|
|||
AndroidBitmap_getInfo(env, dstBitmap, &dstInfo);
|
||||
AndroidBitmap_lockPixels(env, dstBitmap, &dstPixels);
|
||||
|
||||
SkImage::Info info = {
|
||||
dstInfo.width, dstInfo.height, SkImage::kPMColor_ColorType,kPremul_SkAlphaType
|
||||
SkImageInfo info = {
|
||||
dstInfo.width, dstInfo.height, kPMColor_SkColorType, kPremul_SkAlphaType
|
||||
};
|
||||
|
||||
// Create a surface from the given bitmap
|
||||
|
|
|
@ -106,8 +106,8 @@ public:
|
|||
fInverse.setScale(SK_Scalar1 / zoom, SK_Scalar1 / zoom);
|
||||
fShader->setLocalMatrix(fMatrix);
|
||||
|
||||
SkImage::Info info = {
|
||||
width, height, SkImage::kPMColor_ColorType, SkImage::kPremul_AlphaType
|
||||
SkImageInfo info = {
|
||||
width, height, kPMColor_SkColorType, kPremul_SkAlphaType
|
||||
};
|
||||
fMinSurface.reset(SkSurface::NewRaster(info));
|
||||
info.fWidth *= zoom;
|
||||
|
|
|
@ -9,15 +9,15 @@
|
|||
#include "SkCanvas.h"
|
||||
#include "SkPicture.h"
|
||||
|
||||
SkBitmap::Config SkImageInfoToBitmapConfig(const SkImage::Info& info) {
|
||||
SkBitmap::Config SkImageInfoToBitmapConfig(const SkImageInfo& info) {
|
||||
switch (info.fColorType) {
|
||||
case SkImage::kAlpha_8_ColorType:
|
||||
case kAlpha_8_SkColorType:
|
||||
return SkBitmap::kA8_Config;
|
||||
|
||||
case SkImage::kRGB_565_ColorType:
|
||||
case kRGB_565_SkColorType:
|
||||
return SkBitmap::kRGB_565_Config;
|
||||
|
||||
case SkImage::kPMColor_ColorType:
|
||||
case kPMColor_SkColorType:
|
||||
return SkBitmap::kARGB_8888_Config;
|
||||
|
||||
default:
|
||||
|
@ -27,31 +27,31 @@ SkBitmap::Config SkImageInfoToBitmapConfig(const SkImage::Info& info) {
|
|||
return SkBitmap::kNo_Config;
|
||||
}
|
||||
|
||||
int SkImageBytesPerPixel(SkImage::ColorType ct) {
|
||||
int SkImageBytesPerPixel(SkColorType ct) {
|
||||
static const uint8_t gColorTypeBytesPerPixel[] = {
|
||||
1, // kAlpha_8_ColorType
|
||||
2, // kRGB_565_ColorType
|
||||
4, // kRGBA_8888_ColorType
|
||||
4, // kBGRA_8888_ColorType
|
||||
4, // kPMColor_ColorType
|
||||
1, // kAlpha_8_SkColorType
|
||||
2, // kRGB_565_SkColorType
|
||||
4, // kRGBA_8888_SkColorType
|
||||
4, // kBGRA_8888_SkColorType
|
||||
4, // kPMColor_SkColorType
|
||||
};
|
||||
|
||||
SkASSERT((size_t)ct < SK_ARRAY_COUNT(gColorTypeBytesPerPixel));
|
||||
return gColorTypeBytesPerPixel[ct];
|
||||
}
|
||||
|
||||
bool SkBitmapToImageInfo(const SkBitmap& bm, SkImage::Info* info) {
|
||||
bool SkBitmapToImageInfo(const SkBitmap& bm, SkImageInfo* info) {
|
||||
switch (bm.config()) {
|
||||
case SkBitmap::kA8_Config:
|
||||
info->fColorType = SkImage::kAlpha_8_ColorType;
|
||||
info->fColorType = kAlpha_8_SkColorType;
|
||||
break;
|
||||
|
||||
case SkBitmap::kRGB_565_Config:
|
||||
info->fColorType = SkImage::kRGB_565_ColorType;
|
||||
info->fColorType = kRGB_565_SkColorType;
|
||||
break;
|
||||
|
||||
case SkBitmap::kARGB_8888_Config:
|
||||
info->fColorType = SkImage::kPMColor_ColorType;
|
||||
info->fColorType = kPMColor_SkColorType;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -66,7 +66,7 @@ bool SkBitmapToImageInfo(const SkBitmap& bm, SkImage::Info* info) {
|
|||
}
|
||||
|
||||
SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef) {
|
||||
SkImage::Info info;
|
||||
SkImageInfo info;
|
||||
if (!SkBitmapToImageInfo(bm, &info)) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -13,14 +13,14 @@
|
|||
|
||||
class SkPicture;
|
||||
|
||||
extern SkBitmap::Config SkImageInfoToBitmapConfig(const SkImage::Info&);
|
||||
extern SkBitmap::Config SkImageInfoToBitmapConfig(const SkImageInfo&);
|
||||
|
||||
extern int SkImageBytesPerPixel(SkImage::ColorType);
|
||||
extern int SkImageBytesPerPixel(SkColorType);
|
||||
|
||||
extern bool SkBitmapToImageInfo(const SkBitmap&, SkImage::Info*);
|
||||
extern bool SkBitmapToImageInfo(const SkBitmap&, SkImageInfo*);
|
||||
|
||||
// Call this if you explicitly want to use/share this pixelRef in the image
|
||||
extern SkImage* SkNewImageFromPixelRef(const SkImage::Info&, SkPixelRef*,
|
||||
extern SkImage* SkNewImageFromPixelRef(const SkImageInfo&, SkPixelRef*,
|
||||
size_t rowBytes);
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ extern SkImage* SkNewImageFromPixelRef(const SkImage::Info&, SkPixelRef*,
|
|||
* is true.
|
||||
*
|
||||
* If the bitmap's config cannot be converted into a corresponding
|
||||
* SkImage::Info, or the bitmap's pixels cannot be accessed, this will return
|
||||
* SkImageInfo, or the bitmap's pixels cannot be accessed, this will return
|
||||
* NULL.
|
||||
*/
|
||||
extern SkImage* SkNewImageFromBitmap(const SkBitmap&, bool canSharePixelRef);
|
||||
|
@ -47,7 +47,7 @@ extern void SkImagePrivDrawPicture(SkCanvas*, SkPicture*,
|
|||
*/
|
||||
extern SkImage* SkNewImageFromPicture(const SkPicture*);
|
||||
|
||||
static inline size_t SkImageMinRowBytes(const SkImage::Info& info) {
|
||||
static inline size_t SkImageMinRowBytes(const SkImageInfo& info) {
|
||||
size_t rb = info.fWidth * SkImageBytesPerPixel(info.fColorType);
|
||||
return SkAlign4(rb);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
if (info.fWidth > maxDimension || info.fHeight > maxDimension) {
|
||||
return false;
|
||||
}
|
||||
if ((unsigned)info.fColorType > (unsigned)kLastEnum_ColorType) {
|
||||
if ((unsigned)info.fColorType > (unsigned)kLastEnum_SkColorType) {
|
||||
return false;
|
||||
}
|
||||
if ((unsigned)info.fAlphaType > (unsigned)kLastEnum_SkAlphaType) {
|
||||
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
static SkImage* NewEmpty();
|
||||
|
||||
SkImage_Raster(const SkImage::Info&, SkData*, size_t rb);
|
||||
SkImage_Raster(const SkImageInfo&, SkData*, size_t rb);
|
||||
virtual ~SkImage_Raster();
|
||||
|
||||
virtual void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) SK_OVERRIDE;
|
||||
|
@ -58,7 +58,7 @@ public:
|
|||
virtual bool getROPixels(SkBitmap*) const SK_OVERRIDE;
|
||||
|
||||
// exposed for SkSurface_Raster via SkNewImageFromPixelRef
|
||||
SkImage_Raster(const SkImage::Info&, SkPixelRef*, size_t rowBytes);
|
||||
SkImage_Raster(const SkImageInfo&, SkPixelRef*, size_t rowBytes);
|
||||
|
||||
SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); }
|
||||
|
||||
|
@ -116,7 +116,7 @@ bool SkImage_Raster::getROPixels(SkBitmap* dst) const {
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkImage* SkImage::NewRasterCopy(const SkImage::Info& info, const void* pixels, size_t rowBytes) {
|
||||
SkImage* SkImage::NewRasterCopy(const SkImageInfo& info, const void* pixels, size_t rowBytes) {
|
||||
if (!SkImage_Raster::ValidArgs(info, rowBytes)) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ SkImage* SkImage::NewRasterCopy(const SkImage::Info& info, const void* pixels, s
|
|||
}
|
||||
|
||||
|
||||
SkImage* SkImage::NewRasterData(const SkImage::Info& info, SkData* pixelData, size_t rowBytes) {
|
||||
SkImage* SkImage::NewRasterData(const SkImageInfo& info, SkData* pixelData, size_t rowBytes) {
|
||||
if (!SkImage_Raster::ValidArgs(info, rowBytes)) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ SkImage* SkImage::NewRasterData(const SkImage::Info& info, SkData* pixelData, si
|
|||
return SkNEW_ARGS(SkImage_Raster, (info, data, rowBytes));
|
||||
}
|
||||
|
||||
SkImage* SkNewImageFromPixelRef(const SkImage::Info& info, SkPixelRef* pr,
|
||||
SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr,
|
||||
size_t rowBytes) {
|
||||
return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes));
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ SkImage* SkSurface::newImageSnapshot() {
|
|||
return image;
|
||||
}
|
||||
|
||||
SkSurface* SkSurface::newSurface(const SkImage::Info& info) {
|
||||
SkSurface* SkSurface::newSurface(const SkImageInfo& info) {
|
||||
return asSB(this)->onNewSurface(info);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
*/
|
||||
virtual SkCanvas* onNewCanvas() = 0;
|
||||
|
||||
virtual SkSurface* onNewSurface(const SkImage::Info&) = 0;
|
||||
virtual SkSurface* onNewSurface(const SkImageInfo&) = 0;
|
||||
|
||||
/**
|
||||
* Allocate an SkImage that represents the current contents of the surface.
|
||||
|
|
|
@ -14,12 +14,12 @@ class SkSurface_Gpu : public SkSurface_Base {
|
|||
public:
|
||||
SK_DECLARE_INST_COUNT(SkSurface_Gpu)
|
||||
|
||||
SkSurface_Gpu(GrContext*, const SkImage::Info&, int sampleCount);
|
||||
SkSurface_Gpu(GrContext*, const SkImageInfo&, int sampleCount);
|
||||
SkSurface_Gpu(GrContext*, GrRenderTarget*);
|
||||
virtual ~SkSurface_Gpu();
|
||||
|
||||
virtual SkCanvas* onNewCanvas() SK_OVERRIDE;
|
||||
virtual SkSurface* onNewSurface(const SkImage::Info&) SK_OVERRIDE;
|
||||
virtual SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE;
|
||||
virtual SkImage* onNewImageSnapshot() SK_OVERRIDE;
|
||||
virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y,
|
||||
const SkPaint*) SK_OVERRIDE;
|
||||
|
@ -35,7 +35,7 @@ SK_DEFINE_INST_COUNT(SkSurface_Gpu)
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkSurface_Gpu::SkSurface_Gpu(GrContext* ctx, const SkImage::Info& info,
|
||||
SkSurface_Gpu::SkSurface_Gpu(GrContext* ctx, const SkImageInfo& info,
|
||||
int sampleCount)
|
||||
: INHERITED(info.fWidth, info.fHeight) {
|
||||
SkBitmap::Config config = SkImageInfoToBitmapConfig(info);
|
||||
|
@ -64,7 +64,7 @@ SkCanvas* SkSurface_Gpu::onNewCanvas() {
|
|||
return SkNEW_ARGS(SkCanvas, (fDevice));
|
||||
}
|
||||
|
||||
SkSurface* SkSurface_Gpu::onNewSurface(const SkImage::Info& info) {
|
||||
SkSurface* SkSurface_Gpu::onNewSurface(const SkImageInfo& info) {
|
||||
GrRenderTarget* rt = fDevice->accessRenderTarget();
|
||||
int sampleCount = rt->numSamples();
|
||||
return SkSurface::NewRenderTarget(fDevice->context(), info, sampleCount);
|
||||
|
@ -113,7 +113,7 @@ SkSurface* SkSurface::NewRenderTargetDirect(GrContext* ctx,
|
|||
return SkNEW_ARGS(SkSurface_Gpu, (ctx, target));
|
||||
}
|
||||
|
||||
SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImage::Info& info, int sampleCount) {
|
||||
SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImageInfo& info, int sampleCount) {
|
||||
if (NULL == ctx) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
virtual ~SkSurface_Picture();
|
||||
|
||||
virtual SkCanvas* onNewCanvas() SK_OVERRIDE;
|
||||
virtual SkSurface* onNewSurface(const SkImage::Info&) SK_OVERRIDE;
|
||||
virtual SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE;
|
||||
virtual SkImage* onNewImageSnapshot() SK_OVERRIDE;
|
||||
virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y,
|
||||
const SkPaint*) SK_OVERRIDE;
|
||||
|
@ -51,7 +51,7 @@ SkCanvas* SkSurface_Picture::onNewCanvas() {
|
|||
return canvas;
|
||||
}
|
||||
|
||||
SkSurface* SkSurface_Picture::onNewSurface(const SkImage::Info& info) {
|
||||
SkSurface* SkSurface_Picture::onNewSurface(const SkImageInfo& info) {
|
||||
return SkSurface::NewPicture(info.fWidth, info.fHeight);
|
||||
}
|
||||
|
||||
|
@ -59,9 +59,9 @@ SkImage* SkSurface_Picture::onNewImageSnapshot() {
|
|||
if (fPicture) {
|
||||
return SkNewImageFromPicture(fPicture);
|
||||
} else {
|
||||
SkImage::Info info;
|
||||
SkImageInfo info;
|
||||
info.fWidth = info.fHeight = 0;
|
||||
info.fColorType = SkImage::kPMColor_ColorType;
|
||||
info.fColorType = kPMColor_SkColorType;
|
||||
info.fAlphaType = kOpaque_SkAlphaType;
|
||||
return SkImage::NewRasterCopy(info, NULL, 0);
|
||||
}
|
||||
|
|
|
@ -15,13 +15,13 @@ static const size_t kIgnoreRowBytesValue = (size_t)~0;
|
|||
|
||||
class SkSurface_Raster : public SkSurface_Base {
|
||||
public:
|
||||
static bool Valid(const SkImage::Info&, size_t rb = kIgnoreRowBytesValue);
|
||||
static bool Valid(const SkImageInfo&, size_t rb = kIgnoreRowBytesValue);
|
||||
|
||||
SkSurface_Raster(const SkImage::Info&, void*, size_t rb);
|
||||
SkSurface_Raster(const SkImage::Info&, SkPixelRef*, size_t rb);
|
||||
SkSurface_Raster(const SkImageInfo&, void*, size_t rb);
|
||||
SkSurface_Raster(const SkImageInfo&, SkPixelRef*, size_t rb);
|
||||
|
||||
virtual SkCanvas* onNewCanvas() SK_OVERRIDE;
|
||||
virtual SkSurface* onNewSurface(const SkImage::Info&) SK_OVERRIDE;
|
||||
virtual SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE;
|
||||
virtual SkImage* onNewImageSnapshot() SK_OVERRIDE;
|
||||
virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y,
|
||||
const SkPaint*) SK_OVERRIDE;
|
||||
|
@ -36,7 +36,7 @@ private:
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool SkSurface_Raster::Valid(const SkImage::Info& info, size_t rowBytes) {
|
||||
bool SkSurface_Raster::Valid(const SkImageInfo& info, size_t rowBytes) {
|
||||
static const size_t kMaxTotalSize = SK_MaxS32;
|
||||
|
||||
SkBitmap::Config config = SkImageInfoToBitmapConfig(info);
|
||||
|
@ -80,7 +80,7 @@ bool SkSurface_Raster::Valid(const SkImage::Info& info, size_t rowBytes) {
|
|||
return true;
|
||||
}
|
||||
|
||||
SkSurface_Raster::SkSurface_Raster(const SkImage::Info& info, void* pixels, size_t rb)
|
||||
SkSurface_Raster::SkSurface_Raster(const SkImageInfo& info, void* pixels, size_t rb)
|
||||
: INHERITED(info.fWidth, info.fHeight) {
|
||||
SkBitmap::Config config = SkImageInfoToBitmapConfig(info);
|
||||
fBitmap.setConfig(config, info.fWidth, info.fHeight, rb, info.fAlphaType);
|
||||
|
@ -88,7 +88,7 @@ SkSurface_Raster::SkSurface_Raster(const SkImage::Info& info, void* pixels, size
|
|||
fWeOwnThePixels = false; // We are "Direct"
|
||||
}
|
||||
|
||||
SkSurface_Raster::SkSurface_Raster(const SkImage::Info& info, SkPixelRef* pr, size_t rb)
|
||||
SkSurface_Raster::SkSurface_Raster(const SkImageInfo& info, SkPixelRef* pr, size_t rb)
|
||||
: INHERITED(info.fWidth, info.fHeight) {
|
||||
SkBitmap::Config config = SkImageInfoToBitmapConfig(info);
|
||||
fBitmap.setConfig(config, info.fWidth, info.fHeight, rb, info.fAlphaType);
|
||||
|
@ -104,7 +104,7 @@ SkCanvas* SkSurface_Raster::onNewCanvas() {
|
|||
return SkNEW_ARGS(SkCanvas, (fBitmap));
|
||||
}
|
||||
|
||||
SkSurface* SkSurface_Raster::onNewSurface(const SkImage::Info& info) {
|
||||
SkSurface* SkSurface_Raster::onNewSurface(const SkImageInfo& info) {
|
||||
return SkSurface::NewRaster(info);
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ void SkSurface_Raster::onCopyOnWrite(ContentChangeMode mode) {
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkSurface* SkSurface::NewRasterDirect(const SkImage::Info& info, void* pixels, size_t rowBytes) {
|
||||
SkSurface* SkSurface::NewRasterDirect(const SkImageInfo& info, void* pixels, size_t rowBytes) {
|
||||
if (!SkSurface_Raster::Valid(info, rowBytes)) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ SkSurface* SkSurface::NewRasterDirect(const SkImage::Info& info, void* pixels, s
|
|||
return SkNEW_ARGS(SkSurface_Raster, (info, pixels, rowBytes));
|
||||
}
|
||||
|
||||
SkSurface* SkSurface::NewRaster(const SkImage::Info& info) {
|
||||
SkSurface* SkSurface::NewRaster(const SkImageInfo& info) {
|
||||
if (!SkSurface_Raster::Valid(info)) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -403,7 +403,7 @@ static bool decode_pixels_to_8888(SkImageDecoder* decoder, SkStream* stream,
|
|||
}
|
||||
|
||||
bool SkImageDecoder::DecodeMemoryToTarget(const void* buffer, size_t size,
|
||||
SkImage::Info* info,
|
||||
SkImageInfo* info,
|
||||
const SkBitmapFactory::Target* target) {
|
||||
// FIXME: Just to get this working, implement in terms of existing
|
||||
// ImageDecoder calls.
|
||||
|
|
|
@ -48,7 +48,7 @@ bool SkBitmapFactory::installPixelRef(SkData* data, SkBitmap* dst) {
|
|||
return false;
|
||||
}
|
||||
|
||||
SkImage::Info info;
|
||||
SkImageInfo info;
|
||||
if (!fDecodeProc(data->data(), data->size(), &info, NULL)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ SkLazyPixelRef::~SkLazyPixelRef() {
|
|||
fImageCache->unref();
|
||||
}
|
||||
|
||||
static size_t ComputeMinRowBytesAndSize(const SkImage::Info& info, size_t* rowBytes) {
|
||||
static size_t ComputeMinRowBytesAndSize(const SkImageInfo& info, size_t* rowBytes) {
|
||||
*rowBytes = SkImageMinRowBytes(info);
|
||||
|
||||
Sk64 safeSize;
|
||||
|
@ -80,9 +80,9 @@ static size_t ComputeMinRowBytesAndSize(const SkImage::Info& info, size_t* rowBy
|
|||
return safeSize.is32() ? safeSize.get32() : 0;
|
||||
}
|
||||
|
||||
const SkImage::Info* SkLazyPixelRef::getCachedInfo() {
|
||||
const SkImageInfo* SkLazyPixelRef::getCachedInfo() {
|
||||
if (fLazilyCachedInfo.fWidth < 0) {
|
||||
SkImage::Info info;
|
||||
SkImageInfo info;
|
||||
fErrorInDecoding = !fDecodeProc(fData->data(), fData->size(), &info, NULL);
|
||||
if (fErrorInDecoding) {
|
||||
return NULL;
|
||||
|
@ -94,7 +94,7 @@ const SkImage::Info* SkLazyPixelRef::getCachedInfo() {
|
|||
|
||||
/**
|
||||
Returns bitmap->getPixels() on success; NULL on failure */
|
||||
static void* decode_into_bitmap(SkImage::Info* info,
|
||||
static void* decode_into_bitmap(SkImageInfo* info,
|
||||
SkBitmapFactory::DecodeProc decodeProc,
|
||||
size_t* rowBytes,
|
||||
SkData* data,
|
||||
|
@ -122,7 +122,7 @@ void* SkLazyPixelRef::lockScaledImageCachePixels() {
|
|||
SkASSERT(!fErrorInDecoding);
|
||||
SkASSERT(NULL == fImageCache);
|
||||
SkBitmap bitmap;
|
||||
const SkImage::Info* info = this->getCachedInfo();
|
||||
const SkImageInfo* info = this->getCachedInfo();
|
||||
if (info == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ void* SkLazyPixelRef::lockScaledImageCachePixels() {
|
|||
return pixels;
|
||||
} else {
|
||||
// Cache has been purged, must re-decode.
|
||||
void* pixels = decode_into_bitmap(const_cast<SkImage::Info*>(info),
|
||||
void* pixels = decode_into_bitmap(const_cast<SkImageInfo*>(info),
|
||||
fDecodeProc, &fRowBytes, fData,
|
||||
&bitmap);
|
||||
if (NULL == pixels) {
|
||||
|
@ -204,7 +204,7 @@ void* SkLazyPixelRef::lockImageCachePixels() {
|
|||
|
||||
SkASSERT(fData != NULL && fData->size() > 0);
|
||||
if (NULL == target.fAddr) {
|
||||
const SkImage::Info* info = this->getCachedInfo();
|
||||
const SkImageInfo* info = this->getCachedInfo();
|
||||
if (NULL == info) {
|
||||
SkASSERT(SkImageCache::UNINITIALIZED_ID == fCacheId);
|
||||
return NULL;
|
||||
|
@ -262,7 +262,7 @@ SkData* SkLazyPixelRef::onRefEncodedData() {
|
|||
return fData;
|
||||
}
|
||||
|
||||
static bool init_from_info(SkBitmap* bm, const SkImage::Info& info,
|
||||
static bool init_from_info(SkBitmap* bm, const SkImageInfo& info,
|
||||
size_t rowBytes) {
|
||||
SkBitmap::Config config = SkImageInfoToBitmapConfig(info);
|
||||
if (SkBitmap::kNo_Config == config) {
|
||||
|
@ -284,7 +284,7 @@ bool SkLazyPixelRef::onDecodeInto(int pow2, SkBitmap* bitmap) {
|
|||
return false;
|
||||
}
|
||||
|
||||
SkImage::Info info;
|
||||
SkImageInfo info;
|
||||
// Determine the size of the image in order to determine how much memory to allocate.
|
||||
// FIXME: As an optimization, only do this part once.
|
||||
fErrorInDecoding = !fDecodeProc(fData->data(), fData->size(), &info, NULL);
|
||||
|
|
|
@ -77,7 +77,7 @@ private:
|
|||
SkScaledImageCache::ID* fScaledCacheId;
|
||||
};
|
||||
size_t fRowBytes;
|
||||
SkImage::Info fLazilyCachedInfo;
|
||||
SkImageInfo fLazilyCachedInfo;
|
||||
|
||||
#if LAZY_CACHE_STATS
|
||||
static int32_t gCacheHits;
|
||||
|
|
|
@ -84,7 +84,7 @@ SkBitmap::Allocator* SkImageDecoder::setAllocator(SkBitmap::Allocator*) {
|
|||
|
||||
void SkImageDecoder::setSampleSize(int) {}
|
||||
|
||||
bool SkImageDecoder::DecodeMemoryToTarget(const void*, size_t, SkImage::Info*,
|
||||
bool SkImageDecoder::DecodeMemoryToTarget(const void*, size_t, SkImageInfo*,
|
||||
const SkBitmapFactory::Target*) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ static SkData* create_data_from_bitmap(const SkBitmap& bm,
|
|||
static bool simple_bitmap_factory(SkBitmapFactory::DecodeProc proc,
|
||||
SkData* data,
|
||||
SkBitmap* dst) {
|
||||
SkImage::Info info;
|
||||
SkImageInfo info;
|
||||
if (!proc(data->data(), data->size(), &info, NULL)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
return SkNEW_ARGS(SkCanvas, (fBitmap));
|
||||
}
|
||||
|
||||
virtual SkSurface* onNewSurface(const SkImage::Info&) SK_OVERRIDE {
|
||||
virtual SkSurface* onNewSurface(const SkImageInfo&) SK_OVERRIDE {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -692,10 +692,10 @@ static PixelPtr getSurfacePixelPtr(SkSurface* surface, bool useGpu) {
|
|||
}
|
||||
|
||||
static void TestDeferredCanvasSurface(skiatest::Reporter* reporter, GrContextFactory* factory) {
|
||||
SkImage::Info imageSpec = {
|
||||
SkImageInfo imageSpec = {
|
||||
10, // width
|
||||
10, // height
|
||||
SkImage::kPMColor_ColorType,
|
||||
kPMColor_SkColorType,
|
||||
kPremul_SkAlphaType
|
||||
};
|
||||
SkSurface* surface;
|
||||
|
@ -759,10 +759,10 @@ static void TestDeferredCanvasSurface(skiatest::Reporter* reporter, GrContextFac
|
|||
}
|
||||
|
||||
static void TestDeferredCanvasSetSurface(skiatest::Reporter* reporter, GrContextFactory* factory) {
|
||||
SkImage::Info imageSpec = {
|
||||
SkImageInfo imageSpec = {
|
||||
10, // width
|
||||
10, // height
|
||||
SkImage::kPMColor_ColorType,
|
||||
kPMColor_SkColorType,
|
||||
kPremul_SkAlphaType
|
||||
};
|
||||
SkSurface* surface;
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
#include "SkLruImageCache.h"
|
||||
|
||||
// A BitmapFactory that always fails when asked to return pixels.
|
||||
static bool FailureDecoder(const void* data, size_t length, SkImage::Info* info,
|
||||
static bool FailureDecoder(const void* data, size_t length, SkImageInfo* info,
|
||||
const SkBitmapFactory::Target* target) {
|
||||
if (info) {
|
||||
info->fWidth = info->fHeight = 100;
|
||||
info->fColorType = SkImage::kRGBA_8888_ColorType;
|
||||
info->fColorType = kRGBA_8888_SkColorType;
|
||||
info->fAlphaType = kPremul_SkAlphaType;
|
||||
}
|
||||
// this will deliberately return false if they are asking us to decode
|
||||
|
|
|
@ -24,10 +24,10 @@ enum SurfaceType {
|
|||
};
|
||||
|
||||
static SkSurface* createSurface(SurfaceType surfaceType, GrContext* context) {
|
||||
static const SkImage::Info imageSpec = {
|
||||
static const SkImageInfo imageSpec = {
|
||||
10, // width
|
||||
10, // height
|
||||
SkImage::kPMColor_ColorType,
|
||||
kPMColor_SkColorType,
|
||||
kPremul_SkAlphaType
|
||||
};
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
SkSafeUnref(fPurgeableImageCache);
|
||||
}
|
||||
|
||||
virtual SkImageCache* selectCache(const SkImage::Info& info) SK_OVERRIDE {
|
||||
virtual SkImageCache* selectCache(const SkImageInfo& info) SK_OVERRIDE {
|
||||
if (info.fWidth * info.fHeight > 32 * 1024 && fPurgeableImageCache != NULL) {
|
||||
return fPurgeableImageCache;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче