зеркало из https://github.com/mozilla/moz-skia.git
add gpu to gm tool
add pass-through read/write pixels API to canvas git-svn-id: http://skia.googlecode.com/svn/trunk@660 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
da96ea01fe
Коммит
51df9e3fe3
|
@ -181,12 +181,13 @@ static void write_pdf(GM* gm, const char writePath[]) {
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
SkBitmap::Config fConfig;
|
SkBitmap::Config fConfig;
|
||||||
bool fUsePicture;
|
bool fUseGPU;
|
||||||
const char* fName;
|
const char* fName;
|
||||||
} gRec[] = {
|
} gRec[] = {
|
||||||
{ SkBitmap::kARGB_8888_Config, false, "8888" },
|
{ SkBitmap::kARGB_8888_Config, false, "8888" },
|
||||||
{ SkBitmap::kARGB_4444_Config, false, "4444" },
|
{ SkBitmap::kARGB_4444_Config, false, "4444" },
|
||||||
{ SkBitmap::kRGB_565_Config, false, "565" },
|
{ SkBitmap::kRGB_565_Config, false, "565" },
|
||||||
|
{ SkBitmap::kARGB_8888_Config, true, "gpu" },
|
||||||
};
|
};
|
||||||
|
|
||||||
int main (int argc, char * const argv[]) {
|
int main (int argc, char * const argv[]) {
|
||||||
|
@ -242,12 +243,14 @@ int main (int argc, char * const argv[]) {
|
||||||
bitmap.eraseColor(0);
|
bitmap.eraseColor(0);
|
||||||
SkCanvas canvas(bitmap);
|
SkCanvas canvas(bitmap);
|
||||||
|
|
||||||
gm->draw(&canvas);
|
if (gRec[i].fUseGPU) {
|
||||||
{
|
|
||||||
SkGpuCanvas gc(context);
|
SkGpuCanvas gc(context);
|
||||||
gc.setDevice(gc.createDevice(bitmap.config(), bitmap.width(), bitmap.height(),
|
gc.setDevice(gc.createDevice(bitmap.config(), bitmap.width(), bitmap.height(),
|
||||||
bitmap.isOpaque(), false))->unref();
|
bitmap.isOpaque(), false))->unref();
|
||||||
gm->draw(&gc);
|
gm->draw(&gc);
|
||||||
|
gc.readPixels(&bitmap); // overwrite our previous allocation
|
||||||
|
} else {
|
||||||
|
gm->draw(&canvas);
|
||||||
}
|
}
|
||||||
SkString name = make_name(gm->shortName(), gRec[i].fName);
|
SkString name = make_name(gm->shortName(), gRec[i].fName);
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,20 @@ public:
|
||||||
*/
|
*/
|
||||||
SkDevice* setBitmapDevice(const SkBitmap& bitmap, bool forLayer = false);
|
SkDevice* setBitmapDevice(const SkBitmap& bitmap, bool forLayer = false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy the pixels from the device into bitmap. Returns true on success.
|
||||||
|
* If false is returned, then the bitmap parameter is left unchanged.
|
||||||
|
*/
|
||||||
|
bool readPixels(const SkIRect& srcRect, SkBitmap* bitmap);
|
||||||
|
bool readPixels(SkBitmap* bitmap);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
void writePixels(const SkBitmap& bitmap, int x, int y);
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
enum SaveFlags {
|
enum SaveFlags {
|
||||||
|
|
|
@ -549,6 +549,31 @@ SkDevice* SkCanvas::setBitmapDevice(const SkBitmap& bitmap, bool forLayer) {
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SkCanvas::readPixels(const SkIRect& srcRect, SkBitmap* bitmap) {
|
||||||
|
SkDevice* device = this->getDevice();
|
||||||
|
if (!device) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return device->readPixels(srcRect, bitmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SkCanvas::readPixels(SkBitmap* bitmap) {
|
||||||
|
SkDevice* device = this->getDevice();
|
||||||
|
if (!device) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SkIRect bounds;
|
||||||
|
bounds.set(0, 0, device->width(), device->height());
|
||||||
|
return this->readPixels(bounds, bitmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkCanvas::writePixels(const SkBitmap& bitmap, int x, int y) {
|
||||||
|
SkDevice* device = this->getDevice();
|
||||||
|
if (device) {
|
||||||
|
device->writePixels(bitmap, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool SkCanvas::getViewport(SkIPoint* size) const {
|
bool SkCanvas::getViewport(SkIPoint* size) const {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче