draw offscreen so we can see the alpha-channel we are writing

todo: know when to use a gpu-surface



git-svn-id: http://skia.googlecode.com/svn/trunk@6436 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2012-11-15 17:24:23 +00:00
Родитель fe830a4641
Коммит 86eca4774b
1 изменённых файлов: 21 добавлений и 2 удалений

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

@ -8,6 +8,7 @@
#include "gm.h"
#include "SkCanvas.h"
#include "SkGradientShader.h"
#include "SkSurface.h"
#define W SkIntToScalar(80)
#define H SkIntToScalar(60)
@ -56,7 +57,7 @@ class SrcModeGM : public skiagm::GM {
SkPath fPath;
public:
SrcModeGM() {
this->setBGColor(0xFFDDDDDD);
this->setBGColor(SK_ColorBLACK);
}
protected:
@ -68,7 +69,7 @@ protected:
return SkISize::Make(640, 760);
}
virtual void onDraw(SkCanvas* canvas) {
void drawContent(SkCanvas* canvas) {
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
SkPaint paint;
@ -107,6 +108,24 @@ protected:
}
}
static SkSurface* compat_surface(SkCanvas* canvas, const SkISize& size) {
SkImage::Info info = {
size.width(),
size.height(),
SkImage::kPMColor_ColorType,
SkImage::kPremul_AlphaType
};
return SkSurface::NewRaster(info);
}
virtual void onDraw(SkCanvas* canvas) {
SkAutoTUnref<SkSurface> surf(compat_surface(canvas, this->getISize()));
surf->getCanvas()->drawColor(SK_ColorWHITE);
this->drawContent(surf->getCanvas());
surf->draw(canvas, 0, 0, NULL);
}
private:
typedef skiagm::GM INHERITED;
};