Added None and Skia antialiasing options in debug menu
This commit is contained in:
parent
30fdec05c1
commit
d973bde4be
50 changed files with 177 additions and 93 deletions
|
|
@ -512,7 +512,7 @@ bool DrawingProgram::prevent_undo_or_redo() {
|
|||
return drawTool->prevent_undo_or_redo();
|
||||
}
|
||||
|
||||
SkPaint DrawingProgram::select_tool_line_paint() {
|
||||
SkPaint DrawingProgram::select_tool_line_paint(const DrawData& drawData) {
|
||||
SkScalar intervals[] = {10, 5};
|
||||
float timeSinceEpoch = std::chrono::duration_cast<std::chrono::duration<float>>(std::chrono::steady_clock::now().time_since_epoch()).count();
|
||||
sk_sp<SkPathEffect> lassoLineDashEffect = SkDashPathEffect::Make({intervals, 2}, -std::fmod(timeSinceEpoch * 50, 15));
|
||||
|
|
@ -523,6 +523,7 @@ SkPaint DrawingProgram::select_tool_line_paint() {
|
|||
selectLinePaint.setColor4f(world.canvasTheme.get_tool_front_color());
|
||||
selectLinePaint.setPathEffect(lassoLineDashEffect);
|
||||
selectLinePaint.setBlender(CanvasTheme::get_visible_blend_mode());
|
||||
selectLinePaint.setAntiAlias(drawData.skiaAA);
|
||||
|
||||
return selectLinePaint;
|
||||
}
|
||||
|
|
@ -648,6 +649,7 @@ void DrawingProgram::draw_drag_circle(SkCanvas* canvas, const Vector2f& sPos, co
|
|||
SkPaint paintOutline(SkColor4f{0.95f, 0.95f, 0.95f, 1.0f});
|
||||
paintOutline.setStroke(true);
|
||||
paintOutline.setStrokeWidth(constantThickness);
|
||||
paintOutline.setAntiAlias(drawData.skiaAA);
|
||||
canvas->drawCircle(sPos.x(), sPos.y(), constantRadius, paintOutline);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class DrawingProgram {
|
|||
|
||||
float drag_point_radius();
|
||||
void draw_drag_circle(SkCanvas* canvas, const Vector2f& pos, const SkColor4f& c, const DrawData& drawData, float radiusMultiplier = 1.0f);
|
||||
SkPaint select_tool_line_paint();
|
||||
SkPaint select_tool_line_paint(const DrawData& drawData);
|
||||
bool is_actual_selection_tool(DrawingProgramToolType typeToCheck);
|
||||
bool is_selection_allowing_tool(DrawingProgramToolType typeToCheck);
|
||||
|
||||
|
|
|
|||
|
|
@ -327,7 +327,6 @@ void DrawingProgramCache::refresh_draw_cache(const std::shared_ptr<DrawingProgra
|
|||
void DrawingProgramCache::allocate_window_cache_area() {
|
||||
const Vector2i& windowSize = drawP.world.main.window.size;
|
||||
windowCache.surface = drawP.world.main.create_native_surface(windowSize, true);
|
||||
windowCache.size = windowSize;
|
||||
}
|
||||
|
||||
void DrawingProgramCache::update_window_cache_invalid_bounds(const DrawData& drawData) {
|
||||
|
|
@ -366,7 +365,7 @@ void DrawingProgramCache::window_cache_complete_refresh(const DrawData& drawData
|
|||
}
|
||||
|
||||
void DrawingProgramCache::update_and_draw_cached_canvas(SkCanvas* canvas, const DrawData& drawData) {
|
||||
if(windowCache.surface == nullptr || drawData.main->window.size != windowCache.size) {
|
||||
if(windowCache.surface == nullptr) {
|
||||
allocate_window_cache_area();
|
||||
refresh_all_draw_cache(drawData);
|
||||
window_cache_complete_refresh(drawData);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ class DrawingProgramCache {
|
|||
sk_sp<SkSurface> surface;
|
||||
DrawingProgramCache* attachedDrawingProgramCache = nullptr;
|
||||
std::optional<SCollision::AABB<WorldScalar>> invalidBounds;
|
||||
Vector2i size = {0, 0};
|
||||
CoordSpaceHelper coords;
|
||||
};
|
||||
static WindowCache windowCache;
|
||||
|
|
|
|||
|
|
@ -195,6 +195,7 @@ void BrushTool::draw(SkCanvas* canvas, const DrawData& drawData) {
|
|||
width += 1.0f;
|
||||
Vector2f pos = drawData.main->input.mouse.pos;
|
||||
SkPaint linePaint;
|
||||
linePaint.setAntiAlias(drawData.skiaAA);
|
||||
linePaint.setColor4f({1.0f, 1.0f, 1.0f, 1.0f});
|
||||
linePaint.setStyle(SkPaint::kStroke_Style);
|
||||
linePaint.setStrokeCap(SkPaint::kRound_Cap);
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ void EraserTool::draw(SkCanvas* canvas, const DrawData& drawData) {
|
|||
if(relativeWidthResult.first.has_value()) {
|
||||
float width = relativeWidthResult.first.value() * 0.5f;
|
||||
SkPaint linePaint;
|
||||
linePaint.setAntiAlias(drawData.skiaAA);
|
||||
linePaint.setColor4f({1.0f, 1.0f, 1.0f, 0.5f});
|
||||
linePaint.setStyle(SkPaint::kStroke_Style);
|
||||
linePaint.setStrokeCap(SkPaint::kRound_Cap);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ void EyeDropperTool::input_mouse_button_on_canvas_callback(const InputManager::M
|
|||
auto& selectingStrokeColor = drawP.world.main.toolConfig.eyeDropper.selectingStrokeColor;
|
||||
|
||||
if(button.button == InputManager::MouseButton::LEFT && button.down && !drawP.selection.is_being_transformed()) {
|
||||
auto& surface = drawP.world.main.window.surface;
|
||||
auto& surface = drawP.world.main.window.intermediateSurface;
|
||||
|
||||
int xPos = std::clamp<int>(button.pos.x(), 0, drawP.world.main.window.size.x() - 1);
|
||||
int yPos = std::clamp<int>(button.pos.y(), 0, drawP.world.main.window.size.y() - 1);
|
||||
|
|
|
|||
|
|
@ -184,6 +184,7 @@ void GridModifyTool::draw(SkCanvas* canvas, const DrawData& drawData) {
|
|||
rectBoundsPaint.setColor4f(drawP.world.canvasTheme.get_tool_front_color());
|
||||
rectBoundsPaint.setStroke(true);
|
||||
rectBoundsPaint.setStrokeWidth(0.0f);
|
||||
rectBoundsPaint.setAntiAlias(drawData.skiaAA);
|
||||
canvas->drawRect(SkRect::MakeLTRB(bMin.x(), bMin.y(), bMax.x(), bMax.y()), rectBoundsPaint);
|
||||
if(selectionMode == 0 || selectionMode == 4)
|
||||
drawP.draw_drag_circle(canvas, bMax, {0.9f, 0.5f, 0.1f, 1.0f}, drawData);
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ void LassoSelectTool::draw(SkCanvas* canvas, const DrawData& drawData) {
|
|||
for(Vector2f& p : controls.lassoPoints | std::views::drop(1))
|
||||
lassoPath.lineTo(convert_vec2<SkPoint>(p));
|
||||
|
||||
canvas->drawPath(lassoPath.detach(), drawP.select_tool_line_paint());
|
||||
canvas->drawPath(lassoPath.detach(), drawP.select_tool_line_paint(drawData));
|
||||
|
||||
canvas->restore();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ void RectSelectTool::draw(SkCanvas* canvas, const DrawData& drawData) {
|
|||
controls.coords.transform_sk_canvas(canvas, drawData);
|
||||
|
||||
SkRect r = SkRect::MakeLTRB(newT[0].x(), newT[0].y(), newT[2].x(), newT[2].y());
|
||||
canvas->drawRect(r, drawP.select_tool_line_paint());
|
||||
canvas->drawRect(r, drawP.select_tool_line_paint(drawData));
|
||||
|
||||
canvas->restore();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue