virtual SkImageInfo imageInfo() const SK_OVERRIDE;
-#ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
- /**
- * DEPRECATED: This will be made protected once WebKit stops using it.
- * Instead use Canvas' writePixels method.
- *
- * Similar to draw sprite, this method will copy the pixels in bitmap onto
- * the device, with the top/left corner specified by (x, y). The pixel
- * values in the device are completely replaced: there is no blending.
- *
- * Currently if bitmap is backed by a texture this is a no-op. This may be
- * relaxed in the future.
- *
- * If the bitmap has config kARGB_8888_Config then the config8888 param
- * will determines how the pixel valuess are intepreted. If the bitmap is
- * not kARGB_8888_Config then this parameter is ignored.
- */
- virtual void writePixels(const SkBitmap& bitmap, int x, int y,
- SkCanvas::Config8888 config8888) SK_OVERRIDE;
-#endif
/**
* Return the device's associated gpu render target, or NULL.
*/
//#define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
-//#define SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
//#define SK_SUPPORT_LEGACY_GETCLIPTYPE
//#define SK_SUPPORT_LEGACY_GETTOTALCLIP
//#define SK_SUPPORT_LEGACY_GETTOPDEVICE
*/
bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap);
-#ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
- /**
- * DEPRECATED
- * Similar to draw sprite, this method will copy the pixels in bitmap onto
- * the canvas, with the top/left corner specified by (x, y). The canvas'
- * pixel values are completely replaced: there is no blending.
- *
- * Currently if bitmap is backed by a texture this is a no-op. This may be
- * relaxed in the future.
- *
- * If the bitmap has config kARGB_8888_Config then the config8888 param
- * will determines how the pixel valuess are intepreted. If the bitmap is
- * not kARGB_8888_Config then this parameter is ignored.
- *
- * Note: If you are recording drawing commands on this canvas to
- * SkPicture, writePixels() is ignored!
- */
- void writePixels(const SkBitmap& bitmap, int x, int y, Config8888 config8888);
-#endif
-
/**
* This method affects the pixels in the base-layer, and operates in pixel coordinates,
* ignoring the matrix and clip.
*/
const SkBitmap& accessBitmap(bool changePixels);
-#ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
- /**
- * DEPRECATED: This will be made protected once WebKit stops using it.
- * Instead use Canvas' writePixels method.
- *
- * Similar to draw sprite, this method will copy the pixels in bitmap onto
- * the device, with the top/left corner specified by (x, y). The pixel
- * values in the device are completely replaced: there is no blending.
- *
- * Currently if bitmap is backed by a texture this is a no-op. This may be
- * relaxed in the future.
- *
- * If the bitmap has config kARGB_8888_Config then the config8888 param
- * will determines how the pixel valuess are intepreted. If the bitmap is
- * not kARGB_8888_Config then this parameter is ignored.
- */
- virtual void writePixels(const SkBitmap& bitmap, int x, int y,
- SkCanvas::Config8888 config8888 = SkCanvas::kNative_Premul_Config8888);
-#endif
-
- bool writePixelsDirect(const SkImageInfo&, const void*, size_t rowBytes, int x, int y);
+ bool writePixels(const SkImageInfo&, const void*, size_t rowBytes, int x, int y);
void* accessPixels(SkImageInfo* info, size_t* rowBytes);
virtual SkBitmap::Config config() const SK_OVERRIDE;
virtual void clear(SkColor color) SK_OVERRIDE;
-#ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
- virtual void writePixels(const SkBitmap& bitmap, int x, int y,
- SkCanvas::Config8888 config8888) SK_OVERRIDE;
-#endif
virtual void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE;
virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count,
const SkPoint[], const SkPaint& paint) SK_OVERRIDE;
return true;
}
-#ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
-void SkBitmapDevice::writePixels(const SkBitmap& bitmap,
- int x, int y,
- SkCanvas::Config8888 config8888) {
- if (bitmap.isNull() || bitmap.getTexture()) {
- return;
- }
- const SkBitmap* sprite = &bitmap;
- // check whether we have to handle a config8888 that doesn't match SkPMColor
- if (SkBitmap::kARGB_8888_Config == bitmap.config() &&
- SkCanvas::kNative_Premul_Config8888 != config8888 &&
- kPMColorAlias != config8888) {
-
- // We're going to have to convert from a config8888 to the native config
- // First we clip to the device bounds.
- SkBitmap dstBmp = this->accessBitmap(true);
- SkIRect spriteRect = SkIRect::MakeXYWH(x, y,
- bitmap.width(), bitmap.height());
- SkIRect devRect = SkIRect::MakeWH(dstBmp.width(), dstBmp.height());
- if (!spriteRect.intersect(devRect)) {
- return;
- }
-
- // write directly to the device if it has pixels and is SkPMColor
- bool drawSprite;
- if (SkBitmap::kARGB_8888_Config == dstBmp.config() && !dstBmp.isNull()) {
- // we can write directly to the dst when doing the conversion
- dstBmp.extractSubset(&dstBmp, spriteRect);
- drawSprite = false;
- } else {
- // we convert to a temporary bitmap and draw that as a sprite
- if (!dstBmp.allocPixels(SkImageInfo::MakeN32Premul(spriteRect.width(),
- spriteRect.height()))) {
- return;
- }
- drawSprite = true;
- }
-
- // copy pixels to dstBmp and convert from config8888 to native config.
- SkAutoLockPixels alp(bitmap);
- uint32_t* srcPixels = bitmap.getAddr32(spriteRect.fLeft - x,
- spriteRect.fTop - y);
- SkCopyConfig8888ToBitmap(dstBmp,
- srcPixels,
- bitmap.rowBytes(),
- config8888);
-
- if (drawSprite) {
- // we've clipped the sprite when we made a copy
- x = spriteRect.fLeft;
- y = spriteRect.fTop;
- sprite = &dstBmp;
- } else {
- return;
- }
- }
-
- SkPaint paint;
- paint.setXfermodeMode(SkXfermode::kSrc_Mode);
- SkRasterClip clip(SkIRect::MakeWH(fBitmap.width(), fBitmap.height()));
- SkDraw draw;
- draw.fRC = &clip;
- draw.fClip = &clip.bwRgn();
- draw.fBitmap = &fBitmap; // canvas should have already called accessBitmap
- draw.fMatrix = &SkMatrix::I();
- this->drawSprite(draw, *sprite, x, y, paint);
-}
-#endif
-
void* SkBitmapDevice::onAccessPixels(SkImageInfo* info, size_t* rowBytes) {
if (fBitmap.getPixels()) {
*info = fBitmap.info();
}
}
-#ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
-void SkCanvas::writePixels(const SkBitmap& bitmap, int x, int y,
- Config8888 config8888) {
- SkBaseDevice* device = this->getDevice();
- if (device) {
- if (SkIRect::Intersects(SkIRect::MakeSize(this->getDeviceSize()),
- SkIRect::MakeXYWH(x, y, bitmap.width(), bitmap.height()))) {
- device->accessBitmap(true);
- device->writePixels(bitmap, x, y, config8888);
- }
- }
-}
-#endif
-
bool SkCanvas::writePixels(const SkBitmap& bitmap, int x, int y) {
if (bitmap.getTexture()) {
return false;
pixels = ((const char*)pixels - y * rowBytes - x * info.bytesPerPixel());
// The device can assert that the requested area is always contained in its bounds
- return device->writePixelsDirect(info, pixels, rowBytes, target.x(), target.y());
+ return device->writePixels(info, pixels, rowBytes, target.x(), target.y());
}
SkCanvas* SkCanvas::canvasForDrawIter() {
this->drawPath(draw, path, paint, preMatrix, pathIsMutable);
}
-bool SkBaseDevice::writePixelsDirect(const SkImageInfo& info, const void* pixels, size_t rowBytes,
- int x, int y) {
+bool SkBaseDevice::writePixels(const SkImageInfo& info, const void* pixels, size_t rowBytes,
+ int x, int y) {
#ifdef SK_DEBUG
SkASSERT(info.width() > 0 && info.height() > 0);
SkASSERT(pixels);
return NULL;
}
-#ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
-void SkBaseDevice::writePixels(const SkBitmap&, int x, int y, SkCanvas::Config8888) {}
-#endif
-
void SkBaseDevice::EXPERIMENTAL_optimize(SkPicture* picture) {
// The base class doesn't perform any analysis but derived classes may
}
flags);
}
-#ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
-void SkGpuDevice::writePixels(const SkBitmap& bitmap, int x, int y,
- SkCanvas::Config8888 config8888) {
- SkAutoLockPixels alp(bitmap);
- if (!bitmap.readyToDraw()) {
- return;
- }
-
- GrPixelConfig config;
- uint32_t flags;
- if (SkBitmap::kARGB_8888_Config == bitmap.config()) {
- config = config8888_to_grconfig_and_flags(config8888, &flags);
- } else {
- flags = 0;
- config= SkBitmapConfig2GrPixelConfig(bitmap.config());
- }
-
- fRenderTarget->writePixels(x, y, bitmap.width(), bitmap.height(),
- config, bitmap.getPixels(), bitmap.rowBytes(), flags);
-}
-#endif
-
bool SkGpuDevice::onWritePixels(const SkImageInfo& info, const void* pixels, size_t rowBytes,
int x, int y) {
// TODO: teach fRenderTarget to take ImageInfo directly to specify the src pixels
virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE;
-#ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
- virtual void writePixels(const SkBitmap& bitmap, int x, int y,
- SkCanvas::Config8888 config8888) SK_OVERRIDE;
-#endif
virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE;
protected:
fImmediateCanvas->flush();
}
-#ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
-void SkDeferredDevice::writePixels(const SkBitmap& bitmap, int x, int y,
- SkCanvas::Config8888 config8888) {
-
- if (x <= 0 && y <= 0 && (x + bitmap.width()) >= width() &&
- (y + bitmap.height()) >= height()) {
- this->skipPendingCommands();
- }
-
- if (SkBitmap::kARGB_8888_Config == bitmap.config() &&
- SkCanvas::kNative_Premul_Config8888 != config8888 &&
- kPMColorAlias != config8888) {
- //Special case config: no deferral
- prepareForImmediatePixelWrite();
- immediateDevice()->writePixels(bitmap, x, y, config8888);
- return;
- }
-
- SkPaint paint;
- paint.setXfermodeMode(SkXfermode::kSrc_Mode);
- if (shouldDrawImmediately(&bitmap, NULL, getBitmapSizeThreshold())) {
- prepareForImmediatePixelWrite();
- fImmediateCanvas->drawSprite(bitmap, x, y, &paint);
- } else {
- this->recordingCanvas()->drawSprite(bitmap, x, y, &paint);
- this->recordedDrawCommand();
-
- }
-}
-#endif
-
bool SkDeferredDevice::onWritePixels(const SkImageInfo& info, const void* pixels, size_t rowBytes,
int x, int y) {
SkASSERT(x >= 0 && y >= 0);
return fEmptyBitmap.info();
}
-#ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
- virtual void writePixels(const SkBitmap& bitmap, int x, int y,
- SkCanvas::Config8888 config8888) SK_OVERRIDE {
- NotSupported();
- }
-#endif
virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE { return NULL; }
protected:
nothing_to_do();
}
-#ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
- virtual void writePixels(const SkBitmap& bitmap, int x, int y,
- SkCanvas::Config8888 config8888) SK_OVERRIDE {
- not_supported();
- }
-#endif
-
virtual void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE {
this->addBitmapFromPaint(paint);
}