mirror of https://github.com/aseprite/aseprite.git
Now Paint::color() can receive a color space w/any laf backend
This commit is contained in:
parent
fae42dbe12
commit
d7b07a5173
2
laf
2
laf
|
@ -1 +1 @@
|
||||||
Subproject commit 5667a0334d0d04eb50aa935e7dafe1d4e0fa025b
|
Subproject commit ff3146071e86db059af6eef64fd24096554fa15e
|
|
@ -16,10 +16,6 @@
|
||||||
#include "ui/size_hint_event.h"
|
#include "ui/size_hint_event.h"
|
||||||
#include "ui/system.h"
|
#include "ui/system.h"
|
||||||
|
|
||||||
#ifdef LAF_SKIA
|
|
||||||
#include "os/skia/skia_color_space.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace app { namespace script {
|
namespace app { namespace script {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
@ -50,13 +46,7 @@ void Canvas::callPaint()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
os::Paint p;
|
os::Paint p;
|
||||||
#ifdef LAF_SKIA
|
|
||||||
if (m_surface && m_surface->colorSpace())
|
|
||||||
p.color(bgColor(), m_surface->colorSpace().get());
|
p.color(bgColor(), m_surface->colorSpace().get());
|
||||||
else
|
|
||||||
#else
|
|
||||||
p.color(bgColor());
|
|
||||||
#endif
|
|
||||||
m_surface->drawRect(m_surface->bounds(), p);
|
m_surface->drawRect(m_surface->bounds(), p);
|
||||||
|
|
||||||
// Draw only on resize (onPaint we draw the cached m_surface)
|
// Draw only on resize (onPaint we draw the cached m_surface)
|
||||||
|
|
|
@ -155,12 +155,7 @@ void Graphics::drawHLine(gfx::Color color, int x, int y, int w)
|
||||||
|
|
||||||
os::SurfaceLock lock(m_surface.get());
|
os::SurfaceLock lock(m_surface.get());
|
||||||
os::Paint paint;
|
os::Paint paint;
|
||||||
#ifdef LAF_SKIA
|
paint.color(color, colorSpace());
|
||||||
if (m_surface && m_surface->colorSpace())
|
|
||||||
paint.color(color, m_surface->colorSpace().get());
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
paint.color(color);
|
|
||||||
m_surface->drawRect(gfx::Rect(m_dx + x, m_dy + y, w, 1), paint);
|
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::SurfaceLock lock(m_surface.get());
|
||||||
os::Paint paint;
|
os::Paint paint;
|
||||||
#ifdef LAF_SKIA
|
paint.color(color, colorSpace());
|
||||||
if (m_surface && m_surface->colorSpace())
|
|
||||||
paint.color(color, m_surface->colorSpace().get());
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
paint.color(color);
|
|
||||||
m_surface->drawRect(gfx::Rect(m_dx + x, m_dy + y, 1, h), paint);
|
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::SurfaceLock lock(m_surface.get());
|
||||||
os::Paint paint;
|
os::Paint paint;
|
||||||
#ifdef LAF_SKIA
|
paint.color(color, colorSpace());
|
||||||
if (m_surface && m_surface->colorSpace())
|
|
||||||
paint.color(color, m_surface->colorSpace().get());
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
paint.color(color);
|
|
||||||
m_surface->drawLine(a, b, paint);
|
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::SurfaceLock lock(m_surface.get());
|
||||||
os::Paint paint;
|
os::Paint paint;
|
||||||
#ifdef LAF_SKIA
|
paint.color(color, colorSpace());
|
||||||
if (m_surface && m_surface->colorSpace())
|
|
||||||
paint.color(color, m_surface->colorSpace().get());
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
paint.color(color);
|
|
||||||
paint.style(os::Paint::Stroke);
|
paint.style(os::Paint::Stroke);
|
||||||
m_surface->drawRect(rc, paint);
|
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::SurfaceLock lock(m_surface.get());
|
||||||
os::Paint paint;
|
os::Paint paint;
|
||||||
#ifdef LAF_SKIA
|
paint.color(color, colorSpace());
|
||||||
if (m_surface && m_surface->colorSpace())
|
|
||||||
paint.color(color, m_surface->colorSpace().get());
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
paint.color(color);
|
|
||||||
paint.style(os::Paint::Fill);
|
paint.style(os::Paint::Fill);
|
||||||
m_surface->drawRect(rc, paint);
|
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);
|
auto textBlob = text::TextBlob::MakeWithShaper(fontMgr, m_font, str);
|
||||||
|
|
||||||
Paint paint;
|
Paint paint;
|
||||||
#ifdef LAF_SKIA
|
|
||||||
if (gfx::geta(bg) > 0) { // Paint background
|
if (gfx::geta(bg) > 0) { // Paint background
|
||||||
paint.color(bg, m_surface->colorSpace().get());
|
paint.color(bg, colorSpace());
|
||||||
paint.style(os::Paint::Fill);
|
paint.style(os::Paint::Fill);
|
||||||
drawRect(gfx::RectF(textBlob->bounds()).offset(pt), paint);
|
drawRect(gfx::RectF(textBlob->bounds()).offset(pt), paint);
|
||||||
}
|
}
|
||||||
paint.color(fg, m_surface->colorSpace().get());
|
paint.color(fg, colorSpace());
|
||||||
#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
|
|
||||||
|
|
||||||
drawTextBlob(textBlob, gfx::PointF(pt), paint);
|
drawTextBlob(textBlob, gfx::PointF(pt), paint);
|
||||||
|
|
||||||
|
@ -636,19 +602,11 @@ gfx::Size Graphics::doUIStringAlgorithm(const std::string& str,
|
||||||
|
|
||||||
Paint paint;
|
Paint paint;
|
||||||
paint.style(os::Paint::Fill);
|
paint.style(os::Paint::Fill);
|
||||||
#ifdef LAF_SKIA
|
|
||||||
if (!gfx::is_transparent(bg)) {
|
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);
|
drawRect(gfx::RectF(xout, pt.y, rc.w, lineSize.h), paint);
|
||||||
}
|
}
|
||||||
paint.color(fg, m_surface->colorSpace().get());
|
paint.color(fg, colorSpace());
|
||||||
#else
|
|
||||||
if (!gfx::is_transparent(bg)) {
|
|
||||||
paint.color(bg);
|
|
||||||
drawRect(gfx::RectF(xout, pt.y, rc.w, lineSize.h), paint);
|
|
||||||
}
|
|
||||||
paint.color(fg);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
float baselineDelta = -metrics.ascent - lineBlob->baseline();
|
float baselineDelta = -metrics.ascent - lineBlob->baseline();
|
||||||
drawTextBlob(lineBlob, gfx::PointF(xout, pt.y + baselineDelta), paint);
|
drawTextBlob(lineBlob, gfx::PointF(xout, pt.y + baselineDelta), paint);
|
||||||
|
|
|
@ -48,6 +48,8 @@ public:
|
||||||
int height() const;
|
int height() const;
|
||||||
|
|
||||||
os::Surface* getInternalSurface() { return m_surface.get(); }
|
os::Surface* getInternalSurface() { return m_surface.get(); }
|
||||||
|
os::ColorSpace* colorSpace() { return m_surface->colorSpace().get(); }
|
||||||
|
|
||||||
int getInternalDeltaX() { return m_dx; }
|
int getInternalDeltaX() { return m_dx; }
|
||||||
int getInternalDeltaY() { return m_dy; }
|
int getInternalDeltaY() { return m_dy; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue