1. remove references to (deprecated) SkGpuCanvas
2. remove references to setDevice (soon to be deprecated) Review URL: https://codereview.appspot.com/6597055 git-svn-id: http://skia.googlecode.com/svn/trunk@5751 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
0ab7c77a2c
commit
44a42ea8b2
@ -306,15 +306,15 @@ static ErrorBitfield generate_image(GM* gm, const ConfigData& gRec,
|
|||||||
SkISize size (gm->getISize());
|
SkISize size (gm->getISize());
|
||||||
setup_bitmap(gRec, size, bitmap);
|
setup_bitmap(gRec, size, bitmap);
|
||||||
|
|
||||||
|
SkAutoTUnref<SkCanvas> canvas;
|
||||||
|
|
||||||
if (gRec.fBackend == kRaster_Backend) {
|
if (gRec.fBackend == kRaster_Backend) {
|
||||||
SkCanvas* canvas;
|
SkAutoTUnref<SkDevice> device(new SkDevice(*bitmap));
|
||||||
if (deferred) {
|
if (deferred) {
|
||||||
canvas = new SkDeferredCanvas;
|
canvas.reset(new SkDeferredCanvas(device));
|
||||||
canvas->setDevice(new SkDevice(*bitmap))->unref();
|
|
||||||
} else {
|
} else {
|
||||||
canvas = new SkCanvas(*bitmap);
|
canvas.reset(new SkCanvas(device));
|
||||||
}
|
}
|
||||||
SkAutoUnref canvasUnref(canvas);
|
|
||||||
invokeGM(gm, canvas);
|
invokeGM(gm, canvas);
|
||||||
canvas->flush();
|
canvas->flush();
|
||||||
}
|
}
|
||||||
@ -323,21 +323,19 @@ static ErrorBitfield generate_image(GM* gm, const ConfigData& gRec,
|
|||||||
if (NULL == context) {
|
if (NULL == context) {
|
||||||
return ERROR_NO_GPU_CONTEXT;
|
return ERROR_NO_GPU_CONTEXT;
|
||||||
}
|
}
|
||||||
SkCanvas* gc;
|
SkAutoTUnref<SkDevice> device(new SkGpuDevice(context, rt));
|
||||||
if (deferred) {
|
if (deferred) {
|
||||||
gc = new SkDeferredCanvas;
|
canvas.reset(new SkDeferredCanvas(device));
|
||||||
} else {
|
} else {
|
||||||
gc = new SkGpuCanvas(context, rt);
|
canvas.reset(new SkCanvas(device));
|
||||||
}
|
}
|
||||||
SkAutoUnref gcUnref(gc);
|
invokeGM(gm, canvas);
|
||||||
gc->setDevice(new SkGpuDevice(context, rt))->unref();
|
|
||||||
invokeGM(gm, gc);
|
|
||||||
// the device is as large as the current rendertarget, so we explicitly
|
// the device is as large as the current rendertarget, so we explicitly
|
||||||
// only readback the amount we expect (in size)
|
// only readback the amount we expect (in size)
|
||||||
// overwrite our previous allocation
|
// overwrite our previous allocation
|
||||||
bitmap->setConfig(SkBitmap::kARGB_8888_Config, size.fWidth,
|
bitmap->setConfig(SkBitmap::kARGB_8888_Config, size.fWidth,
|
||||||
size.fHeight);
|
size.fHeight);
|
||||||
gc->readPixels(bitmap, 0, 0);
|
canvas->readPixels(bitmap, 0, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return ERROR_NONE;
|
return ERROR_NONE;
|
||||||
|
@ -15,7 +15,6 @@ class GrContext;
|
|||||||
|
|
||||||
static void make_bitmap(SkBitmap* bitmap, GrContext* ctx, SkIRect* center) {
|
static void make_bitmap(SkBitmap* bitmap, GrContext* ctx, SkIRect* center) {
|
||||||
SkDevice* dev;
|
SkDevice* dev;
|
||||||
SkCanvas canvas;
|
|
||||||
|
|
||||||
const int kFixed = 28;
|
const int kFixed = 28;
|
||||||
const int kStretchy = 8;
|
const int kStretchy = 8;
|
||||||
@ -33,7 +32,8 @@ static void make_bitmap(SkBitmap* bitmap, GrContext* ctx, SkIRect* center) {
|
|||||||
dev = new SkDevice(*bitmap);
|
dev = new SkDevice(*bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas.setDevice(dev)->unref();
|
SkCanvas canvas(dev);
|
||||||
|
dev->unref();
|
||||||
canvas.clear(0);
|
canvas.clear(0);
|
||||||
|
|
||||||
SkRect r = SkRect::MakeWH(SkIntToScalar(kSize), SkIntToScalar(kSize));
|
SkRect r = SkRect::MakeWH(SkIntToScalar(kSize), SkIntToScalar(kSize));
|
||||||
|
@ -48,24 +48,25 @@ static const SkCanvas::Config8888 gUnpremulConfigs[] = {
|
|||||||
|
|
||||||
void PremulAlphaRoundTripTest(skiatest::Reporter* reporter,
|
void PremulAlphaRoundTripTest(skiatest::Reporter* reporter,
|
||||||
GrContext* context) {
|
GrContext* context) {
|
||||||
SkCanvas canvas;
|
SkAutoTUnref<SkDevice> device;
|
||||||
for (int dtype = 0; dtype < 2; ++dtype) {
|
for (int dtype = 0; dtype < 2; ++dtype) {
|
||||||
if (0 == dtype) {
|
if (0 == dtype) {
|
||||||
canvas.setDevice(new SkDevice(SkBitmap::kARGB_8888_Config,
|
device.reset(new SkDevice(SkBitmap::kARGB_8888_Config,
|
||||||
256,
|
256,
|
||||||
256,
|
256,
|
||||||
false))->unref();
|
false));
|
||||||
} else {
|
} else {
|
||||||
#if !SK_SUPPORT_GPU || defined(SK_SCALAR_IS_FIXED)
|
#if !SK_SUPPORT_GPU || defined(SK_SCALAR_IS_FIXED)
|
||||||
// GPU device known not to work in the fixed pt build.
|
// GPU device known not to work in the fixed pt build.
|
||||||
continue;
|
continue;
|
||||||
#else
|
#else
|
||||||
canvas.setDevice(new SkGpuDevice(context,
|
device.reset(new SkGpuDevice(context,
|
||||||
SkBitmap::kARGB_8888_Config,
|
SkBitmap::kARGB_8888_Config,
|
||||||
256,
|
256,
|
||||||
256))->unref();
|
256));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
SkCanvas canvas(device);
|
||||||
|
|
||||||
SkBitmap readBmp1;
|
SkBitmap readBmp1;
|
||||||
readBmp1.setConfig(SkBitmap::kARGB_8888_Config, 256, 256);
|
readBmp1.setConfig(SkBitmap::kARGB_8888_Config, 256, 256);
|
||||||
|
@ -109,7 +109,7 @@ void fillCanvas(SkCanvas* canvas) {
|
|||||||
static SkBitmap bmp;
|
static SkBitmap bmp;
|
||||||
if (bmp.isNull()) {
|
if (bmp.isNull()) {
|
||||||
bmp.setConfig(SkBitmap::kARGB_8888_Config, DEV_W, DEV_H);
|
bmp.setConfig(SkBitmap::kARGB_8888_Config, DEV_W, DEV_H);
|
||||||
bool alloc = bmp.allocPixels();
|
SkDEBUGCODE(bool alloc =) bmp.allocPixels();
|
||||||
SkASSERT(alloc);
|
SkASSERT(alloc);
|
||||||
SkAutoLockPixels alp(bmp);
|
SkAutoLockPixels alp(bmp);
|
||||||
intptr_t pixels = reinterpret_cast<intptr_t>(bmp.getPixels());
|
intptr_t pixels = reinterpret_cast<intptr_t>(bmp.getPixels());
|
||||||
@ -255,8 +255,6 @@ void init_bitmap(SkBitmap* bitmap, const SkIRect& rect, BitmapInit init) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ReadPixelsTest(skiatest::Reporter* reporter, GrContext* context) {
|
void ReadPixelsTest(skiatest::Reporter* reporter, GrContext* context) {
|
||||||
SkCanvas canvas;
|
|
||||||
|
|
||||||
const SkIRect testRects[] = {
|
const SkIRect testRects[] = {
|
||||||
// entire thing
|
// entire thing
|
||||||
DEV_RECT,
|
DEV_RECT,
|
||||||
@ -305,23 +303,24 @@ void ReadPixelsTest(skiatest::Reporter* reporter, GrContext* context) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (int dtype = 0; dtype < 2; ++dtype) {
|
for (int dtype = 0; dtype < 2; ++dtype) {
|
||||||
|
SkAutoTUnref<SkDevice> device;
|
||||||
if (0 == dtype) {
|
if (0 == dtype) {
|
||||||
canvas.setDevice(new SkDevice(SkBitmap::kARGB_8888_Config,
|
device.reset(new SkDevice(SkBitmap::kARGB_8888_Config,
|
||||||
DEV_W,
|
DEV_W,
|
||||||
DEV_H,
|
DEV_H,
|
||||||
false))->unref();
|
false));
|
||||||
} else {
|
} else {
|
||||||
// GPU device known not to work in the fixed pt build.
|
// GPU device known not to work in the fixed pt build.
|
||||||
#if defined(SK_SCALAR_IS_FIXED) || !SK_SUPPORT_GPU
|
#if defined(SK_SCALAR_IS_FIXED) || !SK_SUPPORT_GPU
|
||||||
continue;
|
continue;
|
||||||
#else
|
#else
|
||||||
canvas.setDevice(new SkGpuDevice(context,
|
device.reset(new SkGpuDevice(context,
|
||||||
SkBitmap::kARGB_8888_Config,
|
SkBitmap::kARGB_8888_Config,
|
||||||
DEV_W,
|
DEV_W,
|
||||||
DEV_H))->unref();
|
DEV_H));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
SkCanvas canvas(device);
|
||||||
fillCanvas(&canvas);
|
fillCanvas(&canvas);
|
||||||
|
|
||||||
static const SkCanvas::Config8888 gReadConfigs[] = {
|
static const SkCanvas::Config8888 gReadConfigs[] = {
|
||||||
|
@ -77,9 +77,8 @@ static void ReadWriteAlphaTest(skiatest::Reporter* reporter, GrContext* context)
|
|||||||
REPORTER_ASSERT(reporter, match);
|
REPORTER_ASSERT(reporter, match);
|
||||||
|
|
||||||
// Now try writing on the single channel texture
|
// Now try writing on the single channel texture
|
||||||
SkCanvas canvas;
|
SkAutoTUnref<SkDevice> device(new SkGpuDevice(context, texture->asRenderTarget()));
|
||||||
|
SkCanvas canvas(device);
|
||||||
canvas.setDevice(new SkGpuDevice(context, texture->asRenderTarget()))->unref();
|
|
||||||
|
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
|
|
||||||
|
@ -301,32 +301,29 @@ static const CanvasConfig gCanvasConfigs[] = {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
bool setupCanvas(SkCanvas* canvas, 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;
|
||||||
size_t rowBytes = c.fTightRowBytes ? 0 : 4 * DEV_W + 100;
|
size_t rowBytes = c.fTightRowBytes ? 0 : 4 * DEV_W + 100;
|
||||||
bmp.setConfig(SkBitmap::kARGB_8888_Config, DEV_W, DEV_H, rowBytes);
|
bmp.setConfig(SkBitmap::kARGB_8888_Config, DEV_W, DEV_H, rowBytes);
|
||||||
if (!bmp.allocPixels()) {
|
if (!bmp.allocPixels()) {
|
||||||
return false;
|
sk_throw();
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
// if rowBytes isn't tight then set the padding to a known value
|
// if rowBytes isn't tight then set the padding to a known value
|
||||||
if (rowBytes) {
|
if (rowBytes) {
|
||||||
SkAutoLockPixels alp(bmp);
|
SkAutoLockPixels alp(bmp);
|
||||||
memset(bmp.getPixels(), DEV_PAD, bmp.getSafeSize());
|
memset(bmp.getPixels(), DEV_PAD, bmp.getSafeSize());
|
||||||
}
|
}
|
||||||
canvas->setDevice(new SkDevice(bmp))->unref();
|
return new SkDevice(bmp);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
case kGpu_DevType:
|
case kGpu_DevType:
|
||||||
canvas->setDevice(new SkGpuDevice(grCtx,
|
return new SkGpuDevice(grCtx, SkBitmap::kARGB_8888_Config, DEV_W, DEV_H);
|
||||||
SkBitmap::kARGB_8888_Config,
|
|
||||||
DEV_W, DEV_H))->unref();
|
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return true;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool setupBitmap(SkBitmap* bitmap,
|
bool setupBitmap(SkBitmap* bitmap,
|
||||||
@ -400,7 +397,8 @@ void WritePixelsTest(skiatest::Reporter* reporter, GrContext* context) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gCanvasConfigs); ++i) {
|
for (size_t i = 0; i < SK_ARRAY_COUNT(gCanvasConfigs); ++i) {
|
||||||
REPORTER_ASSERT(reporter, setupCanvas(&canvas, gCanvasConfigs[i], context));
|
SkAutoTUnref<SkDevice> device(createDevice(gCanvasConfigs[i], context));
|
||||||
|
SkCanvas canvas(device);
|
||||||
|
|
||||||
static const SkCanvas::Config8888 gSrcConfigs[] = {
|
static const SkCanvas::Config8888 gSrcConfigs[] = {
|
||||||
SkCanvas::kNative_Premul_Config8888,
|
SkCanvas::kNative_Premul_Config8888,
|
||||||
|
Loading…
Reference in New Issue
Block a user