aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-10-06 12:29:56 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-06 12:29:56 -0700
commit4302ae91b0c97993f7b659474a5fd305921cdc5e (patch)
treebab85c4316b7d205deb06e4958fd3aee266c7fed /samplecode
parent3342d1b5a03e816b0ab1a11bf92d2da0f4b5ca4c (diff)
add surfaceprops to SkWindow, and 'D' to toggle distancefieldfonts
Diffstat (limited to 'samplecode')
-rw-r--r--samplecode/SampleApp.cpp18
-rw-r--r--samplecode/SampleApp.h1
2 files changed, 18 insertions, 1 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 6ca67bcbcd..1b766b021b 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -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 "));
diff --git a/samplecode/SampleApp.h b/samplecode/SampleApp.h
index abb1f24002..2e9a11c2a1 100644
--- a/samplecode/SampleApp.h
+++ b/samplecode/SampleApp.h
@@ -118,6 +118,7 @@ public:
void toggleSlideshow();
void toggleFPS();
void showOverview();
+ void toggleDistanceFieldFonts();
GrContext* getGrContext() const { return fDevManager->getGrContext(); }