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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 #define SKDEBUGCANVAS_ATTRIBUTE_Y "y" | 85 #define SKDEBUGCANVAS_ATTRIBUTE_Y "y" |
86 #define SKDEBUGCANVAS_ATTRIBUTE_RUNS "runs" | 86 #define SKDEBUGCANVAS_ATTRIBUTE_RUNS "runs" |
87 #define SKDEBUGCANVAS_ATTRIBUTE_POSITIONS "positions" | 87 #define SKDEBUGCANVAS_ATTRIBUTE_POSITIONS "positions" |
88 #define SKDEBUGCANVAS_ATTRIBUTE_GLYPHS "glyphs" | 88 #define SKDEBUGCANVAS_ATTRIBUTE_GLYPHS "glyphs" |
89 #define SKDEBUGCANVAS_ATTRIBUTE_FONT "font" | 89 #define SKDEBUGCANVAS_ATTRIBUTE_FONT "font" |
90 #define SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE "typeface" | 90 #define SKDEBUGCANVAS_ATTRIBUTE_TYPEFACE "typeface" |
91 #define SKDEBUGCANVAS_ATTRIBUTE_CUBICS "cubics" | 91 #define SKDEBUGCANVAS_ATTRIBUTE_CUBICS "cubics" |
92 #define SKDEBUGCANVAS_ATTRIBUTE_COLORS "colors" | 92 #define SKDEBUGCANVAS_ATTRIBUTE_COLORS "colors" |
93 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS "textureCoords" | 93 #define SKDEBUGCANVAS_ATTRIBUTE_TEXTURECOORDS "textureCoords" |
94 #define SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY "filterQuality" | 94 #define SKDEBUGCANVAS_ATTRIBUTE_FILTERQUALITY "filterQuality" |
95 | 95 #define SKDEBUGCANVAS_ATTRIBUTE_STARTANGLE "startAngle" |
| 96 #define SKDEBUGCANVAS_ATTRIBUTE_SWEEPANGLE "sweepAngle" |
| 97 #define SKDEBUGCANVAS_ATTRIBUTE_USECENTER "useCenter" |
96 #define SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC "shortDesc" | 98 #define SKDEBUGCANVAS_ATTRIBUTE_SHORTDESC "shortDesc" |
97 | 99 |
98 #define SKDEBUGCANVAS_VERB_MOVE "move" | 100 #define SKDEBUGCANVAS_VERB_MOVE "move" |
99 #define SKDEBUGCANVAS_VERB_LINE "line" | 101 #define SKDEBUGCANVAS_VERB_LINE "line" |
100 #define SKDEBUGCANVAS_VERB_QUAD "quad" | 102 #define SKDEBUGCANVAS_VERB_QUAD "quad" |
101 #define SKDEBUGCANVAS_VERB_CUBIC "cubic" | 103 #define SKDEBUGCANVAS_VERB_CUBIC "cubic" |
102 #define SKDEBUGCANVAS_VERB_CONIC "conic" | 104 #define SKDEBUGCANVAS_VERB_CONIC "conic" |
103 #define SKDEBUGCANVAS_VERB_CLOSE "close" | 105 #define SKDEBUGCANVAS_VERB_CLOSE "close" |
104 | 106 |
105 #define SKDEBUGCANVAS_STYLE_FILL "fill" | 107 #define SKDEBUGCANVAS_STYLE_FILL "fill" |
(...skipping 2147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2253 | 2255 |
2254 SkDrawOvalCommand* SkDrawOvalCommand::fromJSON(Json::Value& command, | 2256 SkDrawOvalCommand* SkDrawOvalCommand::fromJSON(Json::Value& command, |
2255 UrlDataManager& urlDataManager) { | 2257 UrlDataManager& urlDataManager) { |
2256 SkRect coords; | 2258 SkRect coords; |
2257 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords); | 2259 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords); |
2258 SkPaint paint; | 2260 SkPaint paint; |
2259 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); | 2261 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
2260 return new SkDrawOvalCommand(coords, paint); | 2262 return new SkDrawOvalCommand(coords, paint); |
2261 } | 2263 } |
2262 | 2264 |
| 2265 SkDrawArcCommand::SkDrawArcCommand(const SkRect& oval, SkScalar startAngle, SkSc
alar sweepAngle, |
| 2266 bool useCenter, const SkPaint& paint) |
| 2267 : INHERITED(kDrawOval_OpType) { |
| 2268 fOval = oval; |
| 2269 fStartAngle = startAngle; |
| 2270 fSweepAngle = sweepAngle; |
| 2271 fUseCenter = useCenter; |
| 2272 fPaint = paint; |
| 2273 |
| 2274 fInfo.push(SkObjectParser::RectToString(oval)); |
| 2275 fInfo.push(SkObjectParser::ScalarToString(startAngle, "StartAngle: ")); |
| 2276 fInfo.push(SkObjectParser::ScalarToString(sweepAngle, "SweepAngle: ")); |
| 2277 fInfo.push(SkObjectParser::BoolToString(useCenter)); |
| 2278 fInfo.push(SkObjectParser::PaintToString(paint)); |
| 2279 } |
| 2280 |
| 2281 void SkDrawArcCommand::execute(SkCanvas* canvas) const { |
| 2282 canvas->drawArc(fOval, fStartAngle, fSweepAngle, fUseCenter, fPaint); |
| 2283 } |
| 2284 |
| 2285 bool SkDrawArcCommand::render(SkCanvas* canvas) const { |
| 2286 canvas->clear(0xFFFFFFFF); |
| 2287 canvas->save(); |
| 2288 |
| 2289 xlate_and_scale_to_bounds(canvas, fOval); |
| 2290 |
| 2291 SkPaint p; |
| 2292 p.setColor(SK_ColorBLACK); |
| 2293 p.setStyle(SkPaint::kStroke_Style); |
| 2294 |
| 2295 canvas->drawArc(fOval, fStartAngle, fSweepAngle, fUseCenter, p); |
| 2296 canvas->restore(); |
| 2297 |
| 2298 return true; |
| 2299 } |
| 2300 |
| 2301 Json::Value SkDrawArcCommand::toJSON(UrlDataManager& urlDataManager) const { |
| 2302 Json::Value result = INHERITED::toJSON(urlDataManager); |
| 2303 result[SKDEBUGCANVAS_ATTRIBUTE_COORDS] = MakeJsonRect(fOval); |
| 2304 result[SKDEBUGCANVAS_ATTRIBUTE_STARTANGLE] = MakeJsonScalar(fStartAngle); |
| 2305 result[SKDEBUGCANVAS_ATTRIBUTE_SWEEPANGLE] = MakeJsonScalar(fSweepAngle); |
| 2306 result[SKDEBUGCANVAS_ATTRIBUTE_USECENTER] = fUseCenter; |
| 2307 result[SKDEBUGCANVAS_ATTRIBUTE_PAINT] = MakeJsonPaint(fPaint, urlDataManager
); |
| 2308 return result; |
| 2309 } |
| 2310 |
| 2311 SkDrawArcCommand* SkDrawArcCommand::fromJSON(Json::Value& command, |
| 2312 UrlDataManager& urlDataManager) { |
| 2313 SkRect coords; |
| 2314 extract_json_rect(command[SKDEBUGCANVAS_ATTRIBUTE_COORDS], &coords); |
| 2315 SkScalar startAngle = command[SKDEBUGCANVAS_ATTRIBUTE_STARTANGLE].asFloat(); |
| 2316 SkScalar sweepAngle = command[SKDEBUGCANVAS_ATTRIBUTE_SWEEPANGLE].asFloat(); |
| 2317 bool useCenter = command[SKDEBUGCANVAS_ATTRIBUTE_USECENTER].asBool(); |
| 2318 SkPaint paint; |
| 2319 extract_json_paint(command[SKDEBUGCANVAS_ATTRIBUTE_PAINT], urlDataManager, &
paint); |
| 2320 return new SkDrawArcCommand(coords, startAngle, sweepAngle, useCenter, paint
); |
| 2321 } |
| 2322 |
2263 SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint) | 2323 SkDrawPaintCommand::SkDrawPaintCommand(const SkPaint& paint) |
2264 : INHERITED(kDrawPaint_OpType) { | 2324 : INHERITED(kDrawPaint_OpType) { |
2265 fPaint = paint; | 2325 fPaint = paint; |
2266 | 2326 |
2267 fInfo.push(SkObjectParser::PaintToString(paint)); | 2327 fInfo.push(SkObjectParser::PaintToString(paint)); |
2268 } | 2328 } |
2269 | 2329 |
2270 void SkDrawPaintCommand::execute(SkCanvas* canvas) const { | 2330 void SkDrawPaintCommand::execute(SkCanvas* canvas) const { |
2271 canvas->drawPaint(fPaint); | 2331 canvas->drawPaint(fPaint); |
2272 } | 2332 } |
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3399 SkTranslateZCommand* SkTranslateZCommand::fromJSON(Json::Value& command, | 3459 SkTranslateZCommand* SkTranslateZCommand::fromJSON(Json::Value& command, |
3400 UrlDataManager& urlDataManager) { | 3460 UrlDataManager& urlDataManager) { |
3401 SkScalar z; | 3461 SkScalar z; |
3402 #ifdef SK_EXPERIMENTAL_SHADOWING | 3462 #ifdef SK_EXPERIMENTAL_SHADOWING |
3403 extract_json_scalar(command[SKDEBUGCANVAS_ATTRIBUTE_DRAWDEPTHTRANS], &z); | 3463 extract_json_scalar(command[SKDEBUGCANVAS_ATTRIBUTE_DRAWDEPTHTRANS], &z); |
3404 #else | 3464 #else |
3405 z = 0; | 3465 z = 0; |
3406 #endif | 3466 #endif |
3407 return new SkTranslateZCommand(z); | 3467 return new SkTranslateZCommand(z); |
3408 } | 3468 } |
OLD | NEW |