| 403 | } |
| 404 | |
| 405 | static void WritePathInternal(EncodeStream* stream, pag::PathHandle value) { |
| 406 | auto& points = value->points; |
| 407 | std::vector<float> pointList; |
| 408 | uint32_t index = 0; |
| 409 | auto lastPoint = Point::Make(0, 0); |
| 410 | Point control1{}, control2{}, point{}; |
| 411 | for (auto& verb : value->verbs) { |
| 412 | switch (verb) { |
| 413 | case PathDataVerb::Close: |
| 414 | stream->writeUBits(static_cast<uint32_t>(PathRecord::Close), 3); |
| 415 | break; |
| 416 | case PathDataVerb::MoveTo: |
| 417 | lastPoint = points[index++]; |
| 418 | stream->writeUBits(static_cast<uint32_t>(PathRecord::Move), 3); |
| 419 | pointList.push_back(lastPoint.x); |
| 420 | pointList.push_back(lastPoint.y); |
| 421 | break; |
| 422 | case PathDataVerb::LineTo: |
| 423 | point = points[index++]; |
| 424 | if (point.x == lastPoint.x) { |
| 425 | stream->writeUBits(static_cast<uint32_t>(PathRecord::VLine), 3); |
| 426 | pointList.push_back(point.y); |
| 427 | } else if (point.y == lastPoint.y) { |
| 428 | stream->writeUBits(static_cast<uint32_t>(PathRecord::HLine), 3); |
| 429 | pointList.push_back(point.x); |
| 430 | } else { |
| 431 | stream->writeUBits(static_cast<uint32_t>(PathRecord::Line), 3); |
| 432 | pointList.push_back(point.x); |
| 433 | pointList.push_back(point.y); |
| 434 | } |
| 435 | lastPoint = point; |
| 436 | break; |
| 437 | case PathDataVerb::CurveTo: |
| 438 | control1 = points[index++]; |
| 439 | control2 = points[index++]; |
| 440 | point = points[index++]; |
| 441 | if (control1 == lastPoint) { |
| 442 | stream->writeUBits(static_cast<uint32_t>(PathRecord::Curve01), 3); |
| 443 | pointList.push_back(control2.x); |
| 444 | pointList.push_back(control2.y); |
| 445 | pointList.push_back(point.x); |
| 446 | pointList.push_back(point.y); |
| 447 | lastPoint = point; |
| 448 | } else if (control2 == point) { |
| 449 | stream->writeUBits(static_cast<uint32_t>(PathRecord::Curve10), 3); |
| 450 | pointList.push_back(control1.x); |
| 451 | pointList.push_back(control1.y); |
| 452 | pointList.push_back(point.x); |
| 453 | pointList.push_back(point.y); |
| 454 | lastPoint = point; |
| 455 | } else { |
| 456 | stream->writeUBits(static_cast<uint32_t>(PathRecord::Curve11), 3); |
| 457 | pointList.push_back(control1.x); |
| 458 | pointList.push_back(control1.y); |
| 459 | pointList.push_back(control2.x); |
| 460 | pointList.push_back(control2.y); |
| 461 | pointList.push_back(point.x); |
| 462 | pointList.push_back(point.y); |
no test coverage detected