add surfaceprops to SkWindow, and 'D' to toggle distancefieldfonts
BUG=skia: Review URL: https://codereview.chromium.org/631943002
This commit is contained in:
parent
3342d1b5a0
commit
4302ae91b0
@ -14,6 +14,7 @@
|
||||
#include "SkRegion.h"
|
||||
#include "SkEvent.h"
|
||||
#include "SkKey.h"
|
||||
#include "SkSurfaceProps.h"
|
||||
#include "SkTDArray.h"
|
||||
|
||||
#ifdef SK_BUILD_FOR_WINCEx
|
||||
@ -29,6 +30,11 @@ public:
|
||||
SkWindow();
|
||||
virtual ~SkWindow();
|
||||
|
||||
SkSurfaceProps getSurfaceProps() const { return fSurfaceProps; }
|
||||
void setSurfaceProps(const SkSurfaceProps& props) {
|
||||
fSurfaceProps = props;
|
||||
}
|
||||
|
||||
const SkBitmap& getBitmap() const { return fBitmap; }
|
||||
|
||||
void setColorType(SkColorType);
|
||||
@ -80,6 +86,7 @@ protected:
|
||||
virtual bool onSetFocusView(SkView* focus);
|
||||
|
||||
private:
|
||||
SkSurfaceProps fSurfaceProps;
|
||||
SkColorType fColorType;
|
||||
SkBitmap fBitmap;
|
||||
SkRegion fDirtyRgn;
|
||||
|
@ -275,7 +275,8 @@ public:
|
||||
SampleWindow* win) SK_OVERRIDE {
|
||||
#if SK_SUPPORT_GPU
|
||||
if (IsGpuDeviceType(dType) && fCurContext) {
|
||||
return SkSurface::NewRenderTargetDirect(fCurRenderTarget);
|
||||
SkSurfaceProps props(win->getSurfaceProps());
|
||||
return SkSurface::NewRenderTargetDirect(fCurRenderTarget, &props);
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
@ -1715,6 +1716,9 @@ bool SampleWindow::onHandleChar(SkUnichar uni) {
|
||||
post_event_to_sink(SkNEW_ARGS(SkEvent, (gUpdateWindowTitleEvtName)), this);
|
||||
this->inval(NULL);
|
||||
break;
|
||||
case 'D':
|
||||
toggleDistanceFieldFonts();
|
||||
break;
|
||||
case 'f':
|
||||
// only
|
||||
toggleFPS();
|
||||
@ -1812,6 +1816,15 @@ void SampleWindow::toggleFPS() {
|
||||
this->inval(NULL);
|
||||
}
|
||||
|
||||
void SampleWindow::toggleDistanceFieldFonts() {
|
||||
SkSurfaceProps props = this->getSurfaceProps();
|
||||
uint32_t flags = props.flags() ^ SkSurfaceProps::kUseDistanceFieldFonts_Flag;
|
||||
this->setSurfaceProps(SkSurfaceProps(flags, props.pixelGeometry()));
|
||||
|
||||
this->updateTitle();
|
||||
this->inval(NULL);
|
||||
}
|
||||
|
||||
#include "SkDumpCanvas.h"
|
||||
|
||||
bool SampleWindow::onHandleKey(SkKey key) {
|
||||
@ -2023,6 +2036,9 @@ void SampleWindow::updateTitle() {
|
||||
if (fPerspAnim) {
|
||||
title.prepend("<K> ");
|
||||
}
|
||||
if (this->getSurfaceProps().flags() & SkSurfaceProps::kUseDistanceFieldFonts_Flag) {
|
||||
title.prepend("<DFF> ");
|
||||
}
|
||||
|
||||
title.prepend(trystate_str(fLCDState, "LCD ", "lcd "));
|
||||
title.prepend(trystate_str(fAAState, "AA ", "aa "));
|
||||
|
@ -118,6 +118,7 @@ public:
|
||||
void toggleSlideshow();
|
||||
void toggleFPS();
|
||||
void showOverview();
|
||||
void toggleDistanceFieldFonts();
|
||||
|
||||
GrContext* getGrContext() const { return fDevManager->getGrContext(); }
|
||||
|
||||
|
@ -14,7 +14,10 @@
|
||||
|
||||
#define SK_EventDelayInval "\xd" "n" "\xa" "l"
|
||||
|
||||
SkWindow::SkWindow() : fFocusView(NULL) {
|
||||
SkWindow::SkWindow()
|
||||
: fSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)
|
||||
, fFocusView(NULL)
|
||||
{
|
||||
fClicks.reset();
|
||||
fWaitingOnInval = false;
|
||||
|
||||
@ -34,7 +37,7 @@ SkWindow::~SkWindow() {
|
||||
|
||||
SkSurface* SkWindow::createSurface() {
|
||||
const SkBitmap& bm = this->getBitmap();
|
||||
return SkSurface::NewRasterDirect(bm.info(), bm.getPixels(), bm.rowBytes());
|
||||
return SkSurface::NewRasterDirect(bm.info(), bm.getPixels(), bm.rowBytes(), &fSurfaceProps);
|
||||
}
|
||||
|
||||
void SkWindow::setMatrix(const SkMatrix& matrix) {
|
||||
|
Loading…
Reference in New Issue
Block a user