diff --git a/laf b/laf index 5667a0334..ff3146071 160000 --- a/laf +++ b/laf @@ -1 +1 @@ -Subproject commit 5667a0334d0d04eb50aa935e7dafe1d4e0fa025b +Subproject commit ff3146071e86db059af6eef64fd24096554fa15e diff --git a/src/app/script/canvas_widget.cpp b/src/app/script/canvas_widget.cpp index 2640a6258..228865995 100644 --- a/src/app/script/canvas_widget.cpp +++ b/src/app/script/canvas_widget.cpp @@ -16,10 +16,6 @@ #include "ui/size_hint_event.h" #include "ui/system.h" -#ifdef LAF_SKIA - #include "os/skia/skia_color_space.h" -#endif - namespace app { namespace script { // static @@ -50,14 +46,8 @@ void Canvas::callPaint() return; os::Paint p; -#ifdef LAF_SKIA - if (m_surface && m_surface->colorSpace()) - p.color(bgColor(), m_surface->colorSpace().get()); - else -#else - p.color(bgColor()); -#endif - m_surface->drawRect(m_surface->bounds(), p); + p.color(bgColor(), m_surface->colorSpace().get()); + m_surface->drawRect(m_surface->bounds(), p); // Draw only on resize (onPaint we draw the cached m_surface) GraphicsContext gc(m_surface, m_autoScaling ? ui::guiscale() : 1); diff --git a/src/ui/graphics.cpp b/src/ui/graphics.cpp index cf5b8924d..6ca437947 100644 --- a/src/ui/graphics.cpp +++ b/src/ui/graphics.cpp @@ -155,12 +155,7 @@ void Graphics::drawHLine(gfx::Color color, int x, int y, int w) os::SurfaceLock lock(m_surface.get()); os::Paint paint; -#ifdef LAF_SKIA - if (m_surface && m_surface->colorSpace()) - paint.color(color, m_surface->colorSpace().get()); - else -#endif - paint.color(color); + paint.color(color, colorSpace()); m_surface->drawRect(gfx::Rect(m_dx + x, m_dy + y, w, 1), paint); } @@ -178,12 +173,7 @@ void Graphics::drawVLine(gfx::Color color, int x, int y, int h) os::SurfaceLock lock(m_surface.get()); os::Paint paint; -#ifdef LAF_SKIA - if (m_surface && m_surface->colorSpace()) - paint.color(color, m_surface->colorSpace().get()); - else -#endif - paint.color(color); + paint.color(color, colorSpace()); m_surface->drawRect(gfx::Rect(m_dx + x, m_dy + y, 1, h), paint); } @@ -195,12 +185,7 @@ void Graphics::drawLine(gfx::Color color, const gfx::Point& _a, const gfx::Point os::SurfaceLock lock(m_surface.get()); os::Paint paint; -#ifdef LAF_SKIA - if (m_surface && m_surface->colorSpace()) - paint.color(color, m_surface->colorSpace().get()); - else -#endif - paint.color(color); + paint.color(color, colorSpace()); m_surface->drawLine(a, b, paint); } @@ -257,12 +242,7 @@ void Graphics::drawRect(gfx::Color color, const gfx::Rect& rcOrig) os::SurfaceLock lock(m_surface.get()); os::Paint paint; -#ifdef LAF_SKIA - if (m_surface && m_surface->colorSpace()) - paint.color(color, m_surface->colorSpace().get()); - else -#endif - paint.color(color); + paint.color(color, colorSpace()); paint.style(os::Paint::Stroke); m_surface->drawRect(rc, paint); } @@ -275,12 +255,7 @@ void Graphics::fillRect(gfx::Color color, const gfx::Rect& rcOrig) os::SurfaceLock lock(m_surface.get()); os::Paint paint; -#ifdef LAF_SKIA - if (m_surface && m_surface->colorSpace()) - paint.color(color, m_surface->colorSpace().get()); - else -#endif - paint.color(color); + paint.color(color, colorSpace()); paint.style(os::Paint::Fill); m_surface->drawRect(rc, paint); } @@ -468,21 +443,12 @@ void Graphics::drawUIText(const std::string& str, auto textBlob = text::TextBlob::MakeWithShaper(fontMgr, m_font, str); Paint paint; -#ifdef LAF_SKIA if (gfx::geta(bg) > 0) { // Paint background - paint.color(bg, m_surface->colorSpace().get()); + paint.color(bg, colorSpace()); paint.style(os::Paint::Fill); drawRect(gfx::RectF(textBlob->bounds()).offset(pt), paint); } - paint.color(fg, m_surface->colorSpace().get()); -#else - if (gfx::geta(bg) > 0) { // Paint background - paint.color(bg); - paint.style(os::Paint::Fill); - drawRect(gfx::RectF(textBlob->bounds()).offset(pt), paint); - } - paint.color(fg); -#endif + paint.color(fg, colorSpace()); drawTextBlob(textBlob, gfx::PointF(pt), paint); @@ -636,19 +602,11 @@ gfx::Size Graphics::doUIStringAlgorithm(const std::string& str, Paint paint; paint.style(os::Paint::Fill); -#ifdef LAF_SKIA if (!gfx::is_transparent(bg)) { - paint.color(bg, m_surface->colorSpace().get()); + paint.color(bg, colorSpace()); drawRect(gfx::RectF(xout, pt.y, rc.w, lineSize.h), paint); } - paint.color(fg, m_surface->colorSpace().get()); -#else - if (!gfx::is_transparent(bg)) { - paint.color(bg); - drawRect(gfx::RectF(xout, pt.y, rc.w, lineSize.h), paint); - } - paint.color(fg); -#endif + paint.color(fg, colorSpace()); float baselineDelta = -metrics.ascent - lineBlob->baseline(); drawTextBlob(lineBlob, gfx::PointF(xout, pt.y + baselineDelta), paint); diff --git a/src/ui/graphics.h b/src/ui/graphics.h index 8b08b717a..c7c5be53d 100644 --- a/src/ui/graphics.h +++ b/src/ui/graphics.h @@ -48,6 +48,8 @@ public: int height() const; os::Surface* getInternalSurface() { return m_surface.get(); } + os::ColorSpace* colorSpace() { return m_surface->colorSpace().get(); } + int getInternalDeltaX() { return m_dx; } int getInternalDeltaY() { return m_dy; }