| 363 | } |
| 364 | |
| 365 | void ScreenshotTool::draw(SkCanvas* canvas, const DrawData& drawData) { |
| 366 | if(controls.selectionMode == ScreenshotControls::SelectionMode::NO_SELECTION) { |
| 367 | SkPaint paint1; |
| 368 | paint1.setColor4f({0.0f, 0.0f, 0.0f, 0.3f}); |
| 369 | canvas->drawPaint(paint1); |
| 370 | } |
| 371 | else { |
| 372 | canvas->save(); |
| 373 | controls.coords.transform_sk_canvas(canvas, drawData); |
| 374 | float x1 = std::min(controls.rectX1, controls.rectX2); |
| 375 | float x2 = std::max(controls.rectX1, controls.rectX2); |
| 376 | float y1 = std::min(controls.rectY1, controls.rectY2); |
| 377 | float y2 = std::max(controls.rectY1, controls.rectY2); |
| 378 | SkPoint p1{x1, y1}; |
| 379 | SkPoint p2{x2, y2}; |
| 380 | SkPathBuilder path1B; |
| 381 | path1B.addRect(SkRect::MakeLTRB(p1.x(), p1.y(), p2.x(), p2.y())); |
| 382 | path1B.setFillType(SkPathFillType::kInverseWinding); |
| 383 | SkPath path1 = path1B.detach(); |
| 384 | SkPaint paint1; |
| 385 | paint1.setColor4f({0.0f, 0.0f, 0.0f, 0.3f}); |
| 386 | canvas->drawPath(path1, paint1); |
| 387 | |
| 388 | path1.setFillType(SkPathFillType::kWinding); |
| 389 | SkPaint paint2; |
| 390 | paint2.setColor4f({1.0f, 1.0f, 1.0f, 0.9f}); |
| 391 | paint2.setStyle(SkPaint::kStroke_Style); |
| 392 | canvas->drawPath(path1, paint2); |
| 393 | |
| 394 | canvas->restore(); |
| 395 | |
| 396 | if(controls.selectionMode == ScreenshotControls::SelectionMode::SELECTION_EXISTS) { |
| 397 | paint2.setStyle(SkPaint::kFill_Style); |
| 398 | for(auto& circ : controls.circles) |
| 399 | drawP.draw_drag_circle(canvas, circ.pos, {0.1f, 0.9f, 0.9f, 1.0f}, drawData, 1.0f); |
| 400 | } |
| 401 | } |
| 402 | } |
nothing calls this directly
no test coverage detected