Revert r10830 (Split SkDevice out of SkRasterDevice) until we can get Chromium ready.

git-svn-id: http://skia.googlecode.com/svn/trunk@10835 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
robertphillips@google.com 2013-08-20 20:06:40 +00:00
Родитель 8cee797901
Коммит 9b051a375b
71 изменённых файлов: 487 добавлений и 726 удалений

Просмотреть файл

@ -53,7 +53,7 @@ private:
const int h = fIsSmall ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARGE; const int h = fIsSmall ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARGE;
fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, w, h); fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, w, h);
fCheckerboard.allocPixels(); fCheckerboard.allocPixels();
SkBitmapDevice device(fCheckerboard); SkDevice device(fCheckerboard);
SkCanvas canvas(&device); SkCanvas canvas(&device);
canvas.clear(0x00000000); canvas.clear(0x00000000);
SkPaint darkPaint; SkPaint darkPaint;

Просмотреть файл

@ -26,7 +26,7 @@ protected:
} }
virtual void onDraw(SkCanvas* canvas) { virtual void onDraw(SkCanvas* canvas) {
SkBaseDevice *device = canvas->getDevice()->createCompatibleDevice( SkDevice *device = canvas->getDevice()->createCompatibleDevice(
SkBitmap::kARGB_8888_Config, CANVAS_WIDTH, CANVAS_HEIGHT, false); SkBitmap::kARGB_8888_Config, CANVAS_WIDTH, CANVAS_HEIGHT, false);
SkAutoTUnref<SkDeferredCanvas> deferredCanvas(SkDeferredCanvas::Create(device)); SkAutoTUnref<SkDeferredCanvas> deferredCanvas(SkDeferredCanvas::Create(device));

Просмотреть файл

@ -35,7 +35,7 @@ protected:
const int h = isSmall() ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARGE; const int h = isSmall() ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARGE;
fBitmap.setConfig(SkBitmap::kARGB_8888_Config, w, h); fBitmap.setConfig(SkBitmap::kARGB_8888_Config, w, h);
fBitmap.allocPixels(); fBitmap.allocPixels();
SkBitmapDevice device(fBitmap); SkDevice device(fBitmap);
SkCanvas canvas(&device); SkCanvas canvas(&device);
canvas.clear(0x00000000); canvas.clear(0x00000000);
SkPaint paint; SkPaint paint;
@ -51,7 +51,7 @@ protected:
const int h = isSmall() ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARGE; const int h = isSmall() ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARGE;
fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, w, h); fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, w, h);
fCheckerboard.allocPixels(); fCheckerboard.allocPixels();
SkBitmapDevice device(fCheckerboard); SkDevice device(fCheckerboard);
SkCanvas canvas(&device); SkCanvas canvas(&device);
canvas.clear(0x00000000); canvas.clear(0x00000000);
SkPaint darkPaint; SkPaint darkPaint;

Просмотреть файл

@ -52,7 +52,7 @@ private:
const int h = fIsSmall ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARGE; const int h = fIsSmall ? FILTER_HEIGHT_LARGE : FILTER_HEIGHT_LARGE;
fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, w, h); fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, w, h);
fCheckerboard.allocPixels(); fCheckerboard.allocPixels();
SkBitmapDevice device(fCheckerboard); SkDevice device(fCheckerboard);
SkCanvas canvas(&device); SkCanvas canvas(&device);
canvas.clear(0x00000000); canvas.clear(0x00000000);
SkPaint darkPaint; SkPaint darkPaint;

Просмотреть файл

@ -53,7 +53,7 @@ private:
void make_bitmap() { void make_bitmap() {
fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 80, 80);
fBitmap.allocPixels(); fBitmap.allocPixels();
SkBitmapDevice device(fBitmap); SkDevice device(fBitmap);
SkCanvas canvas(&device); SkCanvas canvas(&device);
canvas.clear(0x00000000); canvas.clear(0x00000000);
SkPaint paint; SkPaint paint;
@ -67,7 +67,7 @@ private:
void make_checkerboard() { void make_checkerboard() {
fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, 80, 80);
fCheckerboard.allocPixels(); fCheckerboard.allocPixels();
SkBitmapDevice device(fCheckerboard); SkDevice device(fCheckerboard);
SkCanvas canvas(&device); SkCanvas canvas(&device);
canvas.clear(0x00000000); canvas.clear(0x00000000);
SkPaint darkPaint; SkPaint darkPaint;

Просмотреть файл

@ -193,9 +193,9 @@ enum Backend {
kPDF_Backend, kPDF_Backend,
}; };
static SkBaseDevice* make_device(SkBitmap::Config config, const SkIPoint& size, static SkDevice* make_device(SkBitmap::Config config, const SkIPoint& size,
Backend backend, int sampleCount, GrContext* context) { Backend backend, int sampleCount, GrContext* context) {
SkBaseDevice* device = NULL; SkDevice* device = NULL;
SkBitmap bitmap; SkBitmap bitmap;
bitmap.setConfig(config, size.fX, size.fY); bitmap.setConfig(config, size.fX, size.fY);
@ -203,7 +203,7 @@ static SkBaseDevice* make_device(SkBitmap::Config config, const SkIPoint& size,
case kRaster_Backend: case kRaster_Backend:
bitmap.allocPixels(); bitmap.allocPixels();
erase(bitmap); erase(bitmap);
device = SkNEW_ARGS(SkBitmapDevice, (bitmap)); device = SkNEW_ARGS(SkDevice, (bitmap));
break; break;
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
case kGPU_Backend: { case kGPU_Backend: {
@ -776,7 +776,7 @@ int tool_main(int argc, char** argv) {
glContext = gContextFactory.getGLContext(gConfigs[configIndex].fContextType); glContext = gContextFactory.getGLContext(gConfigs[configIndex].fContextType);
} }
#endif #endif
SkBaseDevice* device = NULL; SkDevice* device = NULL;
SkCanvas* canvas = NULL; SkCanvas* canvas = NULL;
SkPicture pictureRecordFrom; SkPicture pictureRecordFrom;
SkPicture pictureRecordTo; SkPicture pictureRecordTo;

Просмотреть файл

@ -12,7 +12,7 @@ SkRasterWidget::SkRasterWidget(SkDebugger *debugger) : QWidget() {
fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 800, 800); fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 800, 800);
fBitmap.allocPixels(); fBitmap.allocPixels();
fBitmap.eraseColor(SK_ColorTRANSPARENT); fBitmap.eraseColor(SK_ColorTRANSPARENT);
fDevice = new SkBitmapDevice(fBitmap); fDevice = new SkDevice(fBitmap);
fDebugger = debugger; fDebugger = debugger;
fCanvas = new SkCanvas(fDevice); fCanvas = new SkCanvas(fDevice);
this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cccccc;}"); this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cccccc;}");
@ -29,7 +29,7 @@ void SkRasterWidget::resizeEvent(QResizeEvent* event) {
fBitmap.eraseColor(SK_ColorTRANSPARENT); fBitmap.eraseColor(SK_ColorTRANSPARENT);
SkSafeUnref(fCanvas); SkSafeUnref(fCanvas);
SkSafeUnref(fDevice); SkSafeUnref(fDevice);
fDevice = new SkBitmapDevice(fBitmap); fDevice = new SkDevice(fBitmap);
fCanvas = new SkCanvas(fDevice); fCanvas = new SkCanvas(fDevice);
fDebugger->resize(event->size().width(), event->size().height()); fDebugger->resize(event->size().width(), event->size().height());
this->update(); this->update();

Просмотреть файл

@ -44,7 +44,7 @@ private:
SkBitmap fBitmap; SkBitmap fBitmap;
SkDebugger* fDebugger; SkDebugger* fDebugger;
SkCanvas* fCanvas; SkCanvas* fCanvas;
SkBaseDevice* fDevice; SkDevice* fDevice;
}; };
#endif /* SKRASTERWIDGET_H_ */ #endif /* SKRASTERWIDGET_H_ */

Просмотреть файл

@ -8,7 +8,7 @@ public:
SK_DECLARE_INST_COUNT(SkNulCanvas); SK_DECLARE_INST_COUNT(SkNulCanvas);
SkNulCanvas() {} SkNulCanvas() {}
explicit SkNulCanvas(SkBaseDevice* device) : SkCanvas(device) {} explicit SkNulCanvas(SkDevice* device) : SkCanvas(device) {}
explicit SkNulCanvas(const SkBitmap& bitmap) : SkCanvas(bitmap) {} explicit SkNulCanvas(const SkBitmap& bitmap) : SkCanvas(bitmap) {}
virtual ~SkNulCanvas() {} virtual ~SkNulCanvas() {}
@ -83,7 +83,7 @@ public:
protected: protected:
virtual SkCanvas* canvasForDrawIter() {return NULL;} virtual SkCanvas* canvasForDrawIter() {return NULL;}
virtual SkBaseDevice* setDevice(SkBaseDevice* device) {return NULL;} virtual SkDevice* setDevice(SkDevice* device) {return NULL;}
private: private:
typedef SkCanvas INHERITED; typedef SkCanvas INHERITED;

Просмотреть файл

@ -242,7 +242,7 @@ static bool readToken(SkPdfNativeTokenizer* fTokenizer, PdfToken* token) {
memcpy(bitmap.getPixels(), gDumpBitmap->getPixels(), gDumpBitmap->getSize()); memcpy(bitmap.getPixels(), gDumpBitmap->getPixels(), gDumpBitmap->getSize());
SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap))); SkAutoTUnref<SkDevice> device(SkNEW_ARGS(SkDevice, (bitmap)));
SkCanvas canvas(device); SkCanvas canvas(device);
// draw context stuff here // draw context stuff here
@ -2641,7 +2641,7 @@ bool SkPDFNativeRenderToBitmap(SkStream* stream,
setup_bitmap(output, (int)SkScalarToDouble(width), (int)SkScalarToDouble(height)); setup_bitmap(output, (int)SkScalarToDouble(width), (int)SkScalarToDouble(height));
SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (*output))); SkAutoTUnref<SkDevice> device(SkNEW_ARGS(SkDevice, (*output)));
SkCanvas canvas(device); SkCanvas canvas(device);
return renderer.renderPage(page, &canvas, rect); return renderer.renderPage(page, &canvas, rect);

Просмотреть файл

@ -4,24 +4,24 @@
#include "SkDevice.h" #include "SkDevice.h"
#include "SkTracker.h" #include "SkTracker.h"
class SkTrackDevice : public SkBitmapDevice { class SkTrackDevice : public SkDevice {
public: public:
SK_DECLARE_INST_COUNT(SkTrackDevice) SK_DECLARE_INST_COUNT(SkTrackDevice)
SkTrackDevice(const SkBitmap& bitmap) : SkBitmapDevice(bitmap) SkTrackDevice(const SkBitmap& bitmap) : SkDevice(bitmap)
, fTracker(NULL) {} , fTracker(NULL) {}
SkTrackDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties) SkTrackDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties)
: SkBitmapDevice(bitmap, deviceProperties) : SkDevice(bitmap, deviceProperties)
, fTracker(NULL) {} , fTracker(NULL) {}
SkTrackDevice(SkBitmap::Config config, int width, int height, bool isOpaque = false) SkTrackDevice(SkBitmap::Config config, int width, int height, bool isOpaque = false)
: SkBitmapDevice(config, width, height, isOpaque) : SkDevice(config, width, height, isOpaque)
, fTracker(NULL) {} , fTracker(NULL) {}
SkTrackDevice(SkBitmap::Config config, int width, int height, bool isOpaque, SkTrackDevice(SkBitmap::Config config, int width, int height, bool isOpaque,
const SkDeviceProperties& deviceProperties) const SkDeviceProperties& deviceProperties)
: SkBitmapDevice(config, width, height, isOpaque, deviceProperties) : SkDevice(config, width, height, isOpaque, deviceProperties)
, fTracker(NULL) {} , fTracker(NULL) {}
virtual ~SkTrackDevice() {} virtual ~SkTrackDevice() {}
@ -147,7 +147,7 @@ protected:
after(); after();
} }
virtual void drawDevice(const SkDraw& dummy1, SkBaseDevice* dummy2, int x, int y, virtual void drawDevice(const SkDraw& dummy1, SkDevice* dummy2, int x, int y,
const SkPaint& dummy3) { const SkPaint& dummy3) {
before(); before();
INHERITED::drawDevice(dummy1, dummy2, x, y, dummy3); INHERITED::drawDevice(dummy1, dummy2, x, y, dummy3);
@ -171,7 +171,7 @@ private:
private: private:
SkTracker* fTracker; SkTracker* fTracker;
typedef SkBitmapDevice INHERITED; typedef SkDevice INHERITED;
}; };
#endif // EXPERIMENTAL_PDFVIEWER_SKTRACKDEVICE_H_ #endif // EXPERIMENTAL_PDFVIEWER_SKTRACKDEVICE_H_

Просмотреть файл

@ -179,7 +179,7 @@ static bool render_page(const SkString& outputDir,
// Exercise all pdf codepaths as in normal rendering, but no actual bits are changed. // Exercise all pdf codepaths as in normal rendering, but no actual bits are changed.
if (!FLAGS_config.isEmpty() && strcmp(FLAGS_config[0], "nul") == 0) { if (!FLAGS_config.isEmpty() && strcmp(FLAGS_config[0], "nul") == 0) {
SkBitmap bitmap; SkBitmap bitmap;
SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (bitmap))); SkAutoTUnref<SkDevice> device(SkNEW_ARGS(SkDevice, (bitmap)));
SkNulCanvas canvas(device); SkNulCanvas canvas(device);
renderer.renderPage(page < 0 ? 0 : page, &canvas, rect); renderer.renderPage(page < 0 ? 0 : page, &canvas, rect);
} else { } else {
@ -197,9 +197,9 @@ static bool render_page(const SkString& outputDir,
#else #else
setup_bitmap(&bitmap, (int)SkScalarToDouble(width), (int)SkScalarToDouble(height)); setup_bitmap(&bitmap, (int)SkScalarToDouble(width), (int)SkScalarToDouble(height));
#endif #endif
SkAutoTUnref<SkBaseDevice> device; SkAutoTUnref<SkDevice> device;
if (strcmp(FLAGS_config[0], "8888") == 0) { if (strcmp(FLAGS_config[0], "8888") == 0) {
device.reset(SkNEW_ARGS(SkBitmapDevice, (bitmap))); device.reset(SkNEW_ARGS(SkDevice, (bitmap)));
} }
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
else if (strcmp(FLAGS_config[0], "gpu") == 0) { else if (strcmp(FLAGS_config[0], "gpu") == 0) {

Просмотреть файл

@ -115,7 +115,7 @@ void SkExampleWindow::setupRenderTarget() {
SkCanvas* SkExampleWindow::createCanvas() { SkCanvas* SkExampleWindow::createCanvas() {
if (fType == kGPU_DeviceType) { if (fType == kGPU_DeviceType) {
if (NULL != fContext && NULL != fRenderTarget) { if (NULL != fContext && NULL != fRenderTarget) {
SkAutoTUnref<SkBaseDevice> device(new SkGpuDevice(fContext, fRenderTarget)); SkAutoTUnref<SkDevice> device(new SkGpuDevice(fContext, fRenderTarget));
return new SkCanvas(device); return new SkCanvas(device);
} }
tearDownBackend(); tearDownBackend();

Просмотреть файл

@ -136,8 +136,8 @@ public:
case SampleWindow::kGPU_DeviceType: case SampleWindow::kGPU_DeviceType:
case SampleWindow::kNullGPU_DeviceType: case SampleWindow::kNullGPU_DeviceType:
if (fCurContext) { if (fCurContext) {
SkAutoTUnref<SkBaseDevice> device(new SkGpuDevice(fCurContext, SkAutoTUnref<SkDevice> device(new SkGpuDevice(fCurContext,
fCurRenderTarget)); fCurRenderTarget));
return new SkCanvas(device); return new SkCanvas(device);
} else { } else {
return NULL; return NULL;

Просмотреть файл

@ -66,7 +66,7 @@ protected:
SkScalar horizMargin(SkIntToScalar(10)); SkScalar horizMargin(SkIntToScalar(10));
SkScalar vertMargin(SkIntToScalar(10)); SkScalar vertMargin(SkIntToScalar(10));
SkBitmapDevice devTmp(SkBitmap::kARGB_8888_Config, 40, 40, false); SkDevice devTmp(SkBitmap::kARGB_8888_Config, 40, 40);
SkCanvas canvasTmp(&devTmp); SkCanvas canvasTmp(&devTmp);
draw_checks(&canvasTmp, 40, 40); draw_checks(&canvasTmp, 40, 40);

Просмотреть файл

@ -44,7 +44,7 @@ protected:
SkDeviceProperties::Geometry::Make(SkDeviceProperties::Geometry::kVertical_Orientation, SkDeviceProperties::Geometry::Make(SkDeviceProperties::Geometry::kVertical_Orientation,
SkDeviceProperties::Geometry::kBGR_Layout), SkDeviceProperties::Geometry::kBGR_Layout),
SK_Scalar1); SK_Scalar1);
SkBitmapDevice device(bitmap, properties); SkDevice device(bitmap, properties);
SkCanvas canvas(&device); SkCanvas canvas(&device);
canvas.drawColor(SK_ColorWHITE); canvas.drawColor(SK_ColorWHITE);

Просмотреть файл

@ -25,7 +25,7 @@ protected:
void make_bitmap() { void make_bitmap() {
fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 80, 80);
fBitmap.allocPixels(); fBitmap.allocPixels();
SkBitmapDevice device(fBitmap); SkDevice device(fBitmap);
SkCanvas canvas(&device); SkCanvas canvas(&device);
canvas.clear(0x00000000); canvas.clear(0x00000000);
SkPaint paint; SkPaint paint;
@ -39,7 +39,7 @@ protected:
void make_checkerboard() { void make_checkerboard() {
fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, 80, 80);
fCheckerboard.allocPixels(); fCheckerboard.allocPixels();
SkBitmapDevice device(fCheckerboard); SkDevice device(fCheckerboard);
SkCanvas canvas(&device); SkCanvas canvas(&device);
canvas.clear(0x00000000); canvas.clear(0x00000000);
SkPaint darkPaint; SkPaint darkPaint;

Просмотреть файл

@ -74,7 +74,7 @@ protected:
} }
// Now do the same but with a device bitmap as source image // Now do the same but with a device bitmap as source image
SkAutoTUnref<SkBaseDevice> secondDevice(canvas->createCompatibleDevice( SkAutoTUnref<SkDevice> secondDevice(canvas->createCompatibleDevice(
SkBitmap::kARGB_8888_Config, bitmap.width(), SkBitmap::kARGB_8888_Config, bitmap.width(),
bitmap.height(), true)); bitmap.height(), true));
SkCanvas secondCanvas(secondDevice.get()); SkCanvas secondCanvas(secondDevice.get());

Просмотреть файл

@ -517,7 +517,7 @@ public:
SkAutoTUnref<SkCanvas> canvas; SkAutoTUnref<SkCanvas> canvas;
if (gRec.fBackend == kRaster_Backend) { if (gRec.fBackend == kRaster_Backend) {
SkAutoTUnref<SkBaseDevice> device(SkNEW_ARGS(SkBitmapDevice, (*bitmap))); SkAutoTUnref<SkDevice> device(SkNEW_ARGS(SkDevice, (*bitmap)));
if (deferred) { if (deferred) {
canvas.reset(SkDeferredCanvas::Create(device)); canvas.reset(SkDeferredCanvas::Create(device));
} else { } else {
@ -528,7 +528,7 @@ public:
} }
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
else { // GPU else { // GPU
SkAutoTUnref<SkBaseDevice> device(SkGpuDevice::Create(gpuTarget)); SkAutoTUnref<SkDevice> device(SkGpuDevice::Create(gpuTarget));
if (deferred) { if (deferred) {
canvas.reset(SkDeferredCanvas::Create(device)); canvas.reset(SkDeferredCanvas::Create(device));
} else { } else {

Просмотреть файл

@ -32,7 +32,7 @@ protected:
void make_bitmap() { void make_bitmap() {
fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
fBitmap.allocPixels(); fBitmap.allocPixels();
SkBitmapDevice device(fBitmap); SkDevice device(fBitmap);
SkCanvas canvas(&device); SkCanvas canvas(&device);
canvas.clear(0x00000000); canvas.clear(0x00000000);
SkPaint paint; SkPaint paint;

Просмотреть файл

@ -27,7 +27,7 @@ protected:
void make_bitmap() { void make_bitmap() {
fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
fBitmap.allocPixels(); fBitmap.allocPixels();
SkBitmapDevice device(fBitmap); SkDevice device(fBitmap);
SkCanvas canvas(&device); SkCanvas canvas(&device);
canvas.clear(0x00000000); canvas.clear(0x00000000);
SkPaint paint; SkPaint paint;

Просмотреть файл

@ -26,7 +26,7 @@ protected:
void make_bitmap() { void make_bitmap() {
fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 80, 80);
fBitmap.allocPixels(); fBitmap.allocPixels();
SkBitmapDevice device(fBitmap); SkDevice device(fBitmap);
SkCanvas canvas(&device); SkCanvas canvas(&device);
canvas.clear(0x00000000); canvas.clear(0x00000000);
SkPaint paint; SkPaint paint;

Просмотреть файл

@ -28,7 +28,7 @@ protected:
void make_bitmap() { void make_bitmap() {
fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 135, 135); fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 135, 135);
fBitmap.allocPixels(); fBitmap.allocPixels();
SkBitmapDevice device(fBitmap); SkDevice device(fBitmap);
SkCanvas canvas(&device); SkCanvas canvas(&device);
canvas.clear(0x0); canvas.clear(0x0);
SkPaint paint; SkPaint paint;

Просмотреть файл

@ -14,7 +14,7 @@ class GrContext;
#endif #endif
static void make_bitmap(SkBitmap* bitmap, GrContext* ctx, SkIRect* center) { static void make_bitmap(SkBitmap* bitmap, GrContext* ctx, SkIRect* center) {
SkBaseDevice* dev; SkDevice* dev;
const int kFixed = 28; const int kFixed = 28;
const int kStretchy = 8; const int kStretchy = 8;
@ -29,7 +29,7 @@ static void make_bitmap(SkBitmap* bitmap, GrContext* ctx, SkIRect* center) {
{ {
bitmap->setConfig(SkBitmap::kARGB_8888_Config, kSize, kSize); bitmap->setConfig(SkBitmap::kARGB_8888_Config, kSize, kSize);
bitmap->allocPixels(); bitmap->allocPixels();
dev = new SkBitmapDevice(*bitmap); dev = new SkDevice(*bitmap);
} }
SkCanvas canvas(dev); SkCanvas canvas(dev);

Просмотреть файл

@ -124,7 +124,7 @@ protected:
SkImage::kPremul_AlphaType SkImage::kPremul_AlphaType
}; };
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
SkBaseDevice* dev = canvas->getDevice(); SkDevice* dev = canvas->getDevice();
if (!skipGPU && dev->accessRenderTarget()) { if (!skipGPU && dev->accessRenderTarget()) {
SkGpuDevice* gd = (SkGpuDevice*)dev; SkGpuDevice* gd = (SkGpuDevice*)dev;
GrContext* ctx = gd->context(); GrContext* ctx = gd->context();

Просмотреть файл

@ -38,7 +38,7 @@ protected:
} }
virtual void onDraw(SkCanvas* canvas) { virtual void onDraw(SkCanvas* canvas) {
SkBaseDevice* device = canvas->getTopDevice(); SkDevice* device = canvas->getTopDevice();
GrRenderTarget* target = device->accessRenderTarget(); GrRenderTarget* target = device->accessRenderTarget();
GrContext* ctx = GetGr(); GrContext* ctx = GetGr();
if (ctx && target) { if (ctx && target) {

Просмотреть файл

@ -31,7 +31,7 @@ protected:
void make_bitmap() { void make_bitmap() {
fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 80, 80);
fBitmap.allocPixels(); fBitmap.allocPixels();
SkBitmapDevice device(fBitmap); SkDevice device(fBitmap);
SkCanvas canvas(&device); SkCanvas canvas(&device);
canvas.clear(0x00000000); canvas.clear(0x00000000);
SkPaint paint; SkPaint paint;
@ -45,7 +45,7 @@ protected:
void make_checkerboard() { void make_checkerboard() {
fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, 80, 80); fCheckerboard.setConfig(SkBitmap::kARGB_8888_Config, 80, 80);
fCheckerboard.allocPixels(); fCheckerboard.allocPixels();
SkBitmapDevice device(fCheckerboard); SkDevice device(fCheckerboard);
SkCanvas canvas(&device); SkCanvas canvas(&device);
canvas.clear(0x00000000); canvas.clear(0x00000000);
SkPaint darkPaint; SkPaint darkPaint;

Просмотреть файл

@ -132,7 +132,7 @@ private:
desc.fConfig = rt->config(); desc.fConfig = rt->config();
desc.fFlags = kRenderTarget_GrTextureFlagBit; desc.fFlags = kRenderTarget_GrTextureFlagBit;
SkAutoTUnref<GrSurface> surface(context->createUncachedTexture(desc, NULL, 0)); SkAutoTUnref<GrSurface> surface(context->createUncachedTexture(desc, NULL, 0));
SkAutoTUnref<SkBaseDevice> device(SkGpuDevice::Create(surface.get())); SkAutoTUnref<SkDevice> device(SkGpuDevice::Create(surface.get()));
if (NULL != device.get()) { if (NULL != device.get()) {
tempCanvas = SkNEW_ARGS(SkCanvas, (device.get())); tempCanvas = SkNEW_ARGS(SkCanvas, (device.get()));
} }

Просмотреть файл

@ -22,7 +22,7 @@
#include "SkXfermode.h" #include "SkXfermode.h"
class SkBounder; class SkBounder;
class SkBaseDevice; class SkDevice;
class SkDraw; class SkDraw;
class SkDrawFilter; class SkDrawFilter;
class SkMetaData; class SkMetaData;
@ -55,7 +55,7 @@ public:
@param device Specifies a device for the canvas to draw into. @param device Specifies a device for the canvas to draw into.
*/ */
explicit SkCanvas(SkBaseDevice* device); explicit SkCanvas(SkDevice* device);
/** Deprecated - Construct a canvas with the specified bitmap to draw into. /** Deprecated - Construct a canvas with the specified bitmap to draw into.
@param bitmap Specifies a bitmap for the canvas to draw into. Its @param bitmap Specifies a bitmap for the canvas to draw into. Its
@ -84,7 +84,7 @@ public:
the bitmap of the pixels that the canvas draws into. The reference count the bitmap of the pixels that the canvas draws into. The reference count
of the returned device is not changed by this call. of the returned device is not changed by this call.
*/ */
SkBaseDevice* getDevice() const; SkDevice* getDevice() const;
/** /**
* saveLayer() can create another device (which is later drawn onto * saveLayer() can create another device (which is later drawn onto
@ -99,15 +99,15 @@ public:
* is drawn to, but is optional here, as there is a small perf hit * is drawn to, but is optional here, as there is a small perf hit
* sometimes. * sometimes.
*/ */
SkBaseDevice* getTopDevice(bool updateMatrixClip = false) const; SkDevice* getTopDevice(bool updateMatrixClip = false) const;
/** /**
* Shortcut for getDevice()->createCompatibleDevice(...). * Shortcut for getDevice()->createCompatibleDevice(...).
* If getDevice() == NULL, this method does nothing, and returns NULL. * If getDevice() == NULL, this method does nothing, and returns NULL.
*/ */
SkBaseDevice* createCompatibleDevice(SkBitmap::Config config, SkDevice* createCompatibleDevice(SkBitmap::Config config,
int width, int height, int width, int height,
bool isOpaque); bool isOpaque);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -994,7 +994,7 @@ public:
// These reflect the current device in the iterator // These reflect the current device in the iterator
SkBaseDevice* device() const; SkDevice* device() const;
const SkMatrix& matrix() const; const SkMatrix& matrix() const;
const SkRegion& clip() const; const SkRegion& clip() const;
const SkPaint& paint() const; const SkPaint& paint() const;
@ -1043,7 +1043,7 @@ protected:
reference count is incremented. If the canvas was already holding a reference count is incremented. If the canvas was already holding a
device, its reference count is decremented. The new device is returned. device, its reference count is decremented. The new device is returned.
*/ */
virtual SkBaseDevice* setDevice(SkBaseDevice* device); virtual SkDevice* setDevice(SkDevice* device);
private: private:
class MCRec; class MCRec;
@ -1074,10 +1074,10 @@ private:
friend class SkDrawIter; // needs setupDrawForLayerDevice() friend class SkDrawIter; // needs setupDrawForLayerDevice()
friend class AutoDrawLooper; friend class AutoDrawLooper;
SkBaseDevice* createLayerDevice(SkBitmap::Config, int width, int height, SkDevice* createLayerDevice(SkBitmap::Config, int width, int height,
bool isOpaque); bool isOpaque);
SkBaseDevice* init(SkBaseDevice*); SkDevice* init(SkDevice*);
// internal methods are not virtual, so they can safely be called by other // internal methods are not virtual, so they can safely be called by other
// canvas apis, without confusing subclasses (like SkPictureRecording) // canvas apis, without confusing subclasses (like SkPictureRecording)
@ -1090,7 +1090,7 @@ private:
void internalDrawPaint(const SkPaint& paint); void internalDrawPaint(const SkPaint& paint);
int internalSaveLayer(const SkRect* bounds, const SkPaint* paint, int internalSaveLayer(const SkRect* bounds, const SkPaint* paint,
SaveFlags, bool justForImageFilter); SaveFlags, bool justForImageFilter);
void internalDrawDevice(SkBaseDevice*, int x, int y, const SkPaint*); void internalDrawDevice(SkDevice*, int x, int y, const SkPaint*);
// shared by save() and saveLayer() // shared by save() and saveLayer()
int internalSave(SaveFlags flags); int internalSave(SaveFlags flags);

Просмотреть файл

@ -25,21 +25,57 @@ class SkRegion;
class GrRenderTarget; class GrRenderTarget;
class SK_API SkBaseDevice : public SkRefCnt { class SK_API SkDevice : public SkRefCnt {
public: public:
SK_DECLARE_INST_COUNT(SkBaseDevice) SK_DECLARE_INST_COUNT(SkDevice)
/** /**
* Construct a new device. * Construct a new device with the specified bitmap as its backend. It is
* valid for the bitmap to have no pixels associated with it. In that case,
* any drawing to this device will have no effect.
*/ */
SkBaseDevice(); SkDevice(const SkBitmap& bitmap);
/** /**
* Construct a new device. * Construct a new device with the specified bitmap as its backend. It is
* valid for the bitmap to have no pixels associated with it. In that case,
* any drawing to this device will have no effect.
*/ */
SkBaseDevice(const SkDeviceProperties& deviceProperties); SkDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties);
virtual ~SkBaseDevice(); /**
* Create a new raster device and have the pixels be automatically
* allocated. The rowBytes of the device will be computed automatically
* based on the config and the width.
*
* @param config The desired config for the pixels. If the request cannot
* be met, the closest matching support config will be used.
* @param width width (in pixels) of the device
* @param height height (in pixels) of the device
* @param isOpaque Set to true if it is known that all of the pixels will
* be drawn to opaquely. Used as an accelerator when drawing
* these pixels to another device.
*/
SkDevice(SkBitmap::Config config, int width, int height, bool isOpaque = false);
/**
* Create a new raster device and have the pixels be automatically
* allocated. The rowBytes of the device will be computed automatically
* based on the config and the width.
*
* @param config The desired config for the pixels. If the request cannot
* be met, the closest matching support config will be used.
* @param width width (in pixels) of the device
* @param height height (in pixels) of the device
* @param isOpaque Set to true if it is known that all of the pixels will
* be drawn to opaquely. Used as an accelerator when drawing
* these pixels to another device.
* @param deviceProperties Properties which affect compositing.
*/
SkDevice(SkBitmap::Config config, int width, int height, bool isOpaque,
const SkDeviceProperties& deviceProperties);
virtual ~SkDevice();
/** /**
* Creates a device that is of the same type as this device (e.g. SW-raster, * Creates a device that is of the same type as this device (e.g. SW-raster,
@ -52,9 +88,9 @@ public:
* draw into this device such that all of the pixels will * draw into this device such that all of the pixels will
* be opaque. * be opaque.
*/ */
SkBaseDevice* createCompatibleDevice(SkBitmap::Config config, SkDevice* createCompatibleDevice(SkBitmap::Config config,
int width, int height, int width, int height,
bool isOpaque); bool isOpaque);
SkMetaData& getMetaData(); SkMetaData& getMetaData();
@ -63,14 +99,14 @@ public:
kVector_Capability = 0x2, //!< mask indicating a vector representation kVector_Capability = 0x2, //!< mask indicating a vector representation
kAll_Capabilities = 0x3 kAll_Capabilities = 0x3
}; };
virtual uint32_t getDeviceCapabilities() = 0; virtual uint32_t getDeviceCapabilities() { return 0; }
/** Return the width of the device (in pixels). /** Return the width of the device (in pixels).
*/ */
virtual int width() const = 0; virtual int width() const { return fBitmap.width(); }
/** Return the height of the device (in pixels). /** Return the height of the device (in pixels).
*/ */
virtual int height() const = 0; virtual int height() const { return fBitmap.height(); }
/** Return the image properties of the device. */ /** Return the image properties of the device. */
virtual const SkDeviceProperties& getDeviceProperties() const { virtual const SkDeviceProperties& getDeviceProperties() const {
@ -83,12 +119,16 @@ public:
* canvas. The root device will have its top-left at 0,0, but other devices * canvas. The root device will have its top-left at 0,0, but other devices
* such as those associated with saveLayer may have a non-zero origin. * such as those associated with saveLayer may have a non-zero origin.
*/ */
virtual void getGlobalBounds(SkIRect* bounds) const = 0; void getGlobalBounds(SkIRect* bounds) const;
/** Returns true if the device's bitmap's config treats every pixels as /** Returns true if the device's bitmap's config treats every pixels as
implicitly opaque. implicitly opaque.
*/ */
virtual bool isOpaque() const = 0; bool isOpaque() const { return fBitmap.isOpaque(); }
/** Return the bitmap config of the device's pixels
*/
SkBitmap::Config config() const { return fBitmap.getConfig(); }
/** Return the bitmap associated with this device. Call this each time you need /** Return the bitmap associated with this device. Call this each time you need
to access the bitmap, as it notifies the subclass to perform any flushing to access the bitmap, as it notifies the subclass to perform any flushing
@ -114,12 +154,12 @@ public:
* not kARGB_8888_Config then this parameter is ignored. * not kARGB_8888_Config then this parameter is ignored.
*/ */
virtual void writePixels(const SkBitmap& bitmap, int x, int y, virtual void writePixels(const SkBitmap& bitmap, int x, int y,
SkCanvas::Config8888 config8888 = SkCanvas::kNative_Premul_Config8888) = 0; SkCanvas::Config8888 config8888 = SkCanvas::kNative_Premul_Config8888);
/** /**
* Return the device's associated gpu render target, or NULL. * Return the device's associated gpu render target, or NULL.
*/ */
virtual GrRenderTarget* accessRenderTarget() = 0; virtual GrRenderTarget* accessRenderTarget() { return NULL; }
/** /**
@ -131,7 +171,7 @@ public:
/** /**
* onAttachToCanvas is invoked whenever a device is installed in a canvas * onAttachToCanvas is invoked whenever a device is installed in a canvas
* (i.e., setDevice, saveLayer (for the new device created by the save), * (i.e., setDevice, saveLayer (for the new device created by the save),
* and SkCanvas' SkBaseDevice & SkBitmap -taking ctors). It allows the * and SkCanvas' SkDevice & SkBitmap -taking ctors). It allows the
* devices to prepare for drawing (e.g., locking their pixels, etc.) * devices to prepare for drawing (e.g., locking their pixels, etc.)
*/ */
virtual void onAttachToCanvas(SkCanvas*) { virtual void onAttachToCanvas(SkCanvas*) {
@ -173,9 +213,9 @@ protected:
* textflags parameter (output) and return true. If the paint is fine as * textflags parameter (output) and return true. If the paint is fine as
* is, then ignore the textflags parameter and return false. * is, then ignore the textflags parameter and return false.
* *
* The baseclass SkBaseDevice filters based on its depth and blitters. * The baseclass SkDevice filters based on its depth and blitters.
*/ */
virtual bool filterTextFlags(const SkPaint& paint, TextFlags*) = 0; virtual bool filterTextFlags(const SkPaint& paint, TextFlags*);
/** /**
* *
@ -194,12 +234,12 @@ protected:
* passed in). * passed in).
*/ */
virtual void setMatrixClip(const SkMatrix&, const SkRegion&, virtual void setMatrixClip(const SkMatrix&, const SkRegion&,
const SkClipStack&) {}; const SkClipStack&);
/** Clears the entire device to the specified color (including alpha). /** Clears the entire device to the specified color (including alpha).
* Ignores the clip. * Ignores the clip.
*/ */
virtual void clear(SkColor color) = 0; virtual void clear(SkColor color);
/** /**
* Deprecated name for clear. * Deprecated name for clear.
@ -211,15 +251,15 @@ protected:
and are handling any looping from the paint, and any effects from the and are handling any looping from the paint, and any effects from the
DrawFilter. DrawFilter.
*/ */
virtual void drawPaint(const SkDraw&, const SkPaint& paint) = 0; virtual void drawPaint(const SkDraw&, const SkPaint& paint);
virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count, virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, size_t count,
const SkPoint[], const SkPaint& paint) = 0; const SkPoint[], const SkPaint& paint);
virtual void drawRect(const SkDraw&, const SkRect& r, virtual void drawRect(const SkDraw&, const SkRect& r,
const SkPaint& paint) = 0; const SkPaint& paint);
virtual void drawOval(const SkDraw&, const SkRect& oval, virtual void drawOval(const SkDraw&, const SkRect& oval,
const SkPaint& paint) = 0; const SkPaint& paint);
virtual void drawRRect(const SkDraw&, const SkRRect& rr, virtual void drawRRect(const SkDraw&, const SkRRect& rr,
const SkPaint& paint) = 0; const SkPaint& paint);
/** /**
* If pathIsMutable, then the implementation is allowed to cast path to a * If pathIsMutable, then the implementation is allowed to cast path to a
@ -235,11 +275,11 @@ protected:
virtual void drawPath(const SkDraw&, const SkPath& path, virtual void drawPath(const SkDraw&, const SkPath& path,
const SkPaint& paint, const SkPaint& paint,
const SkMatrix* prePathMatrix = NULL, const SkMatrix* prePathMatrix = NULL,
bool pathIsMutable = false) = 0; bool pathIsMutable = false);
virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap, virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap,
const SkMatrix& matrix, const SkPaint& paint) = 0; const SkMatrix& matrix, const SkPaint& paint);
virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap, virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap,
int x, int y, const SkPaint& paint) = 0; int x, int y, const SkPaint& paint);
/** /**
* The default impl. will create a bitmap-shader from the bitmap, * The default impl. will create a bitmap-shader from the bitmap,
@ -248,35 +288,35 @@ protected:
virtual void drawBitmapRect(const SkDraw&, const SkBitmap&, virtual void drawBitmapRect(const SkDraw&, const SkBitmap&,
const SkRect* srcOrNull, const SkRect& dst, const SkRect* srcOrNull, const SkRect& dst,
const SkPaint& paint, const SkPaint& paint,
SkCanvas::DrawBitmapRectFlags flags) = 0; SkCanvas::DrawBitmapRectFlags flags);
/** /**
* Does not handle text decoration. * Does not handle text decoration.
* Decorations (underline and stike-thru) will be handled by SkCanvas. * Decorations (underline and stike-thru) will be handled by SkCanvas.
*/ */
virtual void drawText(const SkDraw&, const void* text, size_t len, virtual void drawText(const SkDraw&, const void* text, size_t len,
SkScalar x, SkScalar y, const SkPaint& paint) = 0; SkScalar x, SkScalar y, const SkPaint& paint);
virtual void drawPosText(const SkDraw&, const void* text, size_t len, virtual void drawPosText(const SkDraw&, const void* text, size_t len,
const SkScalar pos[], SkScalar constY, const SkScalar pos[], SkScalar constY,
int scalarsPerPos, const SkPaint& paint) = 0; int scalarsPerPos, const SkPaint& paint);
virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len, virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
const SkPath& path, const SkMatrix* matrix, const SkPath& path, const SkMatrix* matrix,
const SkPaint& paint) = 0; const SkPaint& paint);
#ifdef SK_BUILD_FOR_ANDROID #ifdef SK_BUILD_FOR_ANDROID
virtual void drawPosTextOnPath(const SkDraw& draw, const void* text, size_t len, virtual void drawPosTextOnPath(const SkDraw& draw, const void* text, size_t len,
const SkPoint pos[], const SkPaint& paint, const SkPoint pos[], const SkPaint& paint,
const SkPath& path, const SkMatrix* matrix) = 0; const SkPath& path, const SkMatrix* matrix);
#endif #endif
virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCount, virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCount,
const SkPoint verts[], const SkPoint texs[], const SkPoint verts[], const SkPoint texs[],
const SkColor colors[], SkXfermode* xmode, const SkColor colors[], SkXfermode* xmode,
const uint16_t indices[], int indexCount, const uint16_t indices[], int indexCount,
const SkPaint& paint) = 0; const SkPaint& paint);
/** The SkBaseDevice passed will be an SkBaseDevice which was returned by a call to /** The SkDevice passed will be an SkDevice which was returned by a call to
onCreateCompatibleDevice on this device with kSaveLayer_Usage. onCreateCompatibleDevice on this device with kSaveLayer_Usage.
*/ */
virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, virtual void drawDevice(const SkDraw&, SkDevice*, int x, int y,
const SkPaint&) = 0; const SkPaint&);
/** /**
* On success (returns true), copy the device pixels into the bitmap. * On success (returns true), copy the device pixels into the bitmap.
@ -311,308 +351,14 @@ protected:
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
/** Update as needed the pixel value in the bitmap, so that the caller can
access the pixels directly.
@return The device contents as a bitmap
*/
virtual const SkBitmap& onAccessBitmap() = 0;
/**
* 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.
*/
virtual bool onReadPixels(const SkBitmap& bitmap,
int x, int y,
SkCanvas::Config8888 config8888) = 0;
/** Called when this device is installed into a Canvas. Balanaced by a call
to unlockPixels() when the device is removed from a Canvas.
*/
virtual void lockPixels() = 0;
virtual void unlockPixels() = 0;
/**
* Returns true if the device allows processing of this imagefilter. If
* false is returned, then the filter is ignored. This may happen for
* some subclasses that do not support pixel manipulations after drawing
* has occurred (e.g. printing). The default implementation returns true.
*/
virtual bool allowImageFilter(SkImageFilter*) = 0;
/**
* Override and return true for filters that the device can handle
* intrinsically. Doing so means that SkCanvas will pass-through this
* filter to drawSprite and drawDevice (and potentially filterImage).
* Returning false means the SkCanvas will have apply the filter itself,
* and just pass the resulting image to the device.
*/
virtual bool canHandleImageFilter(SkImageFilter*) = 0;
/**
* Related (but not required) to canHandleImageFilter, this method returns
* true if the device could apply the filter to the src bitmap and return
* the result (and updates offset as needed).
* If the device does not recognize or support this filter,
* it just returns false and leaves result and offset unchanged.
*/
virtual bool filterImage(SkImageFilter*, const SkBitmap&, const SkMatrix&,
SkBitmap* result, SkIPoint* offset) = 0;
// 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;
private:
friend class SkCanvas;
friend struct DeviceCM; //for setMatrixClip
friend class SkDraw;
friend class SkDrawIter;
friend class SkDeviceFilteredPaint;
friend class SkDeviceImageFilterProxy;
friend class SkSurface_Raster;
// used to change the backend's pixels (and possibly config/rowbytes)
// but cannot change the width/height, so there should be no change to
// any clip information.
virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) = 0;
// just called by SkCanvas when built as a layer
void setOrigin(int x, int y) { fOrigin.set(x, y); }
// just called by SkCanvas for saveLayer
SkBaseDevice* createCompatibleDeviceForSaveLayer(SkBitmap::Config config,
int width, int height,
bool isOpaque);
/**
* Subclasses should override this to implement createCompatibleDevice.
*/
virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config,
int width, int height,
bool isOpaque,
Usage usage) = 0;
/** Causes any deferred drawing to the device to be completed.
*/
virtual void flush() = 0;
SkIPoint fOrigin;
SkMetaData* fMetaData;
/**
* Leaky properties are those which the device should be applying but it isn't.
* These properties will be applied by the draw, when and as it can.
* If the device does handle a property, that property should be set to the identity value
* for that property, effectively making it non-leaky.
*/
SkDeviceProperties fLeakyProperties;
#ifdef SK_DEBUG
bool fAttachedToCanvas;
#endif
typedef SkRefCnt INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
class SK_API SkBitmapDevice : public SkBaseDevice {
public:
SK_DECLARE_INST_COUNT(SkBitmapDevice)
/**
* Construct a new device with the specified bitmap as its backend. It is
* valid for the bitmap to have no pixels associated with it. In that case,
* any drawing to this device will have no effect.
*/
SkBitmapDevice(const SkBitmap& bitmap);
/**
* Construct a new device with the specified bitmap as its backend. It is
* valid for the bitmap to have no pixels associated with it. In that case,
* any drawing to this device will have no effect.
*/
SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties);
/**
* Create a new raster device and have the pixels be automatically
* allocated. The rowBytes of the device will be computed automatically
* based on the config and the width.
*
* @param config The desired config for the pixels. If the request cannot
* be met, the closest matching support config will be used.
* @param width width (in pixels) of the device
* @param height height (in pixels) of the device
* @param isOpaque Set to true if it is known that all of the pixels will
* be drawn to opaquely. Used as an accelerator when drawing
* these pixels to another device.
*/
SkBitmapDevice(SkBitmap::Config config, int width, int height, bool isOpaque);
/**
* Create a new raster device and have the pixels be automatically
* allocated. The rowBytes of the device will be computed automatically
* based on the config and the width.
*
* @param config The desired config for the pixels. If the request cannot
* be met, the closest matching support config will be used.
* @param width width (in pixels) of the device
* @param height height (in pixels) of the device
* @param isOpaque Set to true if it is known that all of the pixels will
* be drawn to opaquely. Used as an accelerator when drawing
* these pixels to another device.
* @param deviceProperties Properties which affect compositing.
*/
SkBitmapDevice(SkBitmap::Config config, int width, int height, bool isOpaque,
const SkDeviceProperties& deviceProperties);
virtual ~SkBitmapDevice();
virtual uint32_t getDeviceCapabilities() SK_OVERRIDE { return 0; }
/** Return the width of the device (in pixels).
*/
virtual int width() const SK_OVERRIDE { return fBitmap.width(); }
/** Return the height of the device (in pixels).
*/
virtual int height() const SK_OVERRIDE { return fBitmap.height(); }
/**
* Return the bounds of the device in the coordinate space of the root
* canvas. The root device will have its top-left at 0,0, but other devices
* such as those associated with saveLayer may have a non-zero origin.
*/
virtual void getGlobalBounds(SkIRect* bounds) const SK_OVERRIDE;
/** Returns true if the device's bitmap's config treats every pixels as
implicitly opaque.
*/
virtual bool isOpaque() const SK_OVERRIDE { return fBitmap.isOpaque(); }
/** Return the bitmap config of the device's pixels
*/
virtual SkBitmap::Config config() const { return fBitmap.getConfig(); }
/**
* 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;
/**
* Return the device's associated gpu render target, or NULL.
*/
virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE { return NULL; }
protected:
/**
* Device may filter the text flags for drawing text here. If it wants to
* make a change to the specified values, it should write them into the
* textflags parameter (output) and return true. If the paint is fine as
* is, then ignore the textflags parameter and return false.
*
* The baseclass SkDevice filters based on its depth and blitters.
*/
virtual bool filterTextFlags(const SkPaint& paint, TextFlags*) SK_OVERRIDE;
/** Clears the entire device to the specified color (including alpha).
* Ignores the clip.
*/
virtual void clear(SkColor color) SK_OVERRIDE;
/** These are called inside the per-device-layer loop for each draw call.
When these are called, we have already applied any saveLayer operations,
and are handling any looping from the paint, and any effects from the
DrawFilter.
*/
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;
virtual void drawRect(const SkDraw&, const SkRect& r,
const SkPaint& paint) SK_OVERRIDE;
virtual void drawOval(const SkDraw&, const SkRect& oval,
const SkPaint& paint) SK_OVERRIDE;
virtual void drawRRect(const SkDraw&, const SkRRect& rr,
const SkPaint& paint) SK_OVERRIDE;
/**
* If pathIsMutable, then the implementation is allowed to cast path to a
* non-const pointer and modify it in place (as an optimization). Canvas
* may do this to implement helpers such as drawOval, by placing a temp
* path on the stack to hold the representation of the oval.
*
* If prePathMatrix is not null, it should logically be applied before any
* stroking or other effects. If there are no effects on the paint that
* affect the geometry/rasterization, then the pre matrix can just be
* pre-concated with the current matrix.
*/
virtual void drawPath(const SkDraw&, const SkPath& path,
const SkPaint& paint,
const SkMatrix* prePathMatrix = NULL,
bool pathIsMutable = false) SK_OVERRIDE;
virtual void drawBitmap(const SkDraw&, const SkBitmap& bitmap,
const SkMatrix& matrix, const SkPaint& paint) SK_OVERRIDE;
virtual void drawSprite(const SkDraw&, const SkBitmap& bitmap,
int x, int y, const SkPaint& paint) SK_OVERRIDE;
/**
* The default impl. will create a bitmap-shader from the bitmap,
* and call drawRect with it.
*/
virtual void drawBitmapRect(const SkDraw&, const SkBitmap&,
const SkRect* srcOrNull, const SkRect& dst,
const SkPaint& paint,
SkCanvas::DrawBitmapRectFlags flags) SK_OVERRIDE;
/**
* Does not handle text decoration.
* Decorations (underline and stike-thru) will be handled by SkCanvas.
*/
virtual void drawText(const SkDraw&, const void* text, size_t len,
SkScalar x, SkScalar y, const SkPaint& paint) SK_OVERRIDE;
virtual void drawPosText(const SkDraw&, const void* text, size_t len,
const SkScalar pos[], SkScalar constY,
int scalarsPerPos, const SkPaint& paint) SK_OVERRIDE;
virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
const SkPath& path, const SkMatrix* matrix,
const SkPaint& paint) SK_OVERRIDE;
#ifdef SK_BUILD_FOR_ANDROID
virtual void drawPosTextOnPath(const SkDraw& draw, const void* text, size_t len,
const SkPoint pos[], const SkPaint& paint,
const SkPath& path, const SkMatrix* matrix) SK_OVERRIDE;
#endif
virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, int vertexCount,
const SkPoint verts[], const SkPoint texs[],
const SkColor colors[], SkXfermode* xmode,
const uint16_t indices[], int indexCount,
const SkPaint& paint) SK_OVERRIDE;
/** The SkBaseDevice passed will be an SkBaseDevice which was returned by a call to
onCreateCompatibleDevice on this device with kSaveLayer_Usage.
*/
virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y,
const SkPaint&) SK_OVERRIDE;
///////////////////////////////////////////////////////////////////////////
/** Update as needed the pixel value in the bitmap, so that the caller can /** Update as needed the pixel value in the bitmap, so that the caller can
access the pixels directly. Note: only the pixels field should be access the pixels directly. Note: only the pixels field should be
altered. The config/width/height/rowbytes must remain unchanged. altered. The config/width/height/rowbytes must remain unchanged.
@return the device contents as a bitmap @param bitmap The device's bitmap
@return Echo the bitmap parameter, or an alternate (shadow) bitmap
maintained by the subclass.
*/ */
virtual const SkBitmap& onAccessBitmap() SK_OVERRIDE; virtual const SkBitmap& onAccessBitmap(SkBitmap*);
SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); } SkPixelRef* getPixelRef() const { return fBitmap.pixelRef(); }
// just for subclasses, to assign a custom pixelref // just for subclasses, to assign a custom pixelref
@ -630,13 +376,13 @@ protected:
*/ */
virtual bool onReadPixels(const SkBitmap& bitmap, virtual bool onReadPixels(const SkBitmap& bitmap,
int x, int y, int x, int y,
SkCanvas::Config8888 config8888) SK_OVERRIDE; SkCanvas::Config8888 config8888);
/** Called when this device is installed into a Canvas. Balanced by a call /** Called when this device is installed into a Canvas. Balanaced by a call
to unlockPixels() when the device is removed from a Canvas. to unlockPixels() when the device is removed from a Canvas.
*/ */
virtual void lockPixels() SK_OVERRIDE; virtual void lockPixels();
virtual void unlockPixels() SK_OVERRIDE; virtual void unlockPixels();
/** /**
* Returns true if the device allows processing of this imagefilter. If * Returns true if the device allows processing of this imagefilter. If
@ -644,7 +390,7 @@ protected:
* some subclasses that do not support pixel manipulations after drawing * some subclasses that do not support pixel manipulations after drawing
* has occurred (e.g. printing). The default implementation returns true. * has occurred (e.g. printing). The default implementation returns true.
*/ */
virtual bool allowImageFilter(SkImageFilter*) SK_OVERRIDE; virtual bool allowImageFilter(SkImageFilter*);
/** /**
* Override and return true for filters that the device can handle * Override and return true for filters that the device can handle
@ -653,7 +399,7 @@ protected:
* Returning false means the SkCanvas will have apply the filter itself, * Returning false means the SkCanvas will have apply the filter itself,
* and just pass the resulting image to the device. * and just pass the resulting image to the device.
*/ */
virtual bool canHandleImageFilter(SkImageFilter*) SK_OVERRIDE; virtual bool canHandleImageFilter(SkImageFilter*);
/** /**
* Related (but not required) to canHandleImageFilter, this method returns * Related (but not required) to canHandleImageFilter, this method returns
@ -663,7 +409,11 @@ protected:
* it just returns false and leaves result and offset unchanged. * it just returns false and leaves result and offset unchanged.
*/ */
virtual bool filterImage(SkImageFilter*, const SkBitmap&, const SkMatrix&, virtual bool filterImage(SkImageFilter*, const SkBitmap&, const SkMatrix&,
SkBitmap* result, SkIPoint* offset) SK_OVERRIDE; SkBitmap* result, SkIPoint* offset);
// 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;
private: private:
friend class SkCanvas; friend class SkCanvas;
@ -674,31 +424,46 @@ private:
friend class SkDeviceImageFilterProxy; friend class SkDeviceImageFilterProxy;
friend class SkSurface_Raster; friend class SkSurface_Raster;
// used to change the backend's pixels (and possibly config/rowbytes) // used to change the backend's pixels (and possibly config/rowbytes)
// but cannot change the width/height, so there should be no change to // but cannot change the width/height, so there should be no change to
// any clip information. // any clip information.
virtual void replaceBitmapBackendForRasterSurface(const SkBitmap&) SK_OVERRIDE; void replaceBitmapBackendForRasterSurface(const SkBitmap&);
// just called by SkCanvas when built as a layer
void setOrigin(int x, int y) { fOrigin.set(x, y); }
// just called by SkCanvas for saveLayer
SkDevice* createCompatibleDeviceForSaveLayer(SkBitmap::Config config,
int width, int height,
bool isOpaque);
/** /**
* Subclasses should override this to implement createCompatibleDevice. * Subclasses should override this to implement createCompatibleDevice.
*/ */
virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config, virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config config,
int width, int height, int width, int height,
bool isOpaque, bool isOpaque,
Usage usage) SK_OVERRIDE; Usage usage);
/** Causes any deferred drawing to the device to be completed. /** Causes any deferred drawing to the device to be completed.
*/ */
virtual void flush() SK_OVERRIDE {} virtual void flush() {}
SkBitmap fBitmap; SkBitmap fBitmap;
SkIPoint fOrigin;
SkMetaData* fMetaData;
/**
* Leaky properties are those which the device should be applying but it isn't.
* These properties will be applied by the draw, when and as it can.
* If the device does handle a property, that property should be set to the identity value
* for that property, effectively making it non-leaky.
*/
SkDeviceProperties fLeakyProperties;
typedef SkBaseDevice INHERITED; #ifdef SK_DEBUG
bool fAttachedToCanvas;
#endif
typedef SkRefCnt INHERITED;
}; };
// Temporary typedef until Chromium (and other clients) are able to move to
// SkBaseDevice or SkBitmapDevice
typedef SkBitmapDevice SkDevice;
#endif #endif

Просмотреть файл

@ -17,7 +17,7 @@
class SkBitmap; class SkBitmap;
class SkBounder; class SkBounder;
class SkClipStack; class SkClipStack;
class SkBaseDevice; class SkDevice;
class SkMatrix; class SkMatrix;
class SkPath; class SkPath;
class SkRegion; class SkRegion;
@ -127,7 +127,7 @@ public:
const SkRasterClip* fRC; // required const SkRasterClip* fRC; // required
const SkClipStack* fClipStack; // optional const SkClipStack* fClipStack; // optional
SkBaseDevice* fDevice; // optional SkDevice* fDevice; // optional
SkBounder* fBounder; // optional SkBounder* fBounder; // optional
SkDrawProcs* fProcs; // optional SkDrawProcs* fProcs; // optional

Просмотреть файл

@ -13,7 +13,7 @@
class SkBitmap; class SkBitmap;
class SkColorFilter; class SkColorFilter;
class SkBaseDevice; class SkDevice;
class SkMatrix; class SkMatrix;
struct SkIPoint; struct SkIPoint;
class SkShader; class SkShader;
@ -35,7 +35,7 @@ public:
public: public:
virtual ~Proxy() {}; virtual ~Proxy() {};
virtual SkBaseDevice* createDevice(int width, int height) = 0; virtual SkDevice* createDevice(int width, int height) = 0;
// returns true if the proxy can handle this filter natively // returns true if the proxy can handle this filter natively
virtual bool canHandleImageFilter(SkImageFilter*) = 0; virtual bool canHandleImageFilter(SkImageFilter*) = 0;
// returns true if the proxy handled the filter itself. if this returns // returns true if the proxy handled the filter itself. if this returns

Просмотреть файл

@ -25,7 +25,7 @@ class SkPath;
// use growToInclude to fit skp round rects & generate stats (RRs vs. real paths) // use growToInclude to fit skp round rects & generate stats (RRs vs. real paths)
// check on # of rectorus's the RRs could handle // check on # of rectorus's the RRs could handle
// rendering work // rendering work
// add entry points (clipRRect, drawRRect) - plumb down to SkBaseDevice // add entry points (clipRRect, drawRRect) - plumb down to SkDevice
// update SkPath.addRRect() to take an SkRRect - only use quads // update SkPath.addRRect() to take an SkRRect - only use quads
// -- alternatively add addRRectToPath here // -- alternatively add addRRectToPath here
// add GM and bench // add GM and bench

Просмотреть файл

@ -30,7 +30,7 @@
The drawing context for the XPS backend. The drawing context for the XPS backend.
*/ */
class SkXPSDevice : public SkBitmapDevice { class SkXPSDevice : public SkDevice {
public: public:
SK_API SkXPSDevice(); SK_API SkXPSDevice();
SK_API virtual ~SkXPSDevice(); SK_API virtual ~SkXPSDevice();
@ -134,7 +134,7 @@ protected:
virtual void drawDevice( virtual void drawDevice(
const SkDraw&, const SkDraw&,
SkBaseDevice* device, SkDevice* device,
int x, int y, int x, int y,
const SkPaint& paint) SK_OVERRIDE; const SkPaint& paint) SK_OVERRIDE;
@ -307,17 +307,18 @@ private:
const SkVector& ppuScale, const SkVector& ppuScale,
IXpsOMPath* shadedPath); IXpsOMPath* shadedPath);
// override from SkBaseDevice // override from SkDevice
virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config, virtual SkDevice* onCreateCompatibleDevice(
int width, int height, SkBitmap::Config config,
bool isOpaque, int width, int height,
Usage usage) SK_OVERRIDE; bool isOpaque,
Usage usage) SK_OVERRIDE;
// Disable the default copy and assign implementation. // Disable the default copy and assign implementation.
SkXPSDevice(const SkXPSDevice&); SkXPSDevice(const SkXPSDevice&);
void operator=(const SkXPSDevice&); void operator=(const SkXPSDevice&);
typedef SkBitmapDevice INHERITED; typedef SkDevice INHERITED;
}; };
#endif #endif

Просмотреть файл

@ -22,10 +22,10 @@ struct GrSkDrawProcs;
class GrTextContext; class GrTextContext;
/** /**
* Subclass of SkBitmapDevice, which directs all drawing to the GrGpu owned by the * Subclass of SkDevice, which directs all drawing to the GrGpu owned by the
* canvas. * canvas.
*/ */
class SK_API SkGpuDevice : public SkBitmapDevice { class SK_API SkGpuDevice : public SkDevice {
public: public:
/** /**
@ -62,7 +62,7 @@ public:
virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE; virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE;
// overrides from SkBaseDevice // overrides from SkDevice
virtual void clear(SkColor color) SK_OVERRIDE; virtual void clear(SkColor color) SK_OVERRIDE;
virtual void writePixels(const SkBitmap& bitmap, int x, int y, virtual void writePixels(const SkBitmap& bitmap, int x, int y,
@ -101,11 +101,11 @@ public:
const SkColor colors[], SkXfermode* xmode, const SkColor colors[], SkXfermode* xmode,
const uint16_t indices[], int indexCount, const uint16_t indices[], int indexCount,
const SkPaint&) SK_OVERRIDE; const SkPaint&) SK_OVERRIDE;
virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, virtual void drawDevice(const SkDraw&, SkDevice*, int x, int y,
const SkPaint&) SK_OVERRIDE; const SkPaint&) SK_OVERRIDE;
virtual bool filterTextFlags(const SkPaint&, TextFlags*) SK_OVERRIDE; virtual bool filterTextFlags(const SkPaint&, TextFlags*) SK_OVERRIDE;
virtual void flush() SK_OVERRIDE; virtual void flush();
virtual void onAttachToCanvas(SkCanvas* canvas) SK_OVERRIDE; virtual void onAttachToCanvas(SkCanvas* canvas) SK_OVERRIDE;
virtual void onDetachFromCanvas() SK_OVERRIDE; virtual void onDetachFromCanvas() SK_OVERRIDE;
@ -123,7 +123,7 @@ public:
class SkAutoCachedTexture; // used internally class SkAutoCachedTexture; // used internally
protected: protected:
// overrides from SkBaseDevice // overrides from SkDevice
virtual bool onReadPixels(const SkBitmap& bitmap, virtual bool onReadPixels(const SkBitmap& bitmap,
int x, int y, int x, int y,
SkCanvas::Config8888 config8888) SK_OVERRIDE; SkCanvas::Config8888 config8888) SK_OVERRIDE;
@ -145,11 +145,11 @@ private:
// used by createCompatibleDevice // used by createCompatibleDevice
SkGpuDevice(GrContext*, GrTexture* texture, bool needClear); SkGpuDevice(GrContext*, GrTexture* texture, bool needClear);
// override from SkBaseDevice // override from SkDevice
virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config, virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config config,
int width, int height, int width, int height,
bool isOpaque, bool isOpaque,
Usage usage) SK_OVERRIDE; Usage usage) SK_OVERRIDE;
SkDrawProcs* initDrawForText(GrTextContext*); SkDrawProcs* initDrawForText(GrTextContext*);
@ -192,7 +192,7 @@ private:
*/ */
GrTextContext* getTextContext(); GrTextContext* getTextContext();
typedef SkBitmapDevice INHERITED; typedef SkDevice INHERITED;
}; };
#endif #endif

Просмотреть файл

@ -44,7 +44,7 @@ typedef bool (*EncodeToDCTStream)(SkWStream* stream, const SkBitmap& bitmap, con
The drawing context for the PDF backend. The drawing context for the PDF backend.
*/ */
class SkPDFDevice : public SkBitmapDevice { class SkPDFDevice : public SkDevice {
public: public:
/** Create a PDF drawing context with the given width and height. /** Create a PDF drawing context with the given width and height.
* 72 points/in means letter paper is 612x792. * 72 points/in means letter paper is 612x792.
@ -107,7 +107,7 @@ public:
const SkPoint texs[], const SkColor colors[], const SkPoint texs[], const SkColor colors[],
SkXfermode* xmode, const uint16_t indices[], SkXfermode* xmode, const uint16_t indices[],
int indexCount, const SkPaint& paint) SK_OVERRIDE; int indexCount, const SkPaint& paint) SK_OVERRIDE;
virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, virtual void drawDevice(const SkDraw&, SkDevice*, int x, int y,
const SkPaint&) SK_OVERRIDE; const SkPaint&) SK_OVERRIDE;
virtual void onAttachToCanvas(SkCanvas* canvas) SK_OVERRIDE; virtual void onAttachToCanvas(SkCanvas* canvas) SK_OVERRIDE;
@ -237,11 +237,11 @@ private:
SkPDFDevice(const SkISize& layerSize, const SkClipStack& existingClipStack, SkPDFDevice(const SkISize& layerSize, const SkClipStack& existingClipStack,
const SkRegion& existingClipRegion); const SkRegion& existingClipRegion);
// override from SkBaseDevice // override from SkDevice
virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config, virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config config,
int width, int height, int width, int height,
bool isOpaque, bool isOpaque,
Usage usage) SK_OVERRIDE; Usage usage) SK_OVERRIDE;
void init(); void init();
void cleanUp(bool clearFontUsage); void cleanUp(bool clearFontUsage);
@ -310,7 +310,7 @@ private:
void defineNamedDestination(SkData* nameData, const SkPoint& point, void defineNamedDestination(SkData* nameData, const SkPoint& point,
const SkMatrix& matrix); const SkMatrix& matrix);
typedef SkBitmapDevice INHERITED; typedef SkDevice INHERITED;
}; };
#endif #endif

Просмотреть файл

@ -33,7 +33,7 @@ public:
*/ */
static SkDeferredCanvas* Create(SkSurface* surface); static SkDeferredCanvas* Create(SkSurface* surface);
static SkDeferredCanvas* Create(SkBaseDevice* device); static SkDeferredCanvas* Create(SkDevice* device);
virtual ~SkDeferredCanvas(); virtual ~SkDeferredCanvas();

Просмотреть файл

@ -269,7 +269,7 @@ public:
SampleWindow* win) { SampleWindow* win) {
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
if (IsGpuDeviceType(dType) && NULL != fCurContext) { if (IsGpuDeviceType(dType) && NULL != fCurContext) {
SkAutoTUnref<SkBaseDevice> device(new SkGpuDevice(fCurContext, fCurRenderTarget)); SkAutoTUnref<SkDevice> device(new SkGpuDevice(fCurContext, fCurRenderTarget));
return new SkCanvas(device); return new SkCanvas(device);
} else } else
#endif #endif
@ -1429,7 +1429,7 @@ void SampleWindow::afterChildren(SkCanvas* orig) {
if (fRequestGrabImage) { if (fRequestGrabImage) {
fRequestGrabImage = false; fRequestGrabImage = false;
SkBaseDevice* device = orig->getDevice(); SkDevice* device = orig->getDevice();
SkBitmap bmp; SkBitmap bmp;
if (device->accessBitmap(false).copyTo(&bmp, SkBitmap::kARGB_8888_Config)) { if (device->accessBitmap(false).copyTo(&bmp, SkBitmap::kARGB_8888_Config)) {
static int gSampleGrabCounter; static int gSampleGrabCounter;

Просмотреть файл

@ -61,7 +61,7 @@ public:
/** /**
* SampleApp ports can subclass this manager class if they want to: * SampleApp ports can subclass this manager class if they want to:
* * filter the types of devices supported * * filter the types of devices supported
* * customize plugging of SkBaseDevice objects into an SkCanvas * * customize plugging of SkDevice objects into an SkCanvas
* * customize publishing the results of draw to the OS window * * customize publishing the results of draw to the OS window
* * manage GrContext / GrRenderTarget lifetimes * * manage GrContext / GrRenderTarget lifetimes
*/ */

Просмотреть файл

@ -74,7 +74,7 @@ protected:
} }
static void blowup(SkCanvas* canvas, const SkIRect& src, const SkRect& dst) { static void blowup(SkCanvas* canvas, const SkIRect& src, const SkRect& dst) {
SkBaseDevice* device = canvas->getDevice(); SkDevice* device = canvas->getDevice();
const SkBitmap& bm = device->accessBitmap(false); const SkBitmap& bm = device->accessBitmap(false);
canvas->drawBitmapRect(bm, &src, dst, NULL); canvas->drawBitmapRect(bm, &src, dst, NULL);
} }

Просмотреть файл

@ -61,7 +61,7 @@ protected:
// the constrainted texture domain. // the constrainted texture domain.
// Note: GPU-backed bitmaps follow a different rendering path // Note: GPU-backed bitmaps follow a different rendering path
// when copying from one GPU device to another. // when copying from one GPU device to another.
SkAutoTUnref<SkBaseDevice> secondDevice(canvas->createCompatibleDevice( SkAutoTUnref<SkDevice> secondDevice(canvas->createCompatibleDevice(
SkBitmap::kARGB_8888_Config, 5, 5, true)); SkBitmap::kARGB_8888_Config, 5, 5, true));
SkCanvas secondCanvas(secondDevice.get()); SkCanvas secondCanvas(secondDevice.get());

Просмотреть файл

@ -11,7 +11,7 @@
SkBBoxHierarchyRecord::SkBBoxHierarchyRecord(uint32_t recordFlags, SkBBoxHierarchyRecord::SkBBoxHierarchyRecord(uint32_t recordFlags,
SkBBoxHierarchy* h, SkBBoxHierarchy* h,
SkBaseDevice* device) SkDevice* device)
: INHERITED(recordFlags, device) { : INHERITED(recordFlags, device) {
fStateTree = SkNEW(SkPictureStateTree); fStateTree = SkNEW(SkPictureStateTree);
fBoundingHierarchy = h; fBoundingHierarchy = h;

Просмотреть файл

@ -20,7 +20,7 @@ class SkBBoxHierarchyRecord : public SkBBoxRecord, public SkBBoxHierarchyClient
public: public:
/** This will take a ref of h */ /** This will take a ref of h */
SkBBoxHierarchyRecord(uint32_t recordFlags, SkBBoxHierarchy* h, SkBBoxHierarchyRecord(uint32_t recordFlags, SkBBoxHierarchy* h,
SkBaseDevice*); SkDevice*);
virtual void handleBBox(const SkRect& bounds) SK_OVERRIDE; virtual void handleBBox(const SkRect& bounds) SK_OVERRIDE;

Просмотреть файл

@ -19,7 +19,7 @@
class SkBBoxRecord : public SkPictureRecord { class SkBBoxRecord : public SkPictureRecord {
public: public:
SkBBoxRecord(uint32_t recordFlags, SkBaseDevice* device) SkBBoxRecord(uint32_t recordFlags, SkDevice* device)
: INHERITED(recordFlags, device) { } : INHERITED(recordFlags, device) { }
virtual ~SkBBoxRecord() { } virtual ~SkBBoxRecord() { }

Просмотреть файл

@ -129,7 +129,7 @@ void SkCanvas::predrawNotify() {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/* This is the record we keep for each SkBaseDevice that the user installs. /* This is the record we keep for each SkDevice that the user installs.
The clip/matrix/proc are fields that reflect the top of the save/restore The clip/matrix/proc are fields that reflect the top of the save/restore
stack. Whenever the canvas changes, it marks a dirty flag, and then before stack. Whenever the canvas changes, it marks a dirty flag, and then before
these are used (assuming we're not on a layer) we rebuild these cache these are used (assuming we're not on a layer) we rebuild these cache
@ -138,12 +138,12 @@ void SkCanvas::predrawNotify() {
*/ */
struct DeviceCM { struct DeviceCM {
DeviceCM* fNext; DeviceCM* fNext;
SkBaseDevice* fDevice; SkDevice* fDevice;
SkRasterClip fClip; SkRasterClip fClip;
const SkMatrix* fMatrix; const SkMatrix* fMatrix;
SkPaint* fPaint; // may be null (in the future) SkPaint* fPaint; // may be null (in the future)
DeviceCM(SkBaseDevice* device, int x, int y, const SkPaint* paint, SkCanvas* canvas) DeviceCM(SkDevice* device, int x, int y, const SkPaint* paint, SkCanvas* canvas)
: fNext(NULL) { : fNext(NULL) {
if (NULL != device) { if (NULL != device) {
device->ref(); device->ref();
@ -315,7 +315,7 @@ public:
return false; return false;
} }
SkBaseDevice* getDevice() const { return fDevice; } SkDevice* getDevice() const { return fDevice; }
int getX() const { return fDevice->getOrigin().x(); } int getX() const { return fDevice->getOrigin().x(); }
int getY() const { return fDevice->getOrigin().y(); } int getY() const { return fDevice->getOrigin().y(); }
const SkMatrix& getMatrix() const { return *fMatrix; } const SkMatrix& getMatrix() const { return *fMatrix; }
@ -482,7 +482,7 @@ private:
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
SkBaseDevice* SkCanvas::init(SkBaseDevice* device) { SkDevice* SkCanvas::init(SkDevice* device) {
fBounder = NULL; fBounder = NULL;
fLocalBoundsCompareType.setEmpty(); fLocalBoundsCompareType.setEmpty();
fLocalBoundsCompareTypeDirty = true; fLocalBoundsCompareTypeDirty = true;
@ -511,7 +511,7 @@ SkCanvas::SkCanvas()
this->init(NULL); this->init(NULL);
} }
SkCanvas::SkCanvas(SkBaseDevice* device) SkCanvas::SkCanvas(SkDevice* device)
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) { : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) {
inc_canvas(); inc_canvas();
@ -522,7 +522,7 @@ SkCanvas::SkCanvas(const SkBitmap& bitmap)
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) { : fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage)) {
inc_canvas(); inc_canvas();
this->init(SkNEW_ARGS(SkBitmapDevice, (bitmap)))->unref(); this->init(SkNEW_ARGS(SkDevice, (bitmap)))->unref();
} }
SkCanvas::~SkCanvas() { SkCanvas::~SkCanvas() {
@ -564,37 +564,37 @@ SkMetaData& SkCanvas::getMetaData() {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void SkCanvas::flush() { void SkCanvas::flush() {
SkBaseDevice* device = this->getDevice(); SkDevice* device = this->getDevice();
if (device) { if (device) {
device->flush(); device->flush();
} }
} }
SkISize SkCanvas::getDeviceSize() const { SkISize SkCanvas::getDeviceSize() const {
SkBaseDevice* d = this->getDevice(); SkDevice* d = this->getDevice();
return d ? SkISize::Make(d->width(), d->height()) : SkISize::Make(0, 0); return d ? SkISize::Make(d->width(), d->height()) : SkISize::Make(0, 0);
} }
SkBaseDevice* SkCanvas::getDevice() const { SkDevice* SkCanvas::getDevice() const {
// return root device // return root device
MCRec* rec = (MCRec*) fMCStack.front(); MCRec* rec = (MCRec*) fMCStack.front();
SkASSERT(rec && rec->fLayer); SkASSERT(rec && rec->fLayer);
return rec->fLayer->fDevice; return rec->fLayer->fDevice;
} }
SkBaseDevice* SkCanvas::getTopDevice(bool updateMatrixClip) const { SkDevice* SkCanvas::getTopDevice(bool updateMatrixClip) const {
if (updateMatrixClip) { if (updateMatrixClip) {
const_cast<SkCanvas*>(this)->updateDeviceCMCache(); const_cast<SkCanvas*>(this)->updateDeviceCMCache();
} }
return fMCRec->fTopLayer->fDevice; return fMCRec->fTopLayer->fDevice;
} }
SkBaseDevice* SkCanvas::setDevice(SkBaseDevice* device) { SkDevice* SkCanvas::setDevice(SkDevice* device) {
// return root device // return root device
SkDeque::F2BIter iter(fMCStack); SkDeque::F2BIter iter(fMCStack);
MCRec* rec = (MCRec*)iter.next(); MCRec* rec = (MCRec*)iter.next();
SkASSERT(rec && rec->fLayer); SkASSERT(rec && rec->fLayer);
SkBaseDevice* rootDevice = rec->fLayer->fDevice; SkDevice* rootDevice = rec->fLayer->fDevice;
if (rootDevice == device) { if (rootDevice == device) {
return device; return device;
@ -644,7 +644,7 @@ SkBaseDevice* SkCanvas::setDevice(SkBaseDevice* device) {
bool SkCanvas::readPixels(SkBitmap* bitmap, bool SkCanvas::readPixels(SkBitmap* bitmap,
int x, int y, int x, int y,
Config8888 config8888) { Config8888 config8888) {
SkBaseDevice* device = this->getDevice(); SkDevice* device = this->getDevice();
if (!device) { if (!device) {
return false; return false;
} }
@ -652,7 +652,7 @@ bool SkCanvas::readPixels(SkBitmap* bitmap,
} }
bool SkCanvas::readPixels(const SkIRect& srcRect, SkBitmap* bitmap) { bool SkCanvas::readPixels(const SkIRect& srcRect, SkBitmap* bitmap) {
SkBaseDevice* device = this->getDevice(); SkDevice* device = this->getDevice();
if (!device) { if (!device) {
return false; return false;
} }
@ -676,7 +676,7 @@ bool SkCanvas::readPixels(const SkIRect& srcRect, SkBitmap* bitmap) {
void SkCanvas::writePixels(const SkBitmap& bitmap, int x, int y, void SkCanvas::writePixels(const SkBitmap& bitmap, int x, int y,
Config8888 config8888) { Config8888 config8888) {
SkBaseDevice* device = this->getDevice(); SkDevice* device = this->getDevice();
if (device) { if (device) {
if (SkIRect::Intersects(SkIRect::MakeSize(this->getDeviceSize()), if (SkIRect::Intersects(SkIRect::MakeSize(this->getDeviceSize()),
SkIRect::MakeXYWH(x, y, bitmap.width(), bitmap.height()))) { SkIRect::MakeXYWH(x, y, bitmap.width(), bitmap.height()))) {
@ -748,7 +748,7 @@ static SkBitmap::Config resolve_config(SkCanvas* canvas,
uint32_t configMask = 0; uint32_t configMask = 0;
for (int i = canvas->countLayerDevices() - 1; i >= 0; --i) for (int i = canvas->countLayerDevices() - 1; i >= 0; --i)
{ {
SkBaseDevice* device = canvas->getLayerDevice(i); SkDevice* device = canvas->getLayerDevice(i);
if (device->intersects(bounds)) if (device->intersects(bounds))
configMask |= 1 << device->config(); configMask |= 1 << device->config();
} }
@ -849,7 +849,7 @@ int SkCanvas::internalSaveLayer(const SkRect* bounds, const SkPaint* paint,
bool isOpaque; bool isOpaque;
SkBitmap::Config config = resolve_config(this, ir, flags, &isOpaque); SkBitmap::Config config = resolve_config(this, ir, flags, &isOpaque);
SkBaseDevice* device; SkDevice* device;
if (paint && paint->getImageFilter()) { if (paint && paint->getImageFilter()) {
device = this->createCompatibleDevice(config, ir.width(), ir.height(), device = this->createCompatibleDevice(config, ir.width(), ir.height(),
isOpaque); isOpaque);
@ -981,7 +981,7 @@ void SkCanvas::internalDrawBitmap(const SkBitmap& bitmap,
LOOPER_END LOOPER_END
} }
void SkCanvas::internalDrawDevice(SkBaseDevice* srcDev, int x, int y, void SkCanvas::internalDrawDevice(SkDevice* srcDev, int x, int y,
const SkPaint* paint) { const SkPaint* paint) {
SkPaint tmp; SkPaint tmp;
if (NULL == paint) { if (NULL == paint) {
@ -991,7 +991,7 @@ void SkCanvas::internalDrawDevice(SkBaseDevice* srcDev, int x, int y,
LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type) LOOPER_BEGIN_DRAWDEVICE(*paint, SkDrawFilter::kBitmap_Type)
while (iter.next()) { while (iter.next()) {
SkBaseDevice* dstDev = iter.fDevice; SkDevice* dstDev = iter.fDevice;
paint = &looper.paint(); paint = &looper.paint();
SkImageFilter* filter = paint->getImageFilter(); SkImageFilter* filter = paint->getImageFilter();
SkIPoint pos = { x - iter.getX(), y - iter.getY() }; SkIPoint pos = { x - iter.getX(), y - iter.getY() };
@ -1164,7 +1164,7 @@ static bool clipPathHelper(const SkCanvas* canvas, SkRasterClip* currClip,
return currClip->op(clip, op); return currClip->op(clip, op);
} }
} else { } else {
const SkBaseDevice* device = canvas->getDevice(); const SkDevice* device = canvas->getDevice();
if (!device) { if (!device) {
return currClip->setEmpty(); return currClip->setEmpty();
} }
@ -1358,7 +1358,7 @@ bool SkCanvas::clipRegion(const SkRegion& rgn, SkRegion::Op op) {
#ifdef SK_DEBUG #ifdef SK_DEBUG
void SkCanvas::validateClip() const { void SkCanvas::validateClip() const {
// construct clipRgn from the clipstack // construct clipRgn from the clipstack
const SkBaseDevice* device = this->getDevice(); const SkDevice* device = this->getDevice();
if (!device) { if (!device) {
SkASSERT(this->getTotalClip().isEmpty()); SkASSERT(this->getTotalClip().isEmpty());
return; return;
@ -1543,10 +1543,10 @@ const SkRegion& SkCanvas::getTotalClip() const {
return fMCRec->fRasterClip->forceGetBW(); return fMCRec->fRasterClip->forceGetBW();
} }
SkBaseDevice* SkCanvas::createLayerDevice(SkBitmap::Config config, SkDevice* SkCanvas::createLayerDevice(SkBitmap::Config config,
int width, int height, int width, int height,
bool isOpaque) { bool isOpaque) {
SkBaseDevice* device = this->getTopDevice(); SkDevice* device = this->getTopDevice();
if (device) { if (device) {
return device->createCompatibleDeviceForSaveLayer(config, width, height, return device->createCompatibleDeviceForSaveLayer(config, width, height,
isOpaque); isOpaque);
@ -1555,10 +1555,10 @@ SkBaseDevice* SkCanvas::createLayerDevice(SkBitmap::Config config,
} }
} }
SkBaseDevice* SkCanvas::createCompatibleDevice(SkBitmap::Config config, SkDevice* SkCanvas::createCompatibleDevice(SkBitmap::Config config,
int width, int height, int width, int height,
bool isOpaque) { bool isOpaque) {
SkBaseDevice* device = this->getDevice(); SkDevice* device = this->getDevice();
if (device) { if (device) {
return device->createCompatibleDevice(config, width, height, isOpaque); return device->createCompatibleDevice(config, width, height, isOpaque);
} else { } else {
@ -1874,8 +1874,8 @@ void SkCanvas::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
class SkDeviceFilteredPaint { class SkDeviceFilteredPaint {
public: public:
SkDeviceFilteredPaint(SkBaseDevice* device, const SkPaint& paint) { SkDeviceFilteredPaint(SkDevice* device, const SkPaint& paint) {
SkBaseDevice::TextFlags flags; SkDevice::TextFlags flags;
if (device->filterTextFlags(paint, &flags)) { if (device->filterTextFlags(paint, &flags)) {
SkPaint* newPaint = fLazy.set(paint); SkPaint* newPaint = fLazy.set(paint);
newPaint->setFlags(flags.fFlags); newPaint->setFlags(flags.fFlags);
@ -2203,7 +2203,7 @@ void SkCanvas::LayerIter::next() {
fDone = !fImpl->next(); fDone = !fImpl->next();
} }
SkBaseDevice* SkCanvas::LayerIter::device() const { SkDevice* SkCanvas::LayerIter::device() const {
return fImpl->getDevice(); return fImpl->getDevice();
} }

Просмотреть файл

@ -15,8 +15,7 @@
#include "SkRRect.h" #include "SkRRect.h"
#include "SkShader.h" #include "SkShader.h"
SK_DEFINE_INST_COUNT(SkBaseDevice) SK_DEFINE_INST_COUNT(SkDevice)
SK_DEFINE_INST_COUNT(SkBitmapDevice)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -25,13 +24,20 @@ SK_DEFINE_INST_COUNT(SkBitmapDevice)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap) SkDevice::SkDevice(const SkBitmap& bitmap)
: fBitmap(bitmap) { : fBitmap(bitmap), fLeakyProperties(SkDeviceProperties::MakeDefault())
#ifdef SK_DEBUG
, fAttachedToCanvas(false)
#endif
{
fOrigin.setZero();
fMetaData = NULL;
SkASSERT(SkBitmap::kARGB_4444_Config != bitmap.config()); SkASSERT(SkBitmap::kARGB_4444_Config != bitmap.config());
} }
SkBaseDevice::SkBaseDevice() SkDevice::SkDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties)
: fLeakyProperties(SkDeviceProperties::MakeDefault()) : fBitmap(bitmap), fLeakyProperties(deviceProperties)
#ifdef SK_DEBUG #ifdef SK_DEBUG
, fAttachedToCanvas(false) , fAttachedToCanvas(false)
#endif #endif
@ -40,12 +46,25 @@ SkBaseDevice::SkBaseDevice()
fMetaData = NULL; fMetaData = NULL;
} }
SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkDeviceProperties& deviceProperties) SkDevice::SkDevice(SkBitmap::Config config, int width, int height, bool isOpaque)
: SkBaseDevice(deviceProperties) : fLeakyProperties(SkDeviceProperties::MakeDefault())
, fBitmap(bitmap) { #ifdef SK_DEBUG
, fAttachedToCanvas(false)
#endif
{
fOrigin.setZero();
fMetaData = NULL;
fBitmap.setConfig(config, width, height);
fBitmap.allocPixels();
fBitmap.setIsOpaque(isOpaque);
if (!isOpaque) {
fBitmap.eraseColor(SK_ColorTRANSPARENT);
}
} }
SkBaseDevice::SkBaseDevice(const SkDeviceProperties& deviceProperties) SkDevice::SkDevice(SkBitmap::Config config, int width, int height, bool isOpaque,
const SkDeviceProperties& deviceProperties)
: fLeakyProperties(deviceProperties) : fLeakyProperties(deviceProperties)
#ifdef SK_DEBUG #ifdef SK_DEBUG
, fAttachedToCanvas(false) , fAttachedToCanvas(false)
@ -53,20 +72,6 @@ SkBaseDevice::SkBaseDevice(const SkDeviceProperties& deviceProperties)
{ {
fOrigin.setZero(); fOrigin.setZero();
fMetaData = NULL; fMetaData = NULL;
}
SkBitmapDevice::SkBitmapDevice(SkBitmap::Config config, int width, int height, bool isOpaque) {
fBitmap.setConfig(config, width, height);
fBitmap.allocPixels();
fBitmap.setIsOpaque(isOpaque);
if (!isOpaque) {
fBitmap.eraseColor(SK_ColorTRANSPARENT);
}
}
SkBitmapDevice::SkBitmapDevice(SkBitmap::Config config, int width, int height, bool isOpaque,
const SkDeviceProperties& deviceProperties)
: SkBaseDevice(deviceProperties) {
fBitmap.setConfig(config, width, height); fBitmap.setConfig(config, width, height);
fBitmap.allocPixels(); fBitmap.allocPixels();
@ -76,43 +81,39 @@ SkBitmapDevice::SkBitmapDevice(SkBitmap::Config config, int width, int height, b
} }
} }
SkBaseDevice::~SkBaseDevice() { SkDevice::~SkDevice() {
delete fMetaData; delete fMetaData;
} }
SkBitmapDevice::~SkBitmapDevice() { void SkDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) {
}
void SkBitmapDevice::replaceBitmapBackendForRasterSurface(const SkBitmap& bm) {
SkASSERT(bm.width() == fBitmap.width()); SkASSERT(bm.width() == fBitmap.width());
SkASSERT(bm.height() == fBitmap.height()); SkASSERT(bm.height() == fBitmap.height());
fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config) fBitmap = bm; // intent is to use bm's pixelRef (and rowbytes/config)
fBitmap.lockPixels(); fBitmap.lockPixels();
} }
SkBaseDevice* SkBaseDevice::createCompatibleDevice(SkBitmap::Config config, SkDevice* SkDevice::createCompatibleDevice(SkBitmap::Config config,
int width, int height, int width, int height,
bool isOpaque) { bool isOpaque) {
return this->onCreateCompatibleDevice(config, width, height, return this->onCreateCompatibleDevice(config, width, height,
isOpaque, kGeneral_Usage); isOpaque, kGeneral_Usage);
} }
SkBaseDevice* SkBaseDevice::createCompatibleDeviceForSaveLayer(SkBitmap::Config config, SkDevice* SkDevice::createCompatibleDeviceForSaveLayer(SkBitmap::Config config,
int width, int height, int width, int height,
bool isOpaque) { bool isOpaque) {
return this->onCreateCompatibleDevice(config, width, height, return this->onCreateCompatibleDevice(config, width, height,
isOpaque, kSaveLayer_Usage); isOpaque, kSaveLayer_Usage);
} }
SkBaseDevice* SkBitmapDevice::onCreateCompatibleDevice(SkBitmap::Config config, SkDevice* SkDevice::onCreateCompatibleDevice(SkBitmap::Config config,
int width, int height, int width, int height,
bool isOpaque, bool isOpaque,
Usage usage) { Usage usage) {
return SkNEW_ARGS(SkBitmapDevice,(config, width, height, isOpaque, return SkNEW_ARGS(SkDevice,(config, width, height, isOpaque, fLeakyProperties));
this->getDeviceProperties()));
} }
SkMetaData& SkBaseDevice::getMetaData() { SkMetaData& SkDevice::getMetaData() {
// metadata users are rare, so we lazily allocate it. If that changes we // metadata users are rare, so we lazily allocate it. If that changes we
// can decide to just make it a field in the device (rather than a ptr) // can decide to just make it a field in the device (rather than a ptr)
if (NULL == fMetaData) { if (NULL == fMetaData) {
@ -121,60 +122,61 @@ SkMetaData& SkBaseDevice::getMetaData() {
return *fMetaData; return *fMetaData;
} }
void SkBitmapDevice::lockPixels() { void SkDevice::lockPixels() {
if (fBitmap.lockPixelsAreWritable()) { if (fBitmap.lockPixelsAreWritable()) {
fBitmap.lockPixels(); fBitmap.lockPixels();
} }
} }
void SkBitmapDevice::unlockPixels() { void SkDevice::unlockPixels() {
if (fBitmap.lockPixelsAreWritable()) { if (fBitmap.lockPixelsAreWritable()) {
fBitmap.unlockPixels(); fBitmap.unlockPixels();
} }
} }
const SkBitmap& SkBaseDevice::accessBitmap(bool changePixels) { const SkBitmap& SkDevice::accessBitmap(bool changePixels) {
const SkBitmap& bitmap = this->onAccessBitmap(); const SkBitmap& bitmap = this->onAccessBitmap(&fBitmap);
if (changePixels) { if (changePixels) {
bitmap.notifyPixelsChanged(); bitmap.notifyPixelsChanged();
} }
return bitmap; return bitmap;
} }
void SkBitmapDevice::getGlobalBounds(SkIRect* bounds) const { void SkDevice::getGlobalBounds(SkIRect* bounds) const {
if (bounds) { if (bounds) {
const SkIPoint& origin = this->getOrigin(); bounds->setXYWH(fOrigin.x(), fOrigin.y(),
bounds->setXYWH(origin.x(), origin.y(),
fBitmap.width(), fBitmap.height()); fBitmap.width(), fBitmap.height());
} }
} }
void SkBitmapDevice::clear(SkColor color) { void SkDevice::clear(SkColor color) {
fBitmap.eraseColor(color); fBitmap.eraseColor(color);
} }
const SkBitmap& SkBitmapDevice::onAccessBitmap() { const SkBitmap& SkDevice::onAccessBitmap(SkBitmap* bitmap) {return *bitmap;}
return fBitmap;
void SkDevice::setMatrixClip(const SkMatrix& matrix, const SkRegion& region,
const SkClipStack& clipStack) {
} }
bool SkBitmapDevice::canHandleImageFilter(SkImageFilter*) { bool SkDevice::canHandleImageFilter(SkImageFilter*) {
return false; return false;
} }
bool SkBitmapDevice::filterImage(SkImageFilter* filter, const SkBitmap& src, bool SkDevice::filterImage(SkImageFilter* filter, const SkBitmap& src,
const SkMatrix& ctm, SkBitmap* result, const SkMatrix& ctm, SkBitmap* result,
SkIPoint* offset) { SkIPoint* offset) {
return false; return false;
} }
bool SkBitmapDevice::allowImageFilter(SkImageFilter*) { bool SkDevice::allowImageFilter(SkImageFilter*) {
return true; return true;
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
bool SkBaseDevice::readPixels(SkBitmap* bitmap, int x, int y, bool SkDevice::readPixels(SkBitmap* bitmap, int x, int y,
SkCanvas::Config8888 config8888) { SkCanvas::Config8888 config8888) {
if (SkBitmap::kARGB_8888_Config != bitmap->config() || if (SkBitmap::kARGB_8888_Config != bitmap->config() ||
NULL != bitmap->getTexture()) { NULL != bitmap->getTexture()) {
return false; return false;
@ -218,21 +220,21 @@ bool SkBaseDevice::readPixels(SkBitmap* bitmap, int x, int y,
} }
#if SK_PMCOLOR_BYTE_ORDER(B,G,R,A) #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A)
const SkCanvas::Config8888 SkBaseDevice::kPMColorAlias = const SkCanvas::Config8888 SkDevice::kPMColorAlias =
SkCanvas::kBGRA_Premul_Config8888; SkCanvas::kBGRA_Premul_Config8888;
#elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A)
const SkCanvas::Config8888 SkBaseDevice::kPMColorAlias = const SkCanvas::Config8888 SkDevice::kPMColorAlias =
SkCanvas::kRGBA_Premul_Config8888; SkCanvas::kRGBA_Premul_Config8888;
#else #else
const SkCanvas::Config8888 SkBaseDevice::kPMColorAlias = const SkCanvas::Config8888 SkDevice::kPMColorAlias =
(SkCanvas::Config8888) -1; (SkCanvas::Config8888) -1;
#endif #endif
#include <SkConfig8888.h> #include <SkConfig8888.h>
bool SkBitmapDevice::onReadPixels(const SkBitmap& bitmap, bool SkDevice::onReadPixels(const SkBitmap& bitmap,
int x, int y, int x, int y,
SkCanvas::Config8888 config8888) { SkCanvas::Config8888 config8888) {
SkASSERT(SkBitmap::kARGB_8888_Config == bitmap.config()); SkASSERT(SkBitmap::kARGB_8888_Config == bitmap.config());
SkASSERT(!bitmap.isNull()); SkASSERT(!bitmap.isNull());
SkASSERT(SkIRect::MakeWH(this->width(), this->height()).contains(SkIRect::MakeXYWH(x, y, bitmap.width(), bitmap.height()))); SkASSERT(SkIRect::MakeWH(this->width(), this->height()).contains(SkIRect::MakeXYWH(x, y, bitmap.width(), bitmap.height())));
@ -255,9 +257,9 @@ bool SkBitmapDevice::onReadPixels(const SkBitmap& bitmap,
return true; return true;
} }
void SkBitmapDevice::writePixels(const SkBitmap& bitmap, void SkDevice::writePixels(const SkBitmap& bitmap,
int x, int y, int x, int y,
SkCanvas::Config8888 config8888) { SkCanvas::Config8888 config8888) {
if (bitmap.isNull() || bitmap.getTexture()) { if (bitmap.isNull() || bitmap.getTexture()) {
return; return;
} }
@ -326,22 +328,22 @@ void SkBitmapDevice::writePixels(const SkBitmap& bitmap,
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
void SkBitmapDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { void SkDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
draw.drawPaint(paint); draw.drawPaint(paint);
} }
void SkBitmapDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, size_t count, void SkDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, size_t count,
const SkPoint pts[], const SkPaint& paint) { const SkPoint pts[], const SkPaint& paint) {
CHECK_FOR_NODRAW_ANNOTATION(paint); CHECK_FOR_NODRAW_ANNOTATION(paint);
draw.drawPoints(mode, count, pts, paint); draw.drawPoints(mode, count, pts, paint);
} }
void SkBitmapDevice::drawRect(const SkDraw& draw, const SkRect& r, const SkPaint& paint) { void SkDevice::drawRect(const SkDraw& draw, const SkRect& r, const SkPaint& paint) {
CHECK_FOR_NODRAW_ANNOTATION(paint); CHECK_FOR_NODRAW_ANNOTATION(paint);
draw.drawRect(r, paint); draw.drawRect(r, paint);
} }
void SkBitmapDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint& paint) { void SkDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint& paint) {
CHECK_FOR_NODRAW_ANNOTATION(paint); CHECK_FOR_NODRAW_ANNOTATION(paint);
SkPath path; SkPath path;
@ -351,7 +353,7 @@ void SkBitmapDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPa
this->drawPath(draw, path, paint, NULL, true); this->drawPath(draw, path, paint, NULL, true);
} }
void SkBitmapDevice::drawRRect(const SkDraw& draw, const SkRRect& rrect, const SkPaint& paint) { void SkDevice::drawRRect(const SkDraw& draw, const SkRRect& rrect, const SkPaint& paint) {
CHECK_FOR_NODRAW_ANNOTATION(paint); CHECK_FOR_NODRAW_ANNOTATION(paint);
SkPath path; SkPath path;
@ -361,22 +363,22 @@ void SkBitmapDevice::drawRRect(const SkDraw& draw, const SkRRect& rrect, const S
this->drawPath(draw, path, paint, NULL, true); this->drawPath(draw, path, paint, NULL, true);
} }
void SkBitmapDevice::drawPath(const SkDraw& draw, const SkPath& path, void SkDevice::drawPath(const SkDraw& draw, const SkPath& path,
const SkPaint& paint, const SkMatrix* prePathMatrix, const SkPaint& paint, const SkMatrix* prePathMatrix,
bool pathIsMutable) { bool pathIsMutable) {
CHECK_FOR_NODRAW_ANNOTATION(paint); CHECK_FOR_NODRAW_ANNOTATION(paint);
draw.drawPath(path, paint, prePathMatrix, pathIsMutable); draw.drawPath(path, paint, prePathMatrix, pathIsMutable);
} }
void SkBitmapDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, void SkDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap,
const SkMatrix& matrix, const SkPaint& paint) { const SkMatrix& matrix, const SkPaint& paint) {
draw.drawBitmap(bitmap, matrix, paint); draw.drawBitmap(bitmap, matrix, paint);
} }
void SkBitmapDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, void SkDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
const SkRect* src, const SkRect& dst, const SkRect* src, const SkRect& dst,
const SkPaint& paint, const SkPaint& paint,
SkCanvas::DrawBitmapRectFlags flags) { SkCanvas::DrawBitmapRectFlags flags) {
SkMatrix matrix; SkMatrix matrix;
SkRect bitmapBounds, tmpSrc, tmpDst; SkRect bitmapBounds, tmpSrc, tmpDst;
SkBitmap tmpBitmap; SkBitmap tmpBitmap;
@ -460,56 +462,56 @@ void SkBitmapDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
this->drawRect(draw, *dstPtr, paintWithShader); this->drawRect(draw, *dstPtr, paintWithShader);
} }
void SkBitmapDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, void SkDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
int x, int y, const SkPaint& paint) { int x, int y, const SkPaint& paint) {
draw.drawSprite(bitmap, x, y, paint); draw.drawSprite(bitmap, x, y, paint);
} }
void SkBitmapDevice::drawText(const SkDraw& draw, const void* text, size_t len, void SkDevice::drawText(const SkDraw& draw, const void* text, size_t len,
SkScalar x, SkScalar y, const SkPaint& paint) { SkScalar x, SkScalar y, const SkPaint& paint) {
draw.drawText((const char*)text, len, x, y, paint); draw.drawText((const char*)text, len, x, y, paint);
} }
void SkBitmapDevice::drawPosText(const SkDraw& draw, const void* text, size_t len, void SkDevice::drawPosText(const SkDraw& draw, const void* text, size_t len,
const SkScalar xpos[], SkScalar y, const SkScalar xpos[], SkScalar y,
int scalarsPerPos, const SkPaint& paint) { int scalarsPerPos, const SkPaint& paint) {
draw.drawPosText((const char*)text, len, xpos, y, scalarsPerPos, paint); draw.drawPosText((const char*)text, len, xpos, y, scalarsPerPos, paint);
} }
void SkBitmapDevice::drawTextOnPath(const SkDraw& draw, const void* text, void SkDevice::drawTextOnPath(const SkDraw& draw, const void* text,
size_t len, const SkPath& path, size_t len, const SkPath& path,
const SkMatrix* matrix, const SkMatrix* matrix,
const SkPaint& paint) { const SkPaint& paint) {
draw.drawTextOnPath((const char*)text, len, path, matrix, paint); draw.drawTextOnPath((const char*)text, len, path, matrix, paint);
} }
#ifdef SK_BUILD_FOR_ANDROID #ifdef SK_BUILD_FOR_ANDROID
void SkBitmapDevice::drawPosTextOnPath(const SkDraw& draw, const void* text, size_t len, void SkDevice::drawPosTextOnPath(const SkDraw& draw, const void* text, size_t len,
const SkPoint pos[], const SkPaint& paint, const SkPoint pos[], const SkPaint& paint,
const SkPath& path, const SkMatrix* matrix) { const SkPath& path, const SkMatrix* matrix) {
draw.drawPosTextOnPath((const char*)text, len, pos, paint, path, matrix); draw.drawPosTextOnPath((const char*)text, len, pos, paint, path, matrix);
} }
#endif #endif
void SkBitmapDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, void SkDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode,
int vertexCount, int vertexCount,
const SkPoint verts[], const SkPoint textures[], const SkPoint verts[], const SkPoint textures[],
const SkColor colors[], SkXfermode* xmode, const SkColor colors[], SkXfermode* xmode,
const uint16_t indices[], int indexCount, const uint16_t indices[], int indexCount,
const SkPaint& paint) { const SkPaint& paint) {
draw.drawVertices(vmode, vertexCount, verts, textures, colors, xmode, draw.drawVertices(vmode, vertexCount, verts, textures, colors, xmode,
indices, indexCount, paint); indices, indexCount, paint);
} }
void SkBitmapDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, void SkDevice::drawDevice(const SkDraw& draw, SkDevice* device,
int x, int y, const SkPaint& paint) { int x, int y, const SkPaint& paint) {
const SkBitmap& src = device->accessBitmap(false); const SkBitmap& src = device->accessBitmap(false);
draw.drawSprite(src, x, y, paint); draw.drawSprite(src, x, y, paint);
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
bool SkBitmapDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) { bool SkDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) {
if (!paint.isLCDRenderText() || !paint.isAntiAlias()) { if (!paint.isLCDRenderText() || !paint.isAntiAlias()) {
// we're cool with the paint as is // we're cool with the paint as is
return false; return false;

Просмотреть файл

@ -12,9 +12,9 @@
class SkDeviceImageFilterProxy : public SkImageFilter::Proxy { class SkDeviceImageFilterProxy : public SkImageFilter::Proxy {
public: public:
SkDeviceImageFilterProxy(SkBaseDevice* device) : fDevice(device) {} SkDeviceImageFilterProxy(SkDevice* device) : fDevice(device) {}
virtual SkBaseDevice* createDevice(int w, int h) SK_OVERRIDE { virtual SkDevice* createDevice(int w, int h) SK_OVERRIDE {
return fDevice->createCompatibleDevice(SkBitmap::kARGB_8888_Config, return fDevice->createCompatibleDevice(SkBitmap::kARGB_8888_Config,
w, h, false); w, h, false);
} }
@ -28,7 +28,7 @@ public:
} }
private: private:
SkBaseDevice* fDevice; SkDevice* fDevice;
}; };
#endif #endif

Просмотреть файл

@ -205,7 +205,7 @@ SkCanvas* SkPicture::beginRecording(int width, int height,
SkBitmap bm; SkBitmap bm;
bm.setConfig(SkBitmap::kNo_Config, width, height); bm.setConfig(SkBitmap::kNo_Config, width, height);
SkAutoTUnref<SkBaseDevice> dev(SkNEW_ARGS(SkBitmapDevice, (bm))); SkAutoTUnref<SkDevice> dev(SkNEW_ARGS(SkDevice, (bm)));
// Must be set before calling createBBoxHierarchy // Must be set before calling createBBoxHierarchy
fWidth = width; fWidth = width;

Просмотреть файл

@ -28,7 +28,7 @@ static const uint32_t kSaveSize = 2 * kUInt32Size;
static const uint32_t kSaveLayerNoBoundsSize = 4 * kUInt32Size; static const uint32_t kSaveLayerNoBoundsSize = 4 * kUInt32Size;
static const uint32_t kSaveLayerWithBoundsSize = 4 * kUInt32Size + sizeof(SkRect); static const uint32_t kSaveLayerWithBoundsSize = 4 * kUInt32Size + sizeof(SkRect);
SkPictureRecord::SkPictureRecord(uint32_t flags, SkBaseDevice* device) : SkPictureRecord::SkPictureRecord(uint32_t flags, SkDevice* device) :
INHERITED(device), INHERITED(device),
fBoundingHierarchy(NULL), fBoundingHierarchy(NULL),
fStateTree(NULL), fStateTree(NULL),
@ -138,7 +138,7 @@ static inline uint32_t getPaintOffset(DrawType op, uint32_t opSize) {
return gPaintOffsets[op] * sizeof(uint32_t) + overflow; return gPaintOffsets[op] * sizeof(uint32_t) + overflow;
} }
SkBaseDevice* SkPictureRecord::setDevice(SkBaseDevice* device) { SkDevice* SkPictureRecord::setDevice(SkDevice* device) {
SkASSERT(!"eeek, don't try to change the device on a recording canvas"); SkASSERT(!"eeek, don't try to change the device on a recording canvas");
return this->INHERITED::setDevice(device); return this->INHERITED::setDevice(device);
} }

Просмотреть файл

@ -30,10 +30,10 @@ class SkBBoxHierarchy;
class SkPictureRecord : public SkCanvas { class SkPictureRecord : public SkCanvas {
public: public:
SkPictureRecord(uint32_t recordFlags, SkBaseDevice*); SkPictureRecord(uint32_t recordFlags, SkDevice*);
virtual ~SkPictureRecord(); virtual ~SkPictureRecord();
virtual SkBaseDevice* setDevice(SkBaseDevice* device) SK_OVERRIDE; virtual SkDevice* setDevice(SkDevice* device) SK_OVERRIDE;
virtual int save(SaveFlags) SK_OVERRIDE; virtual int save(SaveFlags) SK_OVERRIDE;
virtual int saveLayer(const SkRect* bounds, const SkPaint*, SaveFlags) SK_OVERRIDE; virtual int saveLayer(const SkRect* bounds, const SkPaint*, SaveFlags) SK_OVERRIDE;

Просмотреть файл

@ -111,7 +111,7 @@ static SkBitmap make_fake_bitmap(int width, int height) {
} }
SkXPSDevice::SkXPSDevice() SkXPSDevice::SkXPSDevice()
: SkBitmapDevice(make_fake_bitmap(10000, 10000)) : SkDevice(make_fake_bitmap(10000, 10000))
, fCurrentPage(0) { , fCurrentPage(0) {
} }
@ -2375,7 +2375,7 @@ void SkXPSDevice::drawTextOnPath(const SkDraw& d, const void* text, size_t len,
d.drawTextOnPath((const char*)text, len, path, matrix, paint); d.drawTextOnPath((const char*)text, len, path, matrix, paint);
} }
void SkXPSDevice::drawDevice(const SkDraw& d, SkBaseDevice* dev, void SkXPSDevice::drawDevice(const SkDraw& d, SkDevice* dev,
int x, int y, int x, int y,
const SkPaint&) { const SkPaint&) {
SkXPSDevice* that = static_cast<SkXPSDevice*>(dev); SkXPSDevice* that = static_cast<SkXPSDevice*>(dev);
@ -2407,11 +2407,11 @@ bool SkXPSDevice::onReadPixels(const SkBitmap& bitmap, int x, int y,
return false; return false;
} }
SkBaseDevice* SkXPSDevice::onCreateCompatibleDevice(SkBitmap::Config config, SkDevice* SkXPSDevice::onCreateCompatibleDevice(SkBitmap::Config config,
int width, int height, int width, int height,
bool isOpaque, bool isOpaque,
Usage usage) { Usage usage) {
if (SkBaseDevice::kGeneral_Usage == usage) { if (SkDevice::kGeneral_Usage == usage) {
return NULL; return NULL;
SK_CRASH(); SK_CRASH();
//To what stream do we write? //To what stream do we write?
@ -2425,7 +2425,7 @@ SkBaseDevice* SkXPSDevice::onCreateCompatibleDevice(SkBitmap::Config config,
} }
SkXPSDevice::SkXPSDevice(IXpsOMObjectFactory* xpsFactory) SkXPSDevice::SkXPSDevice(IXpsOMObjectFactory* xpsFactory)
: SkBitmapDevice(make_fake_bitmap(10000, 10000)) : SkDevice(make_fake_bitmap(10000, 10000))
, fCurrentPage(0) { , fCurrentPage(0) {
HRVM(CoCreateInstance( HRVM(CoCreateInstance(

Просмотреть файл

@ -111,7 +111,7 @@ bool SkColorFilterImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& sourc
return false; return false;
} }
SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds.height())); SkAutoTUnref<SkDevice> device(proxy->createDevice(bounds.width(), bounds.height()));
SkCanvas canvas(device.get()); SkCanvas canvas(device.get());
SkPaint paint; SkPaint paint;

Просмотреть файл

@ -46,7 +46,7 @@ bool SkDropShadowImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source
if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, loc)) if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, loc))
return false; return false;
SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(src.width(), src.height())); SkAutoTUnref<SkDevice> device(proxy->createDevice(src.width(), src.height()));
SkCanvas canvas(device.get()); SkCanvas canvas(device.get());
SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(fSigma, fSigma)); SkAutoTUnref<SkImageFilter> blurFilter(new SkBlurImageFilter(fSigma, fSigma));

Просмотреть файл

@ -109,7 +109,7 @@ bool SkMergeImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
const int x0 = bounds.left(); const int x0 = bounds.left();
const int y0 = bounds.top(); const int y0 = bounds.top();
SkAutoTUnref<SkBaseDevice> dst(proxy->createDevice(bounds.width(), bounds.height())); SkAutoTUnref<SkDevice> dst(proxy->createDevice(bounds.width(), bounds.height()));
if (NULL == dst) { if (NULL == dst) {
return false; return false;
} }

Просмотреть файл

@ -56,8 +56,8 @@ bool SkRectShaderImageFilter::onFilterImage(Proxy* proxy,
return false; return false;
} }
SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(SkScalarCeilToInt(rect.width()), SkAutoTUnref<SkDevice> device(proxy->createDevice(SkScalarCeilToInt(rect.width()),
SkScalarCeilToInt(rect.height()))); SkScalarCeilToInt(rect.height())));
SkCanvas canvas(device.get()); SkCanvas canvas(device.get());
SkPaint paint; SkPaint paint;
paint.setShader(fShader); paint.setShader(fShader);

Просмотреть файл

@ -9,11 +9,11 @@
// with the following: // with the following:
// //
// SkCanvas canvas(device); // SkCanvas canvas(device);
// SkAutoTUnref<SkBaseDevice> aur(device); // SkAutoTUnref<SkDevice> aur(device);
// //
class OwnDeviceCanvas : public SkCanvas { class OwnDeviceCanvas : public SkCanvas {
public: public:
OwnDeviceCanvas(SkBaseDevice* device) : SkCanvas(device) { OwnDeviceCanvas(SkDevice* device) : SkCanvas(device) {
SkSafeUnref(device); SkSafeUnref(device);
} }
}; };
@ -41,7 +41,7 @@ bool SkDownSampleImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
// downsample // downsample
{ {
SkBaseDevice* dev = proxy->createDevice(dstW, dstH); SkDevice* dev = proxy->createDevice(dstW, dstH);
if (NULL == dev) { if (NULL == dev) {
return false; return false;
} }
@ -56,7 +56,7 @@ bool SkDownSampleImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
// upscale // upscale
{ {
SkBaseDevice* dev = proxy->createDevice(src.width(), src.height()); SkDevice* dev = proxy->createDevice(src.width(), src.height());
if (NULL == dev) { if (NULL == dev) {
return false; return false;
} }

Просмотреть файл

@ -161,12 +161,12 @@ SkGpuDevice* SkGpuDevice::Create(GrSurface* surface) {
} }
SkGpuDevice::SkGpuDevice(GrContext* context, GrTexture* texture) SkGpuDevice::SkGpuDevice(GrContext* context, GrTexture* texture)
: SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { : SkDevice(make_bitmap(context, texture->asRenderTarget())) {
this->initFromRenderTarget(context, texture->asRenderTarget(), false); this->initFromRenderTarget(context, texture->asRenderTarget(), false);
} }
SkGpuDevice::SkGpuDevice(GrContext* context, GrRenderTarget* renderTarget) SkGpuDevice::SkGpuDevice(GrContext* context, GrRenderTarget* renderTarget)
: SkBitmapDevice(make_bitmap(context, renderTarget)) { : SkDevice(make_bitmap(context, renderTarget)) {
this->initFromRenderTarget(context, renderTarget, false); this->initFromRenderTarget(context, renderTarget, false);
} }
@ -203,7 +203,7 @@ SkGpuDevice::SkGpuDevice(GrContext* context,
int width, int width,
int height, int height,
int sampleCount) int sampleCount)
: SkBitmapDevice(config, width, height, false /*isOpaque*/) { : SkDevice(config, width, height, false /*isOpaque*/) {
fDrawProcs = NULL; fDrawProcs = NULL;
@ -1436,7 +1436,7 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap,
fContext->drawRectToRect(grPaint, dstRect, paintRect, &m); fContext->drawRectToRect(grPaint, dstRect, paintRect, &m);
} }
static bool filter_texture(SkBaseDevice* device, GrContext* context, static bool filter_texture(SkDevice* device, GrContext* context,
GrTexture* texture, SkImageFilter* filter, GrTexture* texture, SkImageFilter* filter,
int w, int h, const SkMatrix& ctm, SkBitmap* result, int w, int h, const SkMatrix& ctm, SkBitmap* result,
SkIPoint* offset) { SkIPoint* offset) {
@ -1535,7 +1535,7 @@ void SkGpuDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap,
this->drawBitmapCommon(draw, bitmap, &tmpSrc, matrix, paint, flags); this->drawBitmapCommon(draw, bitmap, &tmpSrc, matrix, paint, flags);
} }
void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, void SkGpuDevice::drawDevice(const SkDraw& draw, SkDevice* device,
int x, int y, const SkPaint& paint) { int x, int y, const SkPaint& paint) {
// clear of the source device must occur before CHECK_SHOULD_DRAW // clear of the source device must occur before CHECK_SHOULD_DRAW
SkGpuDevice* dev = static_cast<SkGpuDevice*>(device); SkGpuDevice* dev = static_cast<SkGpuDevice*>(device);
@ -1818,10 +1818,10 @@ void SkGpuDevice::flush() {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
SkBaseDevice* SkGpuDevice::onCreateCompatibleDevice(SkBitmap::Config config, SkDevice* SkGpuDevice::onCreateCompatibleDevice(SkBitmap::Config config,
int width, int height, int width, int height,
bool isOpaque, bool isOpaque,
Usage usage) { Usage usage) {
GrTextureDesc desc; GrTextureDesc desc;
desc.fConfig = fRenderTarget->config(); desc.fConfig = fRenderTarget->config();
desc.fFlags = kRenderTarget_GrTextureFlagBit; desc.fFlags = kRenderTarget_GrTextureFlagBit;
@ -1854,7 +1854,7 @@ SkBaseDevice* SkGpuDevice::onCreateCompatibleDevice(SkBitmap::Config config,
SkGpuDevice::SkGpuDevice(GrContext* context, SkGpuDevice::SkGpuDevice(GrContext* context,
GrTexture* texture, GrTexture* texture,
bool needClear) bool needClear)
: SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { : SkDevice(make_bitmap(context, texture->asRenderTarget())) {
SkASSERT(texture && texture->asRenderTarget()); SkASSERT(texture && texture->asRenderTarget());
// This constructor is called from onCreateCompatibleDevice. It has locked the RT in the texture // This constructor is called from onCreateCompatibleDevice. It has locked the RT in the texture

Просмотреть файл

@ -566,10 +566,10 @@ void GraphicStackState::updateDrawingState(const GraphicStateEntry& state) {
} }
} }
SkBaseDevice* SkPDFDevice::onCreateCompatibleDevice(SkBitmap::Config config, SkDevice* SkPDFDevice::onCreateCompatibleDevice(SkBitmap::Config config,
int width, int height, int width, int height,
bool isOpaque, bool isOpaque,
Usage usage) { Usage usage) {
SkMatrix initialTransform; SkMatrix initialTransform;
initialTransform.reset(); initialTransform.reset();
SkISize size = SkISize::Make(width, height); SkISize size = SkISize::Make(width, height);
@ -672,7 +672,7 @@ static inline SkBitmap makeContentBitmap(const SkISize& contentSize,
// TODO(vandebo) change pageSize to SkSize. // TODO(vandebo) change pageSize to SkSize.
SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize, SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize,
const SkMatrix& initialTransform) const SkMatrix& initialTransform)
: SkBitmapDevice(makeContentBitmap(contentSize, &initialTransform)), : SkDevice(makeContentBitmap(contentSize, &initialTransform)),
fPageSize(pageSize), fPageSize(pageSize),
fContentSize(contentSize), fContentSize(contentSize),
fLastContentEntry(NULL), fLastContentEntry(NULL),
@ -696,7 +696,7 @@ SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize,
SkPDFDevice::SkPDFDevice(const SkISize& layerSize, SkPDFDevice::SkPDFDevice(const SkISize& layerSize,
const SkClipStack& existingClipStack, const SkClipStack& existingClipStack,
const SkRegion& existingClipRegion) const SkRegion& existingClipRegion)
: SkBitmapDevice(makeContentBitmap(layerSize, NULL)), : SkDevice(makeContentBitmap(layerSize, NULL)),
fPageSize(layerSize), fPageSize(layerSize),
fContentSize(layerSize), fContentSize(layerSize),
fExistingClipStack(existingClipStack), fExistingClipStack(existingClipStack),
@ -1153,11 +1153,11 @@ void SkPDFDevice::drawVertices(const SkDraw& d, SkCanvas::VertexMode,
NOT_IMPLEMENTED("drawVerticies", true); NOT_IMPLEMENTED("drawVerticies", true);
} }
void SkPDFDevice::drawDevice(const SkDraw& d, SkBaseDevice* device, int x, int y, void SkPDFDevice::drawDevice(const SkDraw& d, SkDevice* device, int x, int y,
const SkPaint& paint) { const SkPaint& paint) {
if ((device->getDeviceCapabilities() & kVector_Capability) == 0) { if ((device->getDeviceCapabilities() & kVector_Capability) == 0) {
// If we somehow get a raster device, do what our parent would do. // If we somehow get a raster device, do what our parent would do.
INHERITED::drawDevice(d, device, x, y, paint); SkDevice::drawDevice(d, device, x, y, paint);
return; return;
} }

Просмотреть файл

@ -432,7 +432,7 @@ SkGPipeCanvas::SkGPipeCanvas(SkGPipeController* controller,
// We don't allocate pixels for the bitmap // We don't allocate pixels for the bitmap
SkBitmap bitmap; SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
SkBaseDevice* device = SkNEW_ARGS(SkBitmapDevice, (bitmap)); SkDevice* device = SkNEW_ARGS(SkDevice, (bitmap));
this->setDevice(device)->unref(); this->setDevice(device)->unref();
// Tell the reader the appropriate flags to use. // Tell the reader the appropriate flags to use.

Просмотреть файл

@ -55,7 +55,7 @@ TiledPipeController::TiledPipeController(const SkBitmap& bitmap,
SkDEBUGCODE(bool extracted = )bitmap.extractSubset(&fBitmaps[i], rect); SkDEBUGCODE(bool extracted = )bitmap.extractSubset(&fBitmaps[i], rect);
SkASSERT(extracted); SkASSERT(extracted);
SkBaseDevice* device = new SkBitmapDevice(fBitmaps[i]); SkDevice* device = new SkDevice(fBitmaps[i]);
SkCanvas* canvas = new SkCanvas(device); SkCanvas* canvas = new SkCanvas(device);
device->unref(); device->unref();
if (initial != NULL) { if (initial != NULL) {

Просмотреть файл

@ -137,16 +137,16 @@ void DeferredPipeController::playback(bool silent) {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// DeferredDevice // DeferredDevice
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class DeferredDevice : public SkBitmapDevice { class DeferredDevice : public SkDevice {
public: public:
explicit DeferredDevice(SkBaseDevice* immediateDevice); explicit DeferredDevice(SkDevice* immediateDevice);
explicit DeferredDevice(SkSurface* surface); explicit DeferredDevice(SkSurface* surface);
~DeferredDevice(); ~DeferredDevice();
void setNotificationClient(SkDeferredCanvas::NotificationClient* notificationClient); void setNotificationClient(SkDeferredCanvas::NotificationClient* notificationClient);
SkCanvas* recordingCanvas(); SkCanvas* recordingCanvas();
SkCanvas* immediateCanvas() const {return fImmediateCanvas;} SkCanvas* immediateCanvas() const {return fImmediateCanvas;}
SkBaseDevice* immediateDevice() const {return fImmediateCanvas->getTopDevice();} SkDevice* immediateDevice() const {return fImmediateCanvas->getTopDevice();}
SkImage* newImageSnapshot(); SkImage* newImageSnapshot();
void setSurface(SkSurface* surface); void setSurface(SkSurface* surface);
bool isFreshFrame(); bool isFreshFrame();
@ -165,24 +165,24 @@ public:
virtual int height() const SK_OVERRIDE; virtual int height() const SK_OVERRIDE;
virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE; virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE;
virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config, virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config config,
int width, int height, int width, int height,
bool isOpaque, bool isOpaque,
Usage usage) SK_OVERRIDE; Usage usage) SK_OVERRIDE;
virtual void writePixels(const SkBitmap& bitmap, int x, int y, virtual void writePixels(const SkBitmap& bitmap, int x, int y,
SkCanvas::Config8888 config8888) SK_OVERRIDE; SkCanvas::Config8888 config8888) SK_OVERRIDE;
protected: protected:
virtual const SkBitmap& onAccessBitmap() SK_OVERRIDE; virtual const SkBitmap& onAccessBitmap(SkBitmap*) SK_OVERRIDE;
virtual bool onReadPixels(const SkBitmap& bitmap, virtual bool onReadPixels(const SkBitmap& bitmap,
int x, int y, int x, int y,
SkCanvas::Config8888 config8888) SK_OVERRIDE; SkCanvas::Config8888 config8888) SK_OVERRIDE;
// The following methods are no-ops on a deferred device // The following methods are no-ops on a deferred device
virtual bool filterTextFlags(const SkPaint& paint, TextFlags*) SK_OVERRIDE { virtual bool filterTextFlags(const SkPaint& paint, TextFlags*)
return false; SK_OVERRIDE
} {return false;}
// None of the following drawing methods should ever get called on the // None of the following drawing methods should ever get called on the
// deferred device // deferred device
@ -234,7 +234,7 @@ protected:
SkXfermode* xmode, const uint16_t indices[], SkXfermode* xmode, const uint16_t indices[],
int indexCount, const SkPaint& paint) SK_OVERRIDE int indexCount, const SkPaint& paint) SK_OVERRIDE
{SkASSERT(0);} {SkASSERT(0);}
virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, virtual void drawDevice(const SkDraw&, SkDevice*, int x, int y,
const SkPaint&) SK_OVERRIDE const SkPaint&) SK_OVERRIDE
{SkASSERT(0);} {SkASSERT(0);}
private: private:
@ -258,11 +258,11 @@ private:
size_t fBitmapSizeThreshold; size_t fBitmapSizeThreshold;
}; };
DeferredDevice::DeferredDevice(SkBaseDevice* immediateDevice) DeferredDevice::DeferredDevice(SkDevice* immediateDevice)
: SkBitmapDevice(SkBitmap::kNo_Config, : SkDevice(SkBitmap::kNo_Config,
immediateDevice->width(), immediateDevice->height(), immediateDevice->width(), immediateDevice->height(),
immediateDevice->isOpaque(), immediateDevice->isOpaque(),
immediateDevice->getDeviceProperties()) { immediateDevice->getDeviceProperties()) {
fSurface = NULL; fSurface = NULL;
fImmediateCanvas = SkNEW_ARGS(SkCanvas, (immediateDevice)); fImmediateCanvas = SkNEW_ARGS(SkCanvas, (immediateDevice));
fPipeController.setPlaybackCanvas(fImmediateCanvas); fPipeController.setPlaybackCanvas(fImmediateCanvas);
@ -270,11 +270,11 @@ DeferredDevice::DeferredDevice(SkBaseDevice* immediateDevice)
} }
DeferredDevice::DeferredDevice(SkSurface* surface) DeferredDevice::DeferredDevice(SkSurface* surface)
: SkBitmapDevice(SkBitmap::kNo_Config, : SkDevice(SkBitmap::kNo_Config,
surface->getCanvas()->getDevice()->width(), surface->getCanvas()->getDevice()->width(),
surface->getCanvas()->getDevice()->height(), surface->getCanvas()->getDevice()->height(),
surface->getCanvas()->getDevice()->isOpaque(), surface->getCanvas()->getDevice()->isOpaque(),
surface->getCanvas()->getDevice()->getDeviceProperties()) { surface->getCanvas()->getDevice()->getDeviceProperties()) {
fMaxRecordingStorageBytes = kDefaultMaxRecordingStorageBytes; fMaxRecordingStorageBytes = kDefaultMaxRecordingStorageBytes;
fNotificationClient = NULL; fNotificationClient = NULL;
fImmediateCanvas = NULL; fImmediateCanvas = NULL;
@ -492,12 +492,12 @@ void DeferredDevice::writePixels(const SkBitmap& bitmap,
} }
} }
const SkBitmap& DeferredDevice::onAccessBitmap() { const SkBitmap& DeferredDevice::onAccessBitmap(SkBitmap*) {
this->flushPendingCommands(kNormal_PlaybackMode); this->flushPendingCommands(kNormal_PlaybackMode);
return immediateDevice()->accessBitmap(false); return immediateDevice()->accessBitmap(false);
} }
SkBaseDevice* DeferredDevice::onCreateCompatibleDevice( SkDevice* DeferredDevice::onCreateCompatibleDevice(
SkBitmap::Config config, int width, int height, bool isOpaque, SkBitmap::Config config, int width, int height, bool isOpaque,
Usage usage) { Usage usage) {
@ -555,7 +555,7 @@ SkDeferredCanvas* SkDeferredCanvas::Create(SkSurface* surface) {
return SkNEW_ARGS(SkDeferredCanvas, (deferredDevice)); return SkNEW_ARGS(SkDeferredCanvas, (deferredDevice));
} }
SkDeferredCanvas* SkDeferredCanvas::Create(SkBaseDevice* device) { SkDeferredCanvas* SkDeferredCanvas::Create(SkDevice* device) {
SkAutoTUnref<DeferredDevice> deferredDevice(SkNEW_ARGS(DeferredDevice, (device))); SkAutoTUnref<DeferredDevice> deferredDevice(SkNEW_ARGS(DeferredDevice, (device)));
return SkNEW_ARGS(SkDeferredCanvas, (deferredDevice)); return SkNEW_ARGS(SkDeferredCanvas, (deferredDevice));
} }

Просмотреть файл

@ -47,7 +47,7 @@ static void nothing_to_do() {}
* It should never actually draw anything, so there need not be any pixels * It should never actually draw anything, so there need not be any pixels
* behind its device-bitmap. * behind its device-bitmap.
*/ */
class GatherPixelRefDevice : public SkBitmapDevice { class GatherPixelRefDevice : public SkDevice {
private: private:
PixelRefSet* fPRSet; PixelRefSet* fPRSet;
@ -70,7 +70,7 @@ private:
} }
public: public:
GatherPixelRefDevice(const SkBitmap& bm, PixelRefSet* prset) : SkBitmapDevice(bm) { GatherPixelRefDevice(const SkBitmap& bm, PixelRefSet* prset) : SkDevice(bm) {
fPRSet = prset; fPRSet = prset;
} }
@ -138,7 +138,7 @@ public:
const SkPaint& paint) SK_OVERRIDE { const SkPaint& paint) SK_OVERRIDE {
this->addBitmapFromPaint(paint); this->addBitmapFromPaint(paint);
} }
virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, virtual void drawDevice(const SkDraw&, SkDevice*, int x, int y,
const SkPaint&) SK_OVERRIDE { const SkPaint&) SK_OVERRIDE {
nothing_to_do(); nothing_to_do();
} }
@ -150,14 +150,11 @@ protected:
not_supported(); not_supported();
return false; return false;
} }
private:
typedef SkBitmapDevice INHERITED;
}; };
class NoSaveLayerCanvas : public SkCanvas { class NoSaveLayerCanvas : public SkCanvas {
public: public:
NoSaveLayerCanvas(SkBaseDevice* device) : INHERITED(device) {} NoSaveLayerCanvas(SkDevice* device) : INHERITED(device) {}
// turn saveLayer() into save() for speed, should not affect correctness. // turn saveLayer() into save() for speed, should not affect correctness.
virtual int saveLayer(const SkRect* bounds, const SkPaint* paint, virtual int saveLayer(const SkRect* bounds, const SkPaint* paint,

Просмотреть файл

@ -779,7 +779,7 @@ public:
SkBitmap deferredStore; SkBitmap deferredStore;
createBitmap(&deferredStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); createBitmap(&deferredStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
SkBitmapDevice deferredDevice(deferredStore); SkDevice deferredDevice(deferredStore);
SkAutoTUnref<SkDeferredCanvas> deferredCanvas(SkDeferredCanvas::Create(&deferredDevice)); SkAutoTUnref<SkDeferredCanvas> deferredCanvas(SkDeferredCanvas::Create(&deferredDevice));
testStep->setAssertMessageFormat(kDeferredDrawAssertMessageFormat); testStep->setAssertMessageFormat(kDeferredDrawAssertMessageFormat);
testStep->draw(deferredCanvas, reporter); testStep->draw(deferredCanvas, reporter);
@ -821,7 +821,7 @@ static void TestProxyCanvasStateConsistency(
SkBitmap indirectStore; SkBitmap indirectStore;
createBitmap(&indirectStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); createBitmap(&indirectStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
SkBitmapDevice indirectDevice(indirectStore); SkDevice indirectDevice(indirectStore);
SkCanvas indirectCanvas(&indirectDevice); SkCanvas indirectCanvas(&indirectDevice);
SkProxyCanvas proxyCanvas(&indirectCanvas); SkProxyCanvas proxyCanvas(&indirectCanvas);
testStep->setAssertMessageFormat(kProxyDrawAssertMessageFormat); testStep->setAssertMessageFormat(kProxyDrawAssertMessageFormat);
@ -844,12 +844,12 @@ static void TestNWayCanvasStateConsistency(
SkBitmap indirectStore1; SkBitmap indirectStore1;
createBitmap(&indirectStore1, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); createBitmap(&indirectStore1, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
SkBitmapDevice indirectDevice1(indirectStore1); SkDevice indirectDevice1(indirectStore1);
SkCanvas indirectCanvas1(&indirectDevice1); SkCanvas indirectCanvas1(&indirectDevice1);
SkBitmap indirectStore2; SkBitmap indirectStore2;
createBitmap(&indirectStore2, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); createBitmap(&indirectStore2, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
SkBitmapDevice indirectDevice2(indirectStore2); SkDevice indirectDevice2(indirectStore2);
SkCanvas indirectCanvas2(&indirectDevice2); SkCanvas indirectCanvas2(&indirectDevice2);
SkISize canvasSize = referenceCanvas.getDeviceSize(); SkISize canvasSize = referenceCanvas.getDeviceSize();
@ -882,7 +882,7 @@ static void TestOverrideStateConsistency(skiatest::Reporter* reporter,
CanvasTestStep* testStep) { CanvasTestStep* testStep) {
SkBitmap referenceStore; SkBitmap referenceStore;
createBitmap(&referenceStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); createBitmap(&referenceStore, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
SkBitmapDevice referenceDevice(referenceStore); SkDevice referenceDevice(referenceStore);
SkCanvas referenceCanvas(&referenceDevice); SkCanvas referenceCanvas(&referenceDevice);
testStep->setAssertMessageFormat(kCanvasDrawAssertMessageFormat); testStep->setAssertMessageFormat(kCanvasDrawAssertMessageFormat);
testStep->draw(&referenceCanvas, reporter); testStep->draw(&referenceCanvas, reporter);

Просмотреть файл

@ -33,7 +33,7 @@ static void TestDeferredCanvasBitmapAccess(skiatest::Reporter* reporter) {
SkBitmap store; SkBitmap store;
create(&store, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); create(&store, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
SkBitmapDevice device(store); SkDevice device(store);
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device)); SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->clear(0x00000000); canvas->clear(0x00000000);
@ -259,7 +259,7 @@ static void TestDeferredCanvasFlush(skiatest::Reporter* reporter) {
SkBitmap store; SkBitmap store;
create(&store, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); create(&store, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
SkBitmapDevice device(store); SkDevice device(store);
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device)); SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->clear(0x00000000); canvas->clear(0x00000000);
@ -279,7 +279,7 @@ static void TestDeferredCanvasFreshFrame(skiatest::Reporter* reporter) {
partialRect.setXYWH(SkIntToScalar(0), SkIntToScalar(0), partialRect.setXYWH(SkIntToScalar(0), SkIntToScalar(0),
SkIntToScalar(1), SkIntToScalar(1)); SkIntToScalar(1), SkIntToScalar(1));
create(&store, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF); create(&store, SkBitmap::kARGB_8888_Config, 0xFFFFFFFF);
SkBitmapDevice device(store); SkDevice device(store);
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device)); SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
// verify that frame is intially fresh // verify that frame is intially fresh
@ -433,9 +433,9 @@ static void TestDeferredCanvasFreshFrame(skiatest::Reporter* reporter) {
} }
} }
class MockDevice : public SkBitmapDevice { class MockDevice : public SkDevice {
public: public:
MockDevice(const SkBitmap& bm) : SkBitmapDevice(bm) { MockDevice(const SkBitmap& bm) : SkDevice(bm) {
fDrawBitmapCallCount = 0; fDrawBitmapCallCount = 0;
} }
virtual void drawBitmap(const SkDraw&, const SkBitmap&, virtual void drawBitmap(const SkDraw&, const SkBitmap&,
@ -502,7 +502,7 @@ static void TestDeferredCanvasBitmapCaching(skiatest::Reporter* reporter) {
SkBitmap store; SkBitmap store;
store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
store.allocPixels(); store.allocPixels();
SkBitmapDevice device(store); SkDevice device(store);
NotificationCounter notificationCounter; NotificationCounter notificationCounter;
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device)); SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->setNotificationClient(&notificationCounter); canvas->setNotificationClient(&notificationCounter);
@ -585,7 +585,7 @@ static void TestDeferredCanvasSkip(skiatest::Reporter* reporter) {
SkBitmap store; SkBitmap store;
store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
store.allocPixels(); store.allocPixels();
SkBitmapDevice device(store); SkDevice device(store);
NotificationCounter notificationCounter; NotificationCounter notificationCounter;
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device)); SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->setNotificationClient(&notificationCounter); canvas->setNotificationClient(&notificationCounter);
@ -606,7 +606,7 @@ static void TestDeferredCanvasBitmapShaderNoLeak(skiatest::Reporter* reporter) {
SkBitmap store; SkBitmap store;
store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
store.allocPixels(); store.allocPixels();
SkBitmapDevice device(store); SkDevice device(store);
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device)); SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
// test will fail if nbIterations is not in sync with // test will fail if nbIterations is not in sync with
// BITMAPS_TO_KEEP in SkGPipeWrite.cpp // BITMAPS_TO_KEEP in SkGPipeWrite.cpp
@ -652,7 +652,7 @@ static void TestDeferredCanvasBitmapSizeThreshold(skiatest::Reporter* reporter)
// 1 under : should not store the image // 1 under : should not store the image
{ {
SkBitmapDevice device(store); SkDevice device(store);
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device)); SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->setBitmapSizeThreshold(39999); canvas->setBitmapSizeThreshold(39999);
canvas->drawBitmap(sourceImage, 0, 0, NULL); canvas->drawBitmap(sourceImage, 0, 0, NULL);
@ -662,7 +662,7 @@ static void TestDeferredCanvasBitmapSizeThreshold(skiatest::Reporter* reporter)
// exact value : should store the image // exact value : should store the image
{ {
SkBitmapDevice device(store); SkDevice device(store);
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device)); SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->setBitmapSizeThreshold(40000); canvas->setBitmapSizeThreshold(40000);
canvas->drawBitmap(sourceImage, 0, 0, NULL); canvas->drawBitmap(sourceImage, 0, 0, NULL);
@ -672,7 +672,7 @@ static void TestDeferredCanvasBitmapSizeThreshold(skiatest::Reporter* reporter)
// 1 over : should still store the image // 1 over : should still store the image
{ {
SkBitmapDevice device(store); SkDevice device(store);
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device)); SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->setBitmapSizeThreshold(40001); canvas->setBitmapSizeThreshold(40001);
canvas->drawBitmap(sourceImage, 0, 0, NULL); canvas->drawBitmap(sourceImage, 0, 0, NULL);
@ -807,11 +807,11 @@ static void TestDeferredCanvasCreateCompatibleDevice(skiatest::Reporter* reporte
SkBitmap store; SkBitmap store;
store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100); store.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
store.allocPixels(); store.allocPixels();
SkBitmapDevice device(store); SkDevice device(store);
NotificationCounter notificationCounter; NotificationCounter notificationCounter;
SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device)); SkAutoTUnref<SkDeferredCanvas> canvas(SkDeferredCanvas::Create(&device));
canvas->setNotificationClient(&notificationCounter); canvas->setNotificationClient(&notificationCounter);
SkAutoTUnref<SkBaseDevice> secondaryDevice(canvas->createCompatibleDevice( SkAutoTUnref<SkDevice> secondaryDevice(canvas->createCompatibleDevice(
SkBitmap::kARGB_8888_Config, 10, 10, device.isOpaque())); SkBitmap::kARGB_8888_Config, 10, 10, device.isOpaque()));
SkCanvas secondaryCanvas(secondaryDevice.get()); SkCanvas secondaryCanvas(secondaryDevice.get());
SkRect rect = SkRect::MakeWH(5, 5); SkRect rect = SkRect::MakeWH(5, 5);

Просмотреть файл

@ -146,7 +146,7 @@ static void TestConstantGradient(skiatest::Reporter*) {
outBitmap.allocPixels(); outBitmap.allocPixels();
SkPaint paint; SkPaint paint;
paint.setShader(s.get()); paint.setShader(s.get());
SkBitmapDevice device(outBitmap); SkDevice device(outBitmap);
SkCanvas canvas(&device); SkCanvas canvas(&device);
canvas.drawPaint(paint); canvas.drawPaint(paint);
SkAutoLockPixels alp(outBitmap); SkAutoLockPixels alp(outBitmap);

Просмотреть файл

@ -19,20 +19,17 @@
namespace { namespace {
class FakeDevice : public SkBitmapDevice { class FakeDevice : public SkDevice {
public: public:
FakeDevice() : SkBitmapDevice(SkBitmap::kARGB_8888_Config, 100, 100, false) { } FakeDevice() : SkDevice(SkBitmap::kARGB_8888_Config, 100, 100) { }
virtual void drawRect(const SkDraw& draw, const SkRect& r, virtual void drawRect(const SkDraw& draw, const SkRect& r,
const SkPaint& paint) SK_OVERRIDE { const SkPaint& paint) SK_OVERRIDE {
fLastMatrix = *draw.fMatrix; fLastMatrix = *draw.fMatrix;
INHERITED::drawRect(draw, r, paint); SkDevice::drawRect(draw, r, paint);
} }
SkMatrix fLastMatrix; SkMatrix fLastMatrix;
private:
typedef SkBitmapDevice INHERITED;
}; };
} // namespace } // namespace

Просмотреть файл

@ -41,7 +41,7 @@ static const SkCanvas::Config8888 gUnpremulConfigs[] = {
}; };
void PremulAlphaRoundTripTest(skiatest::Reporter* reporter, GrContextFactory* factory) { void PremulAlphaRoundTripTest(skiatest::Reporter* reporter, GrContextFactory* factory) {
SkAutoTUnref<SkBaseDevice> device; SkAutoTUnref<SkDevice> device;
for (int dtype = 0; dtype < 2; ++dtype) { for (int dtype = 0; dtype < 2; ++dtype) {
int glCtxTypeCnt = 1; int glCtxTypeCnt = 1;
@ -52,10 +52,10 @@ void PremulAlphaRoundTripTest(skiatest::Reporter* reporter, GrContextFactory* fa
#endif #endif
for (int glCtxType = 0; glCtxType < glCtxTypeCnt; ++glCtxType) { for (int glCtxType = 0; glCtxType < glCtxTypeCnt; ++glCtxType) {
if (0 == dtype) { if (0 == dtype) {
device.reset(new SkBitmapDevice(SkBitmap::kARGB_8888_Config, device.reset(new SkDevice(SkBitmap::kARGB_8888_Config,
256, 256,
256, 256,
false)); false));
} else { } else {
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
GrContextFactory::GLContextType type = GrContextFactory::GLContextType type =

Просмотреть файл

@ -311,10 +311,9 @@ void ReadPixelsTest(skiatest::Reporter* reporter, GrContextFactory* factory) {
} }
#endif #endif
for (int glCtxType = 0; glCtxType < glCtxTypeCnt; ++glCtxType) { for (int glCtxType = 0; glCtxType < glCtxTypeCnt; ++glCtxType) {
SkAutoTUnref<SkBaseDevice> device; SkAutoTUnref<SkDevice> device;
if (0 == dtype) { if (0 == dtype) {
device.reset(new SkBitmapDevice(SkBitmap::kARGB_8888_Config, device.reset(new SkDevice(SkBitmap::kARGB_8888_Config, DEV_W, DEV_H, false));
DEV_W, DEV_H, false));
} else { } else {
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
GrContextFactory::GLContextType type = GrContextFactory::GLContextType type =

Просмотреть файл

@ -82,7 +82,7 @@ static void ReadWriteAlphaTest(skiatest::Reporter* reporter, GrContextFactory* f
REPORTER_ASSERT(reporter, match); REPORTER_ASSERT(reporter, match);
// Now try writing on the single channel texture // Now try writing on the single channel texture
SkAutoTUnref<SkBaseDevice> device(new SkGpuDevice(context, texture->asRenderTarget())); SkAutoTUnref<SkDevice> device(new SkGpuDevice(context, texture->asRenderTarget()));
SkCanvas canvas(device); SkCanvas canvas(device);
SkPaint paint; SkPaint paint;

Просмотреть файл

@ -24,7 +24,7 @@ enum Tile {
namespace { namespace {
class MockCanvas : public SkCanvas { class MockCanvas : public SkCanvas {
public: public:
MockCanvas(SkBaseDevice* device) : SkCanvas(device) MockCanvas(SkDevice* device) : SkCanvas(device)
{} {}
virtual void drawRect(const SkRect& rect, const SkPaint&) virtual void drawRect(const SkRect& rect, const SkPaint&)
@ -80,14 +80,14 @@ public:
// Test parts of top-left tile // Test parts of top-left tile
{ {
SkBitmapDevice device(store); SkDevice device(store);
MockCanvas mockCanvas(&device); MockCanvas mockCanvas(&device);
picture.draw(&mockCanvas); picture.draw(&mockCanvas);
REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count()); REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]); REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
} }
{ {
SkBitmapDevice device(store); SkDevice device(store);
MockCanvas mockCanvas(&device); MockCanvas mockCanvas(&device);
mockCanvas.translate(SkFloatToScalar(-7.99f), SkFloatToScalar(-7.99f)); mockCanvas.translate(SkFloatToScalar(-7.99f), SkFloatToScalar(-7.99f));
picture.draw(&mockCanvas); picture.draw(&mockCanvas);
@ -96,7 +96,7 @@ public:
} }
// Corner overlap // Corner overlap
{ {
SkBitmapDevice device(store); SkDevice device(store);
MockCanvas mockCanvas(&device); MockCanvas mockCanvas(&device);
mockCanvas.translate(SkFloatToScalar(-9.5f), SkFloatToScalar(-9.5f)); mockCanvas.translate(SkFloatToScalar(-9.5f), SkFloatToScalar(-9.5f));
picture.draw(&mockCanvas); picture.draw(&mockCanvas);
@ -106,7 +106,7 @@ public:
} }
// Intersect bottom right tile, but does not overlap rect 2 // Intersect bottom right tile, but does not overlap rect 2
{ {
SkBitmapDevice device(store); SkDevice device(store);
MockCanvas mockCanvas(&device); MockCanvas mockCanvas(&device);
mockCanvas.translate(SkFloatToScalar(-16.0f), SkFloatToScalar(-16.0f)); mockCanvas.translate(SkFloatToScalar(-16.0f), SkFloatToScalar(-16.0f));
picture.draw(&mockCanvas); picture.draw(&mockCanvas);
@ -115,7 +115,7 @@ public:
} }
// Out of bounds queries, snap to border tiles // Out of bounds queries, snap to border tiles
{ {
SkBitmapDevice device(store); SkDevice device(store);
MockCanvas mockCanvas(&device); MockCanvas mockCanvas(&device);
mockCanvas.translate(SkFloatToScalar(2.0f), SkFloatToScalar(0.0f)); mockCanvas.translate(SkFloatToScalar(2.0f), SkFloatToScalar(0.0f));
picture.draw(&mockCanvas); picture.draw(&mockCanvas);
@ -123,7 +123,7 @@ public:
REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]); REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
} }
{ {
SkBitmapDevice device(store); SkDevice device(store);
MockCanvas mockCanvas(&device); MockCanvas mockCanvas(&device);
mockCanvas.translate(SkFloatToScalar(0.0f), SkFloatToScalar(2.0f)); mockCanvas.translate(SkFloatToScalar(0.0f), SkFloatToScalar(2.0f));
picture.draw(&mockCanvas); picture.draw(&mockCanvas);
@ -131,7 +131,7 @@ public:
REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]); REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
} }
{ {
SkBitmapDevice device(store); SkDevice device(store);
MockCanvas mockCanvas(&device); MockCanvas mockCanvas(&device);
mockCanvas.translate(SkFloatToScalar(-22.0f), SkFloatToScalar(-16.0f)); mockCanvas.translate(SkFloatToScalar(-22.0f), SkFloatToScalar(-16.0f));
picture.draw(&mockCanvas); picture.draw(&mockCanvas);
@ -139,7 +139,7 @@ public:
REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]); REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]);
} }
{ {
SkBitmapDevice device(store); SkDevice device(store);
MockCanvas mockCanvas(&device); MockCanvas mockCanvas(&device);
mockCanvas.translate(SkFloatToScalar(-16.0f), SkFloatToScalar(-22.0f)); mockCanvas.translate(SkFloatToScalar(-16.0f), SkFloatToScalar(-22.0f));
picture.draw(&mockCanvas); picture.draw(&mockCanvas);
@ -185,7 +185,7 @@ public:
{ {
// The offset should cancel the top and left borders of the top left tile // The offset should cancel the top and left borders of the top left tile
// So a look-up at interval 0-10 should be grid aligned, // So a look-up at interval 0-10 should be grid aligned,
SkBitmapDevice device(tileBitmap); SkDevice device(tileBitmap);
MockCanvas mockCanvas(&device); MockCanvas mockCanvas(&device);
picture.draw(&mockCanvas); picture.draw(&mockCanvas);
REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count()); REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
@ -193,7 +193,7 @@ public:
} }
{ {
// Encroaching border by one pixel // Encroaching border by one pixel
SkBitmapDevice device(moreThanATileBitmap); SkDevice device(moreThanATileBitmap);
MockCanvas mockCanvas(&device); MockCanvas mockCanvas(&device);
picture.draw(&mockCanvas); picture.draw(&mockCanvas);
REPORTER_ASSERT(reporter, 2 == mockCanvas.fRects.count()); REPORTER_ASSERT(reporter, 2 == mockCanvas.fRects.count());
@ -204,7 +204,7 @@ public:
// Tile stride is 8 (tileWidth - 2 * border pixels // Tile stride is 8 (tileWidth - 2 * border pixels
// so translating by 8, should make query grid-aligned // so translating by 8, should make query grid-aligned
// with middle tile. // with middle tile.
SkBitmapDevice device(tileBitmap); SkDevice device(tileBitmap);
MockCanvas mockCanvas(&device); MockCanvas mockCanvas(&device);
mockCanvas.translate(SkIntToScalar(-8), SkIntToScalar(-8)); mockCanvas.translate(SkIntToScalar(-8), SkIntToScalar(-8));
picture.draw(&mockCanvas); picture.draw(&mockCanvas);
@ -212,7 +212,7 @@ public:
REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]); REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]);
} }
{ {
SkBitmapDevice device(tileBitmap); SkDevice device(tileBitmap);
MockCanvas mockCanvas(&device); MockCanvas mockCanvas(&device);
mockCanvas.translate(SkFloatToScalar(-7.9f), SkFloatToScalar(-7.9f)); mockCanvas.translate(SkFloatToScalar(-7.9f), SkFloatToScalar(-7.9f));
picture.draw(&mockCanvas); picture.draw(&mockCanvas);
@ -221,7 +221,7 @@ public:
REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[1]); REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[1]);
} }
{ {
SkBitmapDevice device(tileBitmap); SkDevice device(tileBitmap);
MockCanvas mockCanvas(&device); MockCanvas mockCanvas(&device);
mockCanvas.translate(SkFloatToScalar(-8.1f), SkFloatToScalar(-8.1f)); mockCanvas.translate(SkFloatToScalar(-8.1f), SkFloatToScalar(-8.1f));
picture.draw(&mockCanvas); picture.draw(&mockCanvas);
@ -233,7 +233,7 @@ public:
// Regression test for crbug.com/234688 // Regression test for crbug.com/234688
// Once the 2x2 device region is inset by margin, it yields an empty // Once the 2x2 device region is inset by margin, it yields an empty
// adjusted region, sitting right on top of the tile boundary. // adjusted region, sitting right on top of the tile boundary.
SkBitmapDevice device(tinyBitmap); SkDevice device(tinyBitmap);
MockCanvas mockCanvas(&device); MockCanvas mockCanvas(&device);
mockCanvas.translate(SkFloatToScalar(-8.0f), SkFloatToScalar(-8.0f)); mockCanvas.translate(SkFloatToScalar(-8.0f), SkFloatToScalar(-8.0f));
picture.draw(&mockCanvas); picture.draw(&mockCanvas);

Просмотреть файл

@ -227,7 +227,7 @@ bool checkWrite(skiatest::Reporter* reporter,
const SkBitmap& bitmap, const SkBitmap& bitmap,
int writeX, int writeY, int writeX, int writeY,
SkCanvas::Config8888 config8888) { SkCanvas::Config8888 config8888) {
SkBaseDevice* dev = canvas->getDevice(); SkDevice* dev = canvas->getDevice();
if (!dev) { if (!dev) {
return false; return false;
} }
@ -305,7 +305,7 @@ static const CanvasConfig gCanvasConfigs[] = {
#endif #endif
}; };
SkBaseDevice* createDevice(const CanvasConfig& c, GrContext* grCtx) { SkDevice* createDevice(const CanvasConfig& c, GrContext* grCtx) {
switch (c.fDevType) { switch (c.fDevType) {
case kRaster_DevType: { case kRaster_DevType: {
SkBitmap bmp; SkBitmap bmp;
@ -320,7 +320,7 @@ SkBaseDevice* createDevice(const CanvasConfig& c, GrContext* grCtx) {
SkAutoLockPixels alp(bmp); SkAutoLockPixels alp(bmp);
memset(bmp.getPixels(), DEV_PAD, bmp.getSafeSize()); memset(bmp.getPixels(), DEV_PAD, bmp.getSafeSize());
} }
return new SkBitmapDevice(bmp); return new SkDevice(bmp);
} }
#if SK_SUPPORT_GPU #if SK_SUPPORT_GPU
case kGpu_BottomLeft_DevType: case kGpu_BottomLeft_DevType:
@ -435,7 +435,7 @@ void WritePixelsTest(skiatest::Reporter* reporter, GrContextFactory* factory) {
} }
#endif #endif
SkAutoTUnref<SkBaseDevice> device(createDevice(gCanvasConfigs[i], context)); SkAutoTUnref<SkDevice> device(createDevice(gCanvasConfigs[i], context));
SkCanvas canvas(device); SkCanvas canvas(device);
static const SkCanvas::Config8888 gSrcConfigs[] = { static const SkCanvas::Config8888 gSrcConfigs[] = {