From: caryclark Date: Fri, 12 Jun 2015 18:49:04 +0000 (-0700) Subject: make emptypath portable; add 565 color utility X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~2096 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d85093c28fe360650c46971b00a39c6dbf991a6b;p=platform%2Fupstream%2FlibSkiaSharp.git make emptypath portable; add 565 color utility R=djsollen@google.com Review URL: https://codereview.chromium.org/1182833004 --- diff --git a/gm/emptypath.cpp b/gm/emptypath.cpp index 3b6fe81..219b943 100644 --- a/gm/emptypath.cpp +++ b/gm/emptypath.cpp @@ -63,7 +63,7 @@ protected: SkPaint titlePaint; titlePaint.setColor(SK_ColorBLACK); titlePaint.setAntiAlias(true); - sk_tool_utils::set_portable_typeface(&titlePaint); + sk_tool_utils::set_portable_typeface_always(&titlePaint); titlePaint.setLCDRenderText(true); titlePaint.setTextSize(15 * SK_Scalar1); const char title[] = "Empty Paths Drawn Into Rectangle Clips With " @@ -92,7 +92,8 @@ protected: SkColor color = rand.nextU(); - color = 0xff000000| color; // force solid + color = 0xff000000 | color; // force solid + sk_tool_utils::color_to_565(&color); this->drawEmpty(canvas, color, rect, gStyles[style].fStyle, gFills[fill].fFill); @@ -106,8 +107,7 @@ protected: SkPaint labelPaint; labelPaint.setColor(color); labelPaint.setAntiAlias(true); - sk_tool_utils::set_portable_typeface(&labelPaint); - labelPaint.setLCDRenderText(true); + sk_tool_utils::set_portable_typeface_always(&labelPaint); labelPaint.setTextSize(12 * SK_Scalar1); canvas->drawText(gStyles[style].fName, strlen(gStyles[style].fName), diff --git a/tools/sk_tool_utils.cpp b/tools/sk_tool_utils.cpp index 6fcd337..ec7942b 100644 --- a/tools/sk_tool_utils.cpp +++ b/tools/sk_tool_utils.cpp @@ -34,6 +34,12 @@ const char* colortype_name(SkColorType ct) { } } +void color_to_565(SkColor* color) { + SkPMColor pmColor = SkPreMultiplyColor(*color); + U16CPU color16 = SkPixel32ToPixel16(pmColor); + *color = SkPixel16ToColor(color16); +} + SkTypeface* create_portable_typeface(const char* name, SkTypeface::Style style) { SkTypeface* face; if (FLAGS_portableFonts) { diff --git a/tools/sk_tool_utils.h b/tools/sk_tool_utils.h index 484a810..4d4a5b4 100644 --- a/tools/sk_tool_utils.h +++ b/tools/sk_tool_utils.h @@ -24,6 +24,7 @@ class SkTextBlobBuilder; namespace sk_tool_utils { const char* colortype_name(SkColorType); + void color_to_565(SkColor* color); /** * Sets the paint to use a platform-independent text renderer if FLAGS_portableFonts is set.