зеркало из https://github.com/mozilla/moz-skia.git
flag the GM if we're in deferred-canvas mode, to work-around bug trying to
get the context from its device. git-svn-id: http://skia.googlecode.com/svn/trunk@6452 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
Родитель
13201e74f4
Коммит
aef73617d1
|
@ -12,6 +12,7 @@ SkString GM::gResourcePath;
|
|||
|
||||
GM::GM() {
|
||||
fBGColor = SK_ColorWHITE;
|
||||
fCanvasIsDeferred = false;
|
||||
}
|
||||
GM::~GM() {}
|
||||
|
||||
|
|
6
gm/gm.h
6
gm/gm.h
|
@ -71,6 +71,11 @@ namespace skiagm {
|
|||
gResourcePath = resourcePath;
|
||||
}
|
||||
|
||||
bool isCanvasDeferred() const { return fCanvasIsDeferred; }
|
||||
void setCanvasIsDeferred(bool isDeferred) {
|
||||
fCanvasIsDeferred = isDeferred;
|
||||
}
|
||||
|
||||
protected:
|
||||
static SkString gResourcePath;
|
||||
|
||||
|
@ -84,6 +89,7 @@ namespace skiagm {
|
|||
private:
|
||||
SkString fShortName;
|
||||
SkColor fBGColor;
|
||||
bool fCanvasIsDeferred; // work-around problem in srcmode.cpp
|
||||
};
|
||||
|
||||
typedef SkTRegistry<GM*, void*> GMRegistry;
|
||||
|
|
|
@ -379,13 +379,14 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
static void invokeGM(GM* gm, SkCanvas* canvas, bool isPDF = false) {
|
||||
static void invokeGM(GM* gm, SkCanvas* canvas, bool isPDF, bool isDeferred) {
|
||||
SkAutoCanvasRestore acr(canvas, true);
|
||||
|
||||
if (!isPDF) {
|
||||
canvas->concat(gm->getInitialTransform());
|
||||
}
|
||||
installFilter(canvas);
|
||||
gm->setCanvasIsDeferred(isDeferred);
|
||||
gm->draw(canvas);
|
||||
canvas->setDrawFilter(NULL);
|
||||
}
|
||||
|
@ -407,7 +408,7 @@ public:
|
|||
} else {
|
||||
canvas.reset(new SkCanvas(device));
|
||||
}
|
||||
invokeGM(gm, canvas);
|
||||
invokeGM(gm, canvas, false, deferred);
|
||||
canvas->flush();
|
||||
}
|
||||
#if SK_SUPPORT_GPU
|
||||
|
@ -421,7 +422,7 @@ public:
|
|||
} else {
|
||||
canvas.reset(new SkCanvas(device));
|
||||
}
|
||||
invokeGM(gm, canvas);
|
||||
invokeGM(gm, canvas, false, deferred);
|
||||
// the device is as large as the current rendertarget, so
|
||||
// we explicitly only readback the amount we expect (in
|
||||
// size) overwrite our previous allocation
|
||||
|
@ -463,7 +464,7 @@ public:
|
|||
SkAutoUnref aur(dev);
|
||||
|
||||
SkCanvas c(dev);
|
||||
invokeGM(gm, &c, true);
|
||||
invokeGM(gm, &c, true, false);
|
||||
|
||||
SkPDFDocument doc;
|
||||
doc.appendPage(dev);
|
||||
|
@ -489,7 +490,7 @@ public:
|
|||
SkCanvas c(dev);
|
||||
dev->beginPortfolio(&xps);
|
||||
dev->beginSheet(unitsPerMeter, pixelsPerMeter, trimSize);
|
||||
invokeGM(gm, &c);
|
||||
invokeGM(gm, &c, false, false);
|
||||
dev->endSheet();
|
||||
dev->endPortfolio();
|
||||
|
||||
|
@ -621,7 +622,7 @@ public:
|
|||
SkPicture* pict = new SkPicture;
|
||||
SkISize size = gm->getISize();
|
||||
SkCanvas* cv = pict->beginRecording(size.width(), size.height());
|
||||
invokeGM(gm, cv);
|
||||
invokeGM(gm, cv, false, false);
|
||||
pict->endRecording();
|
||||
|
||||
return pict;
|
||||
|
@ -722,7 +723,7 @@ public:
|
|||
SkGPipeWriter writer;
|
||||
SkCanvas* pipeCanvas = writer.startRecording(
|
||||
&pipeController, gPipeWritingFlagCombos[i].flags);
|
||||
invokeGM(gm, pipeCanvas);
|
||||
invokeGM(gm, pipeCanvas, false, false);
|
||||
writer.endRecording();
|
||||
SkString string("-pipe");
|
||||
string.append(gPipeWritingFlagCombos[i].name);
|
||||
|
@ -749,7 +750,7 @@ public:
|
|||
SkGPipeWriter writer;
|
||||
SkCanvas* pipeCanvas = writer.startRecording(
|
||||
&pipeController, gPipeWritingFlagCombos[i].flags);
|
||||
invokeGM(gm, pipeCanvas);
|
||||
invokeGM(gm, pipeCanvas, false, false);
|
||||
writer.endRecording();
|
||||
SkString string("-tiled pipe");
|
||||
string.append(gPipeWritingFlagCombos[i].name);
|
||||
|
|
|
@ -115,7 +115,8 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
static SkSurface* compat_surface(SkCanvas* canvas, const SkISize& size) {
|
||||
static SkSurface* compat_surface(SkCanvas* canvas, const SkISize& size,
|
||||
bool skipGPU) {
|
||||
SkImage::Info info = {
|
||||
size.width(),
|
||||
size.height(),
|
||||
|
@ -124,7 +125,7 @@ protected:
|
|||
};
|
||||
#if SK_SUPPORT_GPU
|
||||
SkDevice* dev = canvas->getDevice();
|
||||
if (dev->accessRenderTarget()) {
|
||||
if (!skipGPU && dev->accessRenderTarget()) {
|
||||
SkGpuDevice* gd = (SkGpuDevice*)dev;
|
||||
GrContext* ctx = gd->context();
|
||||
return SkSurface::NewRenderTarget(ctx, info, 0);
|
||||
|
@ -134,7 +135,8 @@ protected:
|
|||
}
|
||||
|
||||
virtual void onDraw(SkCanvas* canvas) {
|
||||
SkAutoTUnref<SkSurface> surf(compat_surface(canvas, this->getISize()));
|
||||
SkAutoTUnref<SkSurface> surf(compat_surface(canvas, this->getISize(),
|
||||
this->isCanvasDeferred()));
|
||||
surf->getCanvas()->drawColor(SK_ColorWHITE);
|
||||
this->drawContent(surf->getCanvas());
|
||||
surf->draw(canvas, 0, 0, NULL);
|
||||
|
|
Загрузка…
Ссылка в новой задаче