OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkDrawCommand.h" | 8 #include "SkDrawCommand.h" |
9 | 9 |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 #define SKDEBUGCANVAS_ATTRIBUTE_FONT "font" | 90 #define SKDEBUGCANVAS_ATTRIBUTE_FONT "font" |
91 #define SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE "typeface" | 91 #define SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE "typeface" |
92 #define SKDEBUGCANVAS_ATTRIBUTE_CUBICS "cubics" | 92 #define SKDEBUGCANVAS_ATTRIBUTE_CUBICS "cubics" |
93 #define SKDEBUGCANVAS_ATTRIBUTE_COLORS "colors" | 93 #define SKDEBUGCANVAS_ATTRIBUTE_COLORS "colors" |
94 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS "textureCoords" | 94 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS "textureCoords" |
95 #define SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY "filterQuality" | 95 #define SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY "filterQuality" |
96 #define SKDEBUGCANVAS_ATTRIBUTE_STARTANGLE "startAngle" | 96 #define SKDEBUGCANVAS_ATTRIBUTE_STARTANGLE "startAngle" |
97 #define SKDEBUGCANVAS_ATTRIBUTE_SWEEPANGLE "sweepAngle" | 97 #define SKDEBUGCANVAS_ATTRIBUTE_SWEEPANGLE "sweepAngle" |
98 #define SKDEBUGCANVAS_ATTRIBUTE_USECENTER "useCenter" | 98 #define SKDEBUGCANVAS_ATTRIBUTE_USECENTER "useCenter" |
99 #define SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC "shortDesc" | 99 #define SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC "shortDesc" |
| 100 #define SKDEBUGCANVAS_ATTRIBUTE_UNIQUE_ID "uniqueID" |
| 101 #define SKDEBUGCANVAS_ATTRIBUTE_WIDTH "width" |
| 102 #define SKDEBUGCANVAS_ATTRIBUTE_HEIGHT "height" |
| 103 #define SKDEBUGCANVAS_ATTRIBUTE_ALPHA "alpha" |
100 | 104 |
101 #define SKDEBUGCANVAS_VERB_MOVE "move" | 105 #define SKDEBUGCANVAS_VERB_MOVE "move" |
102 #define SKDEBUGCANVAS_VERB_LINE "line" | 106 #define SKDEBUGCANVAS_VERB_LINE "line" |
103 #define SKDEBUGCANVAS_VERB_QUAD "quad" | 107 #define SKDEBUGCANVAS_VERB_QUAD "quad" |
104 #define SKDEBUGCANVAS_VERB_CUBIC "cubic" | 108 #define SKDEBUGCANVAS_VERB_CUBIC "cubic" |
105 #define SKDEBUGCANVAS_VERB_CONIC "conic" | 109 #define SKDEBUGCANVAS_VERB_CONIC "conic" |
106 #define SKDEBUGCANVAS_VERB_CLOSE "close" | 110 #define SKDEBUGCANVAS_VERB_CLOSE "close" |
107 | 111 |
108 #define SKDEBUGCANVAS_STYLE_FILL "fill" | 112 #define SKDEBUGCANVAS_STYLE_FILL "fill" |
109 #define SKDEBUGCANVAS_STYLE_STROKE "stroke" | 113 #define SKDEBUGCANVAS_STYLE_STROKE "stroke" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 #define SKDEBUGCANVAS_COLORTYPE_RGBA8888 "RGBA8888" | 153 #define SKDEBUGCANVAS_COLORTYPE_RGBA8888 "RGBA8888" |
150 #define SKDEBUGCANVAS_COLORTYPE_BGRA8888 "BGRA8888" | 154 #define SKDEBUGCANVAS_COLORTYPE_BGRA8888 "BGRA8888" |
151 #define SKDEBUGCANVAS_COLORTYPE_565 "565" | 155 #define SKDEBUGCANVAS_COLORTYPE_565 "565" |
152 #define SKDEBUGCANVAS_COLORTYPE_GRAY8 "Gray8" | 156 #define SKDEBUGCANVAS_COLORTYPE_GRAY8 "Gray8" |
153 #define SKDEBUGCANVAS_COLORTYPE_INDEX8 "Index8" | 157 #define SKDEBUGCANVAS_COLORTYPE_INDEX8 "Index8" |
154 #define SKDEBUGCANVAS_COLORTYPE_ALPHA8 "Alpha8" | 158 #define SKDEBUGCANVAS_COLORTYPE_ALPHA8 "Alpha8" |
155 | 159 |
156 #define SKDEBUGCANVAS_ALPHATYPE_OPAQUE "opaque" | 160 #define SKDEBUGCANVAS_ALPHATYPE_OPAQUE "opaque" |
157 #define SKDEBUGCANVAS_ALPHATYPE_PREMUL "premul" | 161 #define SKDEBUGCANVAS_ALPHATYPE_PREMUL "premul" |
158 #define SKDEBUGCANVAS_ALPHATYPE_UNPREMUL "unpremul" | 162 #define SKDEBUGCANVAS_ALPHATYPE_UNPREMUL "unpremul" |
| 163 #define SKDEBUGCANVAS_ALPHATYPE_UNKNOWN "unknown" |
159 | 164 |
160 #define SKDEBUGCANVAS_FILTERQUALITY_NONE "none" | 165 #define SKDEBUGCANVAS_FILTERQUALITY_NONE "none" |
161 #define SKDEBUGCANVAS_FILTERQUALITY_LOW "low" | 166 #define SKDEBUGCANVAS_FILTERQUALITY_LOW "low" |
162 #define SKDEBUGCANVAS_FILTERQUALITY_MEDIUM "medium" | 167 #define SKDEBUGCANVAS_FILTERQUALITY_MEDIUM "medium" |
163 #define SKDEBUGCANVAS_FILTERQUALITY_HIGH "high" | 168 #define SKDEBUGCANVAS_FILTERQUALITY_HIGH "high" |
164 | 169 |
165 #define SKDEBUGCANVAS_HINTING_NONE "none" | 170 #define SKDEBUGCANVAS_HINTING_NONE "none" |
166 #define SKDEBUGCANVAS_HINTING_SLIGHT "slight" | 171 #define SKDEBUGCANVAS_HINTING_SLIGHT "slight" |
167 #define SKDEBUGCANVAS_HINTING_NORMAL "normal" | 172 #define SKDEBUGCANVAS_HINTING_NORMAL "normal" |
168 #define SKDEBUGCANVAS_HINTING_FULL "full" | 173 #define SKDEBUGCANVAS_HINTING_FULL "full" |
(...skipping 1955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2124 | 2129 |
2125 Json::Value SkDrawImageCommand::toJSON(UrlDataManager& urlDataManager) const { | 2130 Json::Value SkDrawImageCommand::toJSON(UrlDataManager& urlDataManager) const { |
2126 Json::Value result = INHERITED::toJSON(urlDataManager); | 2131 Json::Value result = INHERITED::toJSON(urlDataManager); |
2127 Json::Value encoded; | 2132 Json::Value encoded; |
2128 if (flatten(*fImage, &encoded, urlDataManager)) { | 2133 if (flatten(*fImage, &encoded, urlDataManager)) { |
2129 result[SKDEBUGCANVAS_ATTRIBUTE_IMAGE] = encoded; | 2134 result[SKDEBUGCANVAS_ATTRIBUTE_IMAGE] = encoded; |
2130 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonPoint(fLeft, fTop); | 2135 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonPoint(fLeft, fTop); |
2131 if (fPaint.isValid()) { | 2136 if (fPaint.isValid()) { |
2132 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaint.get(),
urlDataManager); | 2137 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(*fPaint.get(),
urlDataManager); |
2133 } | 2138 } |
| 2139 |
| 2140 result[SKDEBUGCANVAS_ATTRIBUTE_UNIQUE_ID] = fImage->uniqueID(); |
| 2141 result[SKDEBUGCANVAS_ATTRIBUTE_WIDTH] = fImage->width(); |
| 2142 result[SKDEBUGCANVAS_ATTRIBUTE_HEIGHT] = fImage->height(); |
| 2143 switch (fImage->alphaType()) { |
| 2144 case kOpaque_SkAlphaType: |
| 2145 result[SKDEBUGCANVAS_ATTRIBUTE_ALPHA] = SKDEBUGCANVAS_ALPHATYPE_
OPAQUE; |
| 2146 break; |
| 2147 case kPremul_SkAlphaType: |
| 2148 result[SKDEBUGCANVAS_ATTRIBUTE_ALPHA] = SKDEBUGCANVAS_ALPHATYPE_
PREMUL; |
| 2149 break; |
| 2150 case kUnpremul_SkAlphaType: |
| 2151 result[SKDEBUGCANVAS_ATTRIBUTE_ALPHA] = SKDEBUGCANVAS_ALPHATYPE_
UNPREMUL; |
| 2152 break; |
| 2153 default: |
| 2154 result[SKDEBUGCANVAS_ATTRIBUTE_ALPHA] = SKDEBUGCANVAS_ALPHATYPE_
UNKNOWN; |
| 2155 break; |
| 2156 } |
2134 } | 2157 } |
2135 return result; | 2158 return result; |
2136 } | 2159 } |
2137 | 2160 |
2138 SkDrawImageCommand* SkDrawImageCommand::fromJSON(Json::Value& command, | 2161 SkDrawImageCommand* SkDrawImageCommand::fromJSON(Json::Value& command, |
2139 UrlDataManager& urlDataManager)
{ | 2162 UrlDataManager& urlDataManager)
{ |
2140 sk_sp<SkImage> image = load_image(command[SKDEBUGCANVAS_ATTRIBUTE_IMAGE], ur
lDataManager); | 2163 sk_sp<SkImage> image = load_image(command[SKDEBUGCANVAS_ATTRIBUTE_IMAGE], ur
lDataManager); |
2141 if (image == nullptr) { | 2164 if (image == nullptr) { |
2142 return nullptr; | 2165 return nullptr; |
2143 } | 2166 } |
(...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3525 SkTranslateZCommand* SkTranslateZCommand::fromJSON(Json::Value& command, | 3548 SkTranslateZCommand* SkTranslateZCommand::fromJSON(Json::Value& command, |
3526 UrlDataManager& urlDataManager) { | 3549 UrlDataManager& urlDataManager) { |
3527 SkScalar z; | 3550 SkScalar z; |
3528 #ifdef SK_EXPERIMENTAL_SHADOWING | 3551 #ifdef SK_EXPERIMENTAL_SHADOWING |
3529 extract_json_scalar(command[SKDEBUGCANVAS_ATTRIBUTE_DRAWDEPTHTRANS], &z); | 3552 extract_json_scalar(command[SKDEBUGCANVAS_ATTRIBUTE_DRAWDEPTHTRANS], &z); |
3530 #else | 3553 #else |
3531 z = 0; | 3554 z = 0; |
3532 #endif | 3555 #endif |
3533 return new SkTranslateZCommand(z); | 3556 return new SkTranslateZCommand(z); |
3534 } | 3557 } |
OLD | NEW |