SkImage::kPMColor_ColorType,
SkImage::kPremul_AlphaType
};
- return SkSurface::NewRaster(info, NULL);
+ return SkSurface::NewRaster(info);
}
static void draw_pixel_centers(SkCanvas* canvas) {
info.fHeight = H;
info.fColorType = SkImage::kPMColor_ColorType;
info.fAlphaType = SkImage::kPremul_AlphaType;
- SkAutoTUnref<SkSurface> surf0(SkSurface::NewRasterDirect(info, NULL, fBuffer, RB));
- SkAutoTUnref<SkSurface> surf1(SkSurface::NewRaster(info, NULL));
+ SkAutoTUnref<SkSurface> surf0(SkSurface::NewRasterDirect(info, fBuffer, RB));
+ SkAutoTUnref<SkSurface> surf1(SkSurface::NewRaster(info));
SkAutoTUnref<SkSurface> surf2(SkSurface::NewPicture(info.fWidth, info.fHeight));
#if SK_SUPPORT_GPU
GrContext* ctx = skiagm::GetGr();
- SkAutoTUnref<SkSurface> surf3(SkSurface::NewRenderTarget(ctx, info, NULL, 0));
+ SkAutoTUnref<SkSurface> surf3(SkSurface::NewRenderTarget(ctx, info, 0));
#endif
test_surface(canvas, surf0);
////// EXPERIMENTAL
-class SkColorSpace;
-
/**
* 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
AlphaType fAlphaType;
};
- static SkImage* NewRasterCopy(const Info&, SkColorSpace*, const void* pixels, size_t rowBytes);
- static SkImage* NewRasterData(const Info&, SkColorSpace*, SkData* pixels, size_t rowBytes);
+ static SkImage* NewRasterCopy(const Info&, const void* pixels, size_t rowBytes);
+ static SkImage* NewRasterData(const Info&, SkData* pixels, size_t rowBytes);
static SkImage* NewEncodedData(SkData*);
static SkImage* NewTexture(GrTexture*);
* 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&, SkColorSpace*,
- void* pixels, size_t rowBytes);
+ static SkSurface* NewRasterDirect(const SkImage::Info&, void* pixels, size_t rowBytes);
/**
* Return a new surface, with the memory for the pixels automatically
* 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&, SkColorSpace*);
+ static SkSurface* NewRaster(const SkImage::Info&);
/**
* Return a new surface whose contents will be recorded into a picture.
* 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&,
- SkColorSpace*, int sampleCount = 0);
+ static SkSurface* NewRenderTarget(GrContext*, const SkImage::Info&, int sampleCount = 0);
int width() const { return fWidth; }
int height() const { return fHeight; }
* ... // draw using canvasB
* canvasA->drawSurface(surfaceB); // <--- this will always be optimal!
*/
- SkSurface* newSurface(const SkImage::Info&, SkColorSpace*);
+ SkSurface* newSurface(const SkImage::Info&);
/**
* Returns an image of the current state of the surface pixels up to this
SkImage::Info info = {
width, height, SkImage::kPMColor_ColorType, SkImage::kPremul_AlphaType
};
- fMinSurface.reset(SkSurface::NewRaster(info, NULL));
+ fMinSurface.reset(SkSurface::NewRaster(info));
info.fWidth *= zoom;
info.fHeight *= zoom;
- fMaxSurface.reset(SkSurface::NewRaster(info, NULL));
+ fMaxSurface.reset(SkSurface::NewRaster(info));
}
void drawBG(SkCanvas*);
} else {
bm.lockPixels();
if (bm.getPixels()) {
- image = SkImage::NewRasterCopy(info, NULL, bm.getPixels(),
- bm.rowBytes());
+ image = SkImage::NewRasterCopy(info, bm.getPixels(), bm.rowBytes());
}
bm.unlockPixels();
}
class SkImage_Raster : public SkImage_Base {
public:
- static bool ValidArgs(const Info& info, SkColorSpace* cs, size_t rowBytes) {
+ static bool ValidArgs(const Info& info, size_t rowBytes) {
const int maxDimension = SK_MaxS32 >> 2;
const size_t kMaxPixelByteSize = SK_MaxS32;
static SkImage* NewEmpty();
- SkImage_Raster(const SkImage::Info&, SkColorSpace*, SkData*, size_t rb);
+ SkImage_Raster(const SkImage::Info&, SkData*, size_t rb);
virtual ~SkImage_Raster();
virtual void onDraw(SkCanvas*, SkScalar, SkScalar, const SkPaint*) SK_OVERRIDE;
return gEmpty;
}
-SkImage_Raster::SkImage_Raster(const Info& info, SkColorSpace* cs,
- SkData* data, size_t rowBytes)
-: INHERITED(info.fWidth, info.fHeight) {
+SkImage_Raster::SkImage_Raster(const Info& info, SkData* data, size_t rowBytes)
+ : INHERITED(info.fWidth, info.fHeight) {
bool isOpaque;
SkBitmap::Config config = SkImageInfoToBitmapConfig(info, &isOpaque);
///////////////////////////////////////////////////////////////////////////////
-SkImage* SkImage::NewRasterCopy(const SkImage::Info& info, SkColorSpace* cs,
- const void* pixels, size_t rowBytes) {
- if (!SkImage_Raster::ValidArgs(info, cs, rowBytes)) {
+SkImage* SkImage::NewRasterCopy(const SkImage::Info& info, const void* pixels, size_t rowBytes) {
+ if (!SkImage_Raster::ValidArgs(info, rowBytes)) {
return NULL;
}
if (0 == info.fWidth && 0 == info.fHeight) {
// Here we actually make a copy of the caller's pixel data
SkAutoDataUnref data(SkData::NewWithCopy(pixels, info.fHeight * rowBytes));
- return SkNEW_ARGS(SkImage_Raster, (info, cs, data, rowBytes));
+ return SkNEW_ARGS(SkImage_Raster, (info, data, rowBytes));
}
-SkImage* SkImage::NewRasterData(const SkImage::Info& info, SkColorSpace* cs,
- SkData* pixelData, size_t rowBytes) {
- if (!SkImage_Raster::ValidArgs(info, cs, rowBytes)) {
+SkImage* SkImage::NewRasterData(const SkImage::Info& info, SkData* pixelData, size_t rowBytes) {
+ if (!SkImage_Raster::ValidArgs(info, rowBytes)) {
return NULL;
}
if (0 == info.fWidth && 0 == info.fHeight) {
}
SkAutoDataUnref data(pixelData);
- return SkNEW_ARGS(SkImage_Raster, (info, cs, data, rowBytes));
+ return SkNEW_ARGS(SkImage_Raster, (info, data, rowBytes));
}
SkImage* SkNewImageFromPixelRef(const SkImage::Info& info, SkPixelRef* pr,
return image;
}
-SkSurface* SkSurface::newSurface(const SkImage::Info& info, SkColorSpace* cs) {
- return asSB(this)->onNewSurface(info, cs);
+SkSurface* SkSurface::newSurface(const SkImage::Info& info) {
+ return asSB(this)->onNewSurface(info);
}
void SkSurface::draw(SkCanvas* canvas, SkScalar x, SkScalar y,
*/
virtual SkCanvas* onNewCanvas() = 0;
- virtual SkSurface* onNewSurface(const SkImage::Info&, SkColorSpace*) = 0;
+ virtual SkSurface* onNewSurface(const SkImage::Info&) = 0;
/**
* Allocate an SkImage that represents the current contents of the surface.
virtual ~SkSurface_Gpu();
virtual SkCanvas* onNewCanvas() SK_OVERRIDE;
- virtual SkSurface* onNewSurface(const SkImage::Info&, SkColorSpace*) SK_OVERRIDE;
+ virtual SkSurface* onNewSurface(const SkImage::Info&) SK_OVERRIDE;
virtual SkImage* onNewImageShapshot() SK_OVERRIDE;
virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y,
const SkPaint*) SK_OVERRIDE;
return SkNEW_ARGS(SkCanvas, (fDevice));
}
-SkSurface* SkSurface_Gpu::onNewSurface(const SkImage::Info& info,
- SkColorSpace* cs) {
+SkSurface* SkSurface_Gpu::onNewSurface(const SkImage::Info& info) {
GrRenderTarget* rt = (GrRenderTarget*) fDevice->accessRenderTarget();
int sampleCount = rt->numSamples();
- return SkSurface::NewRenderTarget(fDevice->context(), info, NULL, sampleCount);
+ return SkSurface::NewRenderTarget(fDevice->context(), info, sampleCount);
}
SkImage* SkSurface_Gpu::onNewImageShapshot() {
return SkNEW_ARGS(SkSurface_Gpu, (ctx, target));
}
-SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImage::Info& info,
- SkColorSpace*, int sampleCount) {
+SkSurface* SkSurface::NewRenderTarget(GrContext* ctx, const SkImage::Info& info, int sampleCount) {
if (NULL == ctx) {
return NULL;
}
virtual ~SkSurface_Picture();
virtual SkCanvas* onNewCanvas() SK_OVERRIDE;
- virtual SkSurface* onNewSurface(const SkImage::Info&, SkColorSpace*) SK_OVERRIDE;
+ virtual SkSurface* onNewSurface(const SkImage::Info&) SK_OVERRIDE;
virtual SkImage* onNewImageShapshot() SK_OVERRIDE;
virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y,
const SkPaint*) SK_OVERRIDE;
return canvas;
}
-SkSurface* SkSurface_Picture::onNewSurface(const SkImage::Info& info, SkColorSpace*) {
+SkSurface* SkSurface_Picture::onNewSurface(const SkImage::Info& info) {
return SkSurface::NewPicture(info.fWidth, info.fHeight);
}
info.fWidth = info.fHeight = 0;
info.fColorType = SkImage::kPMColor_ColorType;
info.fAlphaType = SkImage::kOpaque_AlphaType;
- return SkImage::NewRasterCopy(info, NULL, NULL, 0);
+ return SkImage::NewRasterCopy(info, NULL, 0);
}
}
class SkSurface_Raster : public SkSurface_Base {
public:
- static bool Valid(const SkImage::Info&, SkColorSpace*, size_t rb = kIgnoreRowBytesValue);
+ static bool Valid(const SkImage::Info&, size_t rb = kIgnoreRowBytesValue);
- SkSurface_Raster(const SkImage::Info&, SkColorSpace*, void*, size_t rb);
- SkSurface_Raster(const SkImage::Info&, SkColorSpace*, SkPixelRef*, size_t rb);
+ SkSurface_Raster(const SkImage::Info&, void*, size_t rb);
+ SkSurface_Raster(const SkImage::Info&, SkPixelRef*, size_t rb);
virtual SkCanvas* onNewCanvas() SK_OVERRIDE;
- virtual SkSurface* onNewSurface(const SkImage::Info&, SkColorSpace*) SK_OVERRIDE;
+ virtual SkSurface* onNewSurface(const SkImage::Info&) SK_OVERRIDE;
virtual SkImage* onNewImageShapshot() SK_OVERRIDE;
virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y,
const SkPaint*) SK_OVERRIDE;
///////////////////////////////////////////////////////////////////////////////
-bool SkSurface_Raster::Valid(const SkImage::Info& info, SkColorSpace* cs,
- size_t rowBytes) {
+bool SkSurface_Raster::Valid(const SkImage::Info& info, size_t rowBytes) {
static const size_t kMaxTotalSize = SK_MaxS32;
bool isOpaque;
return true;
}
-SkSurface_Raster::SkSurface_Raster(const SkImage::Info& info, SkColorSpace* cs,
- void* pixels, size_t rb)
+SkSurface_Raster::SkSurface_Raster(const SkImage::Info& info, void* pixels, size_t rb)
: INHERITED(info.fWidth, info.fHeight) {
bool isOpaque;
SkBitmap::Config config = SkImageInfoToBitmapConfig(info, &isOpaque);
fWeOwnThePixels = false; // We are "Direct"
}
-SkSurface_Raster::SkSurface_Raster(const SkImage::Info& info, SkColorSpace* cs,
- SkPixelRef* pr, size_t rb)
+SkSurface_Raster::SkSurface_Raster(const SkImage::Info& info, SkPixelRef* pr, size_t rb)
: INHERITED(info.fWidth, info.fHeight) {
bool isOpaque;
SkBitmap::Config config = SkImageInfoToBitmapConfig(info, &isOpaque);
return SkNEW_ARGS(SkCanvas, (fBitmap));
}
-SkSurface* SkSurface_Raster::onNewSurface(const SkImage::Info& info,
- SkColorSpace* cs) {
- return SkSurface::NewRaster(info, cs);
+SkSurface* SkSurface_Raster::onNewSurface(const SkImage::Info& info) {
+ return SkSurface::NewRaster(info);
}
void SkSurface_Raster::onDraw(SkCanvas* canvas, SkScalar x, SkScalar y,
///////////////////////////////////////////////////////////////////////////////
-SkSurface* SkSurface::NewRasterDirect(const SkImage::Info& info,
- SkColorSpace* cs,
- void* pixels, size_t rowBytes) {
- if (!SkSurface_Raster::Valid(info, cs, rowBytes)) {
+SkSurface* SkSurface::NewRasterDirect(const SkImage::Info& info, void* pixels, size_t rowBytes) {
+ if (!SkSurface_Raster::Valid(info, rowBytes)) {
return NULL;
}
if (NULL == pixels) {
return NULL;
}
- return SkNEW_ARGS(SkSurface_Raster, (info, cs, pixels, rowBytes));
+ return SkNEW_ARGS(SkSurface_Raster, (info, pixels, rowBytes));
}
-SkSurface* SkSurface::NewRaster(const SkImage::Info& info, SkColorSpace* cs) {
- if (!SkSurface_Raster::Valid(info, cs)) {
+SkSurface* SkSurface::NewRaster(const SkImage::Info& info) {
+ if (!SkSurface_Raster::Valid(info)) {
return NULL;
}
}
SkAutoTUnref<SkPixelRef> pr(SkNEW_ARGS(SkMallocPixelRef, (pixels, size, NULL, true)));
- return SkNEW_ARGS(SkSurface_Raster, (info, cs, pr, rowBytes));
+ return SkNEW_ARGS(SkSurface_Raster, (info, pr, rowBytes));
}
SkImage::Info info = {
w, h, SkImage::kPMColor_ColorType, SkImage::kPremul_AlphaType
};
- return SkSurface::NewRaster(info, NULL);
+ return SkSurface::NewRaster(info);
}
// Make sure we stay non-finite once we get there (unless we reset or rewind).