#define SKDEBUGCANVAS_ATTRIBUTE_MATRIX "matrix"
#define SKDEBUGCANVAS_ATTRIBUTE_DRAWDEPTHTRANS "drawDepthTranslation"
#define SKDEBUGCANVAS_ATTRIBUTE_COORDS "coords"
+#define SKDEBUGCANVAS_ATTRIBUTE_HINTING "hinting"
#define SKDEBUGCANVAS_ATTRIBUTE_BOUNDS "bounds"
#define SKDEBUGCANVAS_ATTRIBUTE_PAINT "paint"
#define SKDEBUGCANVAS_ATTRIBUTE_OUTER "outer"
#define SKDEBUGCANVAS_FILTERQUALITY_MEDIUM "medium"
#define SKDEBUGCANVAS_FILTERQUALITY_HIGH "high"
+#define SKDEBUGCANVAS_HINTING_NONE "none"
+#define SKDEBUGCANVAS_HINTING_SLIGHT "slight"
+#define SKDEBUGCANVAS_HINTING_NORMAL "normal"
+#define SKDEBUGCANVAS_HINTING_FULL "full"
+
typedef SkDrawCommand* (*FROM_JSON)(Json::Value&, UrlDataManager&);
static SkString* str_append(SkString* str, const SkRect& r) {
return success;
}
+static void apply_paint_hinting(const SkPaint& paint, Json::Value* target) {
+ SkPaint::Hinting hinting = paint.getHinting();
+ if (hinting != SkPaintDefaults_Hinting) {
+ switch (hinting) {
+ case SkPaint::kNo_Hinting:
+ (*target)[SKDEBUGCANVAS_ATTRIBUTE_HINTING] = SKDEBUGCANVAS_HINTING_NONE;
+ break;
+ case SkPaint::kSlight_Hinting:
+ (*target)[SKDEBUGCANVAS_ATTRIBUTE_HINTING] = SKDEBUGCANVAS_HINTING_SLIGHT;
+ break;
+ case SkPaint::kNormal_Hinting:
+ (*target)[SKDEBUGCANVAS_ATTRIBUTE_HINTING] = SKDEBUGCANVAS_HINTING_NORMAL;
+ break;
+ case SkPaint::kFull_Hinting:
+ (*target)[SKDEBUGCANVAS_ATTRIBUTE_HINTING] = SKDEBUGCANVAS_HINTING_FULL;
+ break;
+ }
+ }
+}
+
static void apply_paint_color(const SkPaint& paint, Json::Value* target) {
SkColor color = paint.getColor();
if (color != SK_ColorBLACK) {
SkPaintDefaults_TextSize);
store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextScaleX(), SK_Scalar1);
store_scalar(&result, SKDEBUGCANVAS_ATTRIBUTE_TEXTSCALEX, paint.getTextSkewX(), 0.0f);
+ apply_paint_hinting(paint, &result);
apply_paint_color(paint, &result);
apply_paint_style(paint, &result);
apply_paint_cap(paint, &result);
}
}
+static void extract_json_paint_hinting(Json::Value& jsonPaint, SkPaint* target) {
+ if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_HINTING)) {
+ const char* hinting = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_HINTING].asCString();
+ if (!strcmp(hinting, SKDEBUGCANVAS_HINTING_NONE)) {
+ target->setHinting(SkPaint::kNo_Hinting);
+ } else if (!strcmp(hinting, SKDEBUGCANVAS_HINTING_SLIGHT)) {
+ target->setHinting(SkPaint::kSlight_Hinting);
+ } else if (!strcmp(hinting, SKDEBUGCANVAS_HINTING_NORMAL)) {
+ target->setHinting(SkPaint::kNormal_Hinting);
+ } else if (!strcmp(hinting, SKDEBUGCANVAS_HINTING_FULL)) {
+ target->setHinting(SkPaint::kFull_Hinting);
+ }
+ }
+}
+
static void extract_json_paint_style(Json::Value& jsonPaint, SkPaint* target) {
if (jsonPaint.isMember(SKDEBUGCANVAS_ATTRIBUTE_STYLE)) {
const char* style = jsonPaint[SKDEBUGCANVAS_ATTRIBUTE_STYLE].asCString();
static void extract_json_paint(Json::Value& paint, UrlDataManager& urlDataManager,
SkPaint* result) {
+ extract_json_paint_hinting(paint, result);
extract_json_paint_color(paint, result);
extract_json_paint_shader(paint, urlDataManager, result);
extract_json_paint_patheffect(paint, urlDataManager, result);