Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Unified Diff: gm/dftext.cpp

Issue 670533002: Add color emoji fallback for distance field text. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix nits Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | src/gpu/GrDistanceFieldTextContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/dftext.cpp
diff --git a/gm/dftext.cpp b/gm/dftext.cpp
index 6f75c4671391af834412f8be0d87cd26bb10a6ec..16fe4bd385db9241c574cadc8698b0ee13a8caee 100755
--- a/gm/dftext.cpp
+++ b/gm/dftext.cpp
@@ -5,30 +5,44 @@
* found in the LICENSE file.
*/
#include "gm.h"
+#include "Resources.h"
+#include "SkCanvas.h"
+#include "SkStream.h"
#include "SkSurface.h"
#include "SkTypeface.h"
-namespace skiagm {
-
-class DFTextGM : public GM {
+class DFTextGM : public skiagm::GM {
public:
DFTextGM() {
this->setBGColor(0xFFFFFFFF);
+ fTypeface = NULL;
}
virtual ~DFTextGM() {
+ SkSafeUnref(fTypeface);
}
protected:
+ virtual void onOnceBeforeDraw() SK_OVERRIDE {
+ SkString filename = GetResourcePath("/Funkster.ttf");
+ SkAutoTUnref<SkFILEStream> stream(new SkFILEStream(filename.c_str()));
+ if (!stream->isValid()) {
+ SkDebugf("Could not find Funkster.ttf, please set --resourcePath correctly.\n");
+ return;
+ }
+
+ fTypeface = SkTypeface::CreateFromStream(stream);
+ }
+
virtual uint32_t onGetFlags() const SK_OVERRIDE {
return kGPUOnly_Flag;
}
- virtual SkString onShortName() {
+ virtual SkString onShortName() SK_OVERRIDE {
return SkString("dftext");
}
- virtual SkISize onISize() {
+ virtual SkISize onISize() SK_OVERRIDE {
return SkISize::Make(1024, 768);
}
@@ -185,6 +199,10 @@ protected:
y += paint.getFontMetrics(NULL);
}
+ // check color emoji
+ paint.setTypeface(fTypeface);
+ canvas->drawText(text, textLen, 670, 100, paint);
+
#if SK_SUPPORT_GPU
// render offscreen buffer
if (surface) {
@@ -199,12 +217,9 @@ protected:
}
private:
- typedef GM INHERITED;
-};
+ SkTypeface* fTypeface;
-//////////////////////////////////////////////////////////////////////////////
-
-static GM* MyFactory(void*) { return new DFTextGM; }
-static GMRegistry reg(MyFactory);
+ typedef skiagm::GM INHERITED;
+};
-}
+DEF_GM( return SkNEW(DFTextGM); )
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | src/gpu/GrDistanceFieldTextContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698