38aeb0fd7a
Also: - make GrMemoryPoolBenches threadsafe - some tweaks to various DM code - rename GM::shortName() to getName() to match benches and tests On my desktop, (289 GMs, 617 benches) x 4 configs, 227 tests takes 46s in Debug, 14s in Release. (Still minutes faster than running tests && bench && gm.) GPU singlethreading is definitely the limiting factor again; going to reexamine whether that's helpful to thread it again. BUG=skia: R=reed@google.com, bsalomon@google.com, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/178473006 git-svn-id: http://skia.googlecode.com/svn/trunk@13603 2bbb7eff-a529-9590-31e7-b0007b416f81
79 lines
1.8 KiB
C++
79 lines
1.8 KiB
C++
|
|
/*
|
|
* Copyright 2011 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
|
|
#ifndef GMSampleView_DEFINED
|
|
#define GMSampleView_DEFINED
|
|
|
|
#include "SampleCode.h"
|
|
#include "gm.h"
|
|
|
|
class GMSampleView : public SampleView {
|
|
private:
|
|
bool fShowSize;
|
|
typedef skiagm::GM GM;
|
|
|
|
public:
|
|
GMSampleView(GM* gm)
|
|
: fShowSize(false), fGM(gm) {}
|
|
|
|
virtual ~GMSampleView() {
|
|
delete fGM;
|
|
}
|
|
|
|
static SkEvent* NewShowSizeEvt(bool doShowSize) {
|
|
SkEvent* evt = SkNEW_ARGS(SkEvent, ("GMSampleView::showSize"));
|
|
evt->setFast32(doShowSize);
|
|
return evt;
|
|
}
|
|
|
|
protected:
|
|
virtual bool onQuery(SkEvent* evt) {
|
|
if (SampleCode::TitleQ(*evt)) {
|
|
SkString name("GM:");
|
|
name.append(fGM->getName());
|
|
SampleCode::TitleR(evt, name.c_str());
|
|
return true;
|
|
}
|
|
return this->INHERITED::onQuery(evt);
|
|
}
|
|
|
|
virtual bool onEvent(const SkEvent& evt) SK_OVERRIDE {
|
|
if (evt.isType("GMSampleView::showSize")) {
|
|
fShowSize = SkToBool(evt.getFast32());
|
|
return true;
|
|
}
|
|
return this->INHERITED::onEvent(evt);
|
|
}
|
|
|
|
virtual void onDrawContent(SkCanvas* canvas) {
|
|
{
|
|
SkAutoCanvasRestore acr(canvas, fShowSize);
|
|
fGM->drawContent(canvas);
|
|
}
|
|
if (fShowSize) {
|
|
SkISize size = fGM->getISize();
|
|
SkRect r = SkRect::MakeWH(SkIntToScalar(size.width()),
|
|
SkIntToScalar(size.height()));
|
|
SkPaint paint;
|
|
paint.setColor(0x40FF8833);
|
|
canvas->drawRect(r, paint);
|
|
}
|
|
}
|
|
|
|
virtual void onDrawBackground(SkCanvas* canvas) {
|
|
fGM->drawBackground(canvas);
|
|
}
|
|
|
|
private:
|
|
GM* fGM;
|
|
typedef SampleView INHERITED;
|
|
};
|
|
|
|
#endif
|