check-point for testing drawBitmap [raster,gpu] -> [raster,gpu]

git-svn-id: http://skia.googlecode.com/svn/trunk@1796 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@google.com 2011-07-06 13:59:47 +00:00
parent a3237875f8
commit 3cec4d71e6
3 changed files with 33 additions and 12 deletions

View File

@ -51,6 +51,8 @@ extern SkView* create_overview(int, const SkViewFactory[]);
#include "GrGLConfig.h"
#endif
static SampleWindow* gSampleWindow;
///////////////
static const char view_inval_msg[] = "view-inval-msg";
@ -240,6 +242,10 @@ SkScalar SampleCode::GetAnimScalar(SkScalar speed, SkScalar period) {
return SkDoubleToScalar(value);
}
GrContext* SampleCode::GetGr() {
return gSampleWindow ? gSampleWindow->getGrContext() : NULL;
}
//////////////////////////////////////////////////////////////////////////////
static SkView* curr_view(SkWindow* wind) {
@ -348,6 +354,8 @@ SampleWindow::CanvasType SampleWindow::cycle_canvastype(CanvasType ct) {
}
SampleWindow::SampleWindow(void* hwnd, int argc, char** argv) : INHERITED(hwnd) {
gSampleWindow = this;
#ifdef PIPE_FILE
//Clear existing file or create file if it doesn't exist
FILE* f = fopen(FILE_PATH, "wb");

View File

@ -17,28 +17,34 @@
#include "SkOSFile.h"
#include "SkStream.h"
static SkBitmap make_bitmap() {
SkBitmap bm;
bm.setConfig(SkBitmap::kARGB_8888_Config, 64, 64);
bm.allocPixels();
SkCanvas canvas(bm);
#include "SkGpuDevice.h"
static SkDevice* make_bitmap(SkBitmap* bitmap, GrContext* ctx) {
SkCanvas canvas;
if (ctx) {
SkDevice* dev = new SkGpuDevice(ctx, SkBitmap::kARGB_8888_Config, 64, 64);
canvas.setDevice(dev)->unref();
*bitmap = dev->accessBitmap(false);
} else {
bitmap->setConfig(SkBitmap::kARGB_8888_Config, 64, 64);
bitmap->allocPixels();
canvas.setBitmapDevice(*bitmap);
}
canvas.drawColor(SK_ColorRED);
SkPaint paint;
paint.setAntiAlias(true);
const SkPoint pts[] = { { 0, 0 }, { 64, 64 } };
const SkColor colors[] = { SK_ColorWHITE, SK_ColorBLUE };
paint.setShader(SkGradientShader::CreateLinear(pts, colors, NULL, 2,
SkShader::kClamp_TileMode))->unref();
SkShader::kClamp_TileMode))->unref();
canvas.drawCircle(32, 32, 32, paint);
return bm;
}
class BitmapRectView : public SampleView {
public:
SkBitmap fBitmap;
BitmapRectView() {
fBitmap = make_bitmap();
this->setBGColor(SK_ColorGRAY);
}
@ -64,6 +70,9 @@ protected:
paint.setStyle(SkPaint::kStroke_Style);
paint.setColor(SK_ColorGREEN);
SkBitmap bitmap;
make_bitmap(&bitmap, NULL /*SampleCode::GetGr()*/);
SkRect dstR = { 0, 200, 128, 380 };
canvas->translate(16, 40);
@ -71,8 +80,8 @@ protected:
SkRect srcR;
srcR.set(src[i]);
canvas->drawBitmap(fBitmap, 0, 0, &paint);
canvas->drawBitmapRect(fBitmap, &src[i], dstR, &paint);
canvas->drawBitmap(bitmap, 0, 0, &paint);
canvas->drawBitmapRect(bitmap, &src[i], dstR, &paint);
canvas->drawRect(dstR, paint);
canvas->drawRect(srcR, paint);

View File

@ -6,6 +6,8 @@
#include "SkKey.h"
#include "SkView.h"
class GrContext;
class SampleCode {
public:
static bool KeyQ(const SkEvent&, SkKey* outKey);
@ -23,6 +25,8 @@ public:
static SkMSec GetAnimTimeDelta();
static SkScalar GetAnimSecondsDelta();
static SkScalar GetAnimScalar(SkScalar speedPerSec, SkScalar period = 0);
static GrContext* GetGr();
};
//////////////////////////////////////////////////////////////////////////////