mirror of
https://github.com/aseprite/aseprite.git
synced 2024-12-25 06:19:32 +00:00
Update Skia to chrome/m55 (aseprite-m55) branch
This commit is contained in:
parent
a911915aab
commit
151a302830
@ -210,7 +210,12 @@ if(WITH_WEBP_SUPPORT)
|
||||
message(FATAL_ERROR "libwebp not found")
|
||||
endif()
|
||||
else()
|
||||
# Skia already includes webp library
|
||||
if(NOT USE_SKIA_BACKEND)
|
||||
set(WEBP_LIBRARIES webp)
|
||||
else()
|
||||
set(WEBP_LIBRARIES "")
|
||||
endif()
|
||||
set(WEBP_INCLUDE_DIR ${LIBWEBP_DIR}/src)
|
||||
endif()
|
||||
include_directories(${WEBP_INCLUDE_DIR})
|
||||
|
@ -226,7 +226,7 @@ Skia.
|
||||
|
||||
You can always check the
|
||||
[official Skia instructions](https://skia.org/user/quick) and select
|
||||
the OS you are building for. Aseprite uses the `aseprite-m53` Skia
|
||||
the OS you are building for. Aseprite uses the `aseprite-m55` Skia
|
||||
branch from `https://github.com/aseprite/skia`.
|
||||
|
||||
## Skia on Windows
|
||||
@ -249,7 +249,7 @@ Just ignore it.)
|
||||
cd C:\deps
|
||||
git clone https://github.com/aseprite/skia.git
|
||||
cd skia
|
||||
git checkout aseprite-m53
|
||||
git checkout aseprite-m55
|
||||
python bin/sync-and-gyp
|
||||
|
||||
(The `bin/sync-and-gyp` will take some minutes because it downloads a
|
||||
@ -273,7 +273,7 @@ several minutes to finish:
|
||||
git clone https://github.com/aseprite/skia.git
|
||||
export PATH="${PWD}/depot_tools:${PATH}"
|
||||
cd skia
|
||||
git checkout aseprite-m53
|
||||
git checkout aseprite-m55
|
||||
python bin/sync-and-gyp
|
||||
ninja -C out/Release dm
|
||||
|
||||
|
@ -82,9 +82,8 @@ if(USE_SKIA_BACKEND)
|
||||
find_library(SKIA_GIF_LIBRARY giflib PATHS "${SKIA_BUILD_OUT_DIR}" "${SKIA_BUILD_OUT_DIR}/obj/gyp" NO_DEFAULT_PATH)
|
||||
find_library(SKIA_IMAGES_LIBRARY skia_images PATH "${SKIA_BUILD_OUT_DIR}")
|
||||
find_library(SKIA_JPG_LIBRARY jpeg-turbo NAMES libjpeg-turbo PATHS "${SKIA_BUILD_OUT_DIR}" "${SKIA_BUILD_OUT_DIR}/obj/gyp" NO_DEFAULT_PATH)
|
||||
find_library(SKIA_OPTS_AVX2_LIBRARY skia_opts_avx2 PATH "${SKIA_BUILD_OUT_DIR}")
|
||||
find_library(SKIA_OPTS_AVX_LIBRARY skia_opts_avx PATH "${SKIA_BUILD_OUT_DIR}")
|
||||
find_library(SKIA_OPTS_AVX_LIBRARY skia_opts_avx PATH "${SKIA_BUILD_OUT_DIR}")
|
||||
find_library(SKIA_OPTS_HSW_LIBRARY skia_opts_hsw PATH "${SKIA_BUILD_OUT_DIR}")
|
||||
find_library(SKIA_OPTS_LIBRARY skia_opts PATH "${SKIA_BUILD_OUT_DIR}")
|
||||
find_library(SKIA_OPTS_SSE41_LIBRARY skia_opts_sse41 PATH "${SKIA_BUILD_OUT_DIR}")
|
||||
find_library(SKIA_OPTS_SSE42_LIBRARY skia_opts_sse42 PATH "${SKIA_BUILD_OUT_DIR}")
|
||||
@ -97,7 +96,10 @@ if(USE_SKIA_BACKEND)
|
||||
find_library(SKIA_SKKTX_LIBRARY SkKTX libSkKTX PATHS "${SKIA_BUILD_OUT_DIR}" "${SKIA_BUILD_OUT_DIR}/obj/gyp" NO_DEFAULT_PATH)
|
||||
find_library(SKIA_UTILS_LIBRARY skia_utils PATH "${SKIA_BUILD_OUT_DIR}")
|
||||
find_library(SKIA_WEBP_DEC_LIBRARY webp_dec NAMES libwebp_dec PATHS "${SKIA_BUILD_OUT_DIR}" "${SKIA_BUILD_OUT_DIR}/obj/gyp" NO_DEFAULT_PATH)
|
||||
find_library(SKIA_WEBP_DEMUX_LIBRARY webp_demux NAMES libwebp_demux PATHS "${SKIA_BUILD_OUT_DIR}" "${SKIA_BUILD_OUT_DIR}/obj/gyp" NO_DEFAULT_PATH)
|
||||
find_library(SKIA_WEBP_DSP_LIBRARY webp_dsp NAMES libwebp_dsp PATHS "${SKIA_BUILD_OUT_DIR}" "${SKIA_BUILD_OUT_DIR}/obj/gyp" NO_DEFAULT_PATH)
|
||||
find_library(SKIA_WEBP_DSP_ENC_LIBRARY webp_dsp_enc NAMES libwebp_dsp_enc PATHS "${SKIA_BUILD_OUT_DIR}" "${SKIA_BUILD_OUT_DIR}/obj/gyp" NO_DEFAULT_PATH)
|
||||
find_library(SKIA_WEBP_ENC_LIBRARY webp_enc NAMES libwebp_enc PATHS "${SKIA_BUILD_OUT_DIR}" "${SKIA_BUILD_OUT_DIR}/obj/gyp" NO_DEFAULT_PATH)
|
||||
find_library(SKIA_WEBP_UTILS_LIBRARY webp_utils NAMES libwebp_utils PATHS "${SKIA_BUILD_OUT_DIR}" "${SKIA_BUILD_OUT_DIR}/obj/gyp" NO_DEFAULT_PATH)
|
||||
find_library(SKIA_ZLIB_LIBRARY zlib PATHS "${SKIA_BUILD_OUT_DIR}" "${SKIA_BUILD_OUT_DIR}/obj/gyp" NO_DEFAULT_PATH)
|
||||
|
||||
@ -153,8 +155,8 @@ if(USE_SKIA_BACKEND)
|
||||
${SKIA_OPTS_SSSE3_LIBRARY}
|
||||
${SKIA_OPTS_SSE41_LIBRARY}
|
||||
${SKIA_OPTS_SSE42_LIBRARY}
|
||||
${SKIA_OPTS_HSW_LIBRARY}
|
||||
${SKIA_OPTS_AVX_LIBRARY}
|
||||
${SKIA_OPTS_AVX2_LIBRARY}
|
||||
${SKIA_PORTS_LIBRARY}
|
||||
${SKIA_EFFECTS_LIBRARY}
|
||||
${SKIA_CODEC_LIBRARY}
|
||||
@ -164,7 +166,10 @@ if(USE_SKIA_BACKEND)
|
||||
${SKIA_GIF_LIBRARY}
|
||||
${SKIA_JPG_LIBRARY}
|
||||
${SKIA_WEBP_DEC_LIBRARY}
|
||||
${SKIA_WEBP_DEMUX_LIBRARY}
|
||||
${SKIA_WEBP_DSP_LIBRARY}
|
||||
${SKIA_WEBP_DSP_ENC_LIBRARY}
|
||||
${SKIA_WEBP_ENC_LIBRARY}
|
||||
${SKIA_WEBP_UTILS_LIBRARY}
|
||||
${SKIA_PNG_LIBRARY}
|
||||
${SKIA_ZLIB_LIBRARY}
|
||||
@ -183,6 +188,7 @@ if(USE_SKIA_BACKEND)
|
||||
|
||||
list(APPEND SHE_SOURCES
|
||||
skia/skia_display.cpp
|
||||
skia/skia_surface.cpp
|
||||
skia/she.cpp)
|
||||
|
||||
if(WIN32)
|
||||
|
@ -59,7 +59,8 @@ public:
|
||||
ASSERT(!m_surface);
|
||||
|
||||
if (!m_bitmap.tryAllocPixels(
|
||||
SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType)))
|
||||
SkImageInfo::MakeN32(width, height, kOpaque_SkAlphaType,
|
||||
colorSpace())))
|
||||
throw base::Exception("Cannot create Skia surface");
|
||||
|
||||
m_bitmap.eraseColor(SK_ColorTRANSPARENT);
|
||||
@ -70,7 +71,7 @@ public:
|
||||
ASSERT(!m_surface);
|
||||
|
||||
if (!m_bitmap.tryAllocPixels(
|
||||
SkImageInfo::MakeN32Premul(width, height)))
|
||||
SkImageInfo::MakeN32Premul(width, height, colorSpace())))
|
||||
throw base::Exception("Cannot create Skia surface");
|
||||
|
||||
m_bitmap.eraseColor(SK_ColorTRANSPARENT);
|
||||
@ -112,30 +113,30 @@ public:
|
||||
|
||||
void setClipBounds(const gfx::Rect& rc) override {
|
||||
m_clip = rc;
|
||||
m_canvas->clipRect(SkRect::Make(to_skia(m_clip)), SkRegion::kReplace_Op);
|
||||
m_canvas->clipRect(SkRect::Make(to_skia(m_clip)), kReplace_SkClipOp);
|
||||
}
|
||||
|
||||
bool intersectClipRect(const gfx::Rect& rc) override {
|
||||
m_clip &= rc;
|
||||
m_canvas->clipRect(SkRect::Make(to_skia(m_clip)), SkRegion::kReplace_Op);
|
||||
m_canvas->clipRect(SkRect::Make(to_skia(m_clip)), kReplace_SkClipOp);
|
||||
return !m_clip.isEmpty();
|
||||
}
|
||||
|
||||
void setDrawMode(DrawMode mode, int param) override {
|
||||
switch (mode) {
|
||||
case DrawMode::Solid:
|
||||
m_paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
|
||||
m_paint.setBlendMode(SkBlendMode::kSrcOver);
|
||||
m_paint.setShader(nullptr);
|
||||
break;
|
||||
case DrawMode::Xor:
|
||||
m_paint.setXfermodeMode(SkXfermode::kXor_Mode);
|
||||
m_paint.setBlendMode(SkBlendMode::kXor);
|
||||
m_paint.setShader(nullptr);
|
||||
break;
|
||||
case DrawMode::Checked: {
|
||||
m_paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
|
||||
m_paint.setBlendMode(SkBlendMode::kSrcOver);
|
||||
{
|
||||
SkBitmap bitmap;
|
||||
if (!bitmap.tryAllocPixels(SkImageInfo::MakeN32Premul(8, 8)))
|
||||
if (!bitmap.tryAllocPixels(SkImageInfo::MakeN32Premul(8, 8, colorSpace())))
|
||||
throw base::Exception("Cannot create temporary Skia surface");
|
||||
|
||||
{
|
||||
@ -184,7 +185,7 @@ public:
|
||||
throw base::Exception("Cannot create temporary Skia surface to change scale");
|
||||
|
||||
SkPaint paint;
|
||||
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kSrc);
|
||||
|
||||
SkCanvas canvas(result);
|
||||
SkRect srcRect = SkRect::Make(SkIRect::MakeXYWH(0, 0, width(), height()));
|
||||
@ -270,7 +271,7 @@ public:
|
||||
SkColor c = 0;
|
||||
|
||||
if (m_surface) {
|
||||
SkImageInfo dstInfo = SkImageInfo::MakeN32Premul(1, 1);
|
||||
SkImageInfo dstInfo = SkImageInfo::MakeN32Premul(1, 1, colorSpace());
|
||||
uint32_t dstPixels;
|
||||
if (m_canvas->readPixels(dstInfo, &dstPixels, 4, x, y))
|
||||
c = dstPixels;
|
||||
@ -324,7 +325,7 @@ public:
|
||||
}
|
||||
|
||||
void blitTo(Surface* dest, int srcx, int srcy, int dstx, int dsty, int width, int height) const override {
|
||||
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
|
||||
SkImageInfo info = SkImageInfo::MakeN32Premul(width, height, colorSpace());
|
||||
std::vector<uint32_t> pixels(width * height * 4);
|
||||
m_canvas->readPixels(info, (void*)&pixels[0], 4*width, srcx, srcy);
|
||||
static_cast<SkiaSurface*>(dest)
|
||||
@ -382,7 +383,7 @@ public:
|
||||
SkRect dstRect = SkRect::Make(SkIRect::MakeXYWH(clip.dst.x, clip.dst.y, clip.size.w, clip.size.h));
|
||||
|
||||
SkPaint paint;
|
||||
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kSrc);
|
||||
|
||||
m_canvas->drawBitmapRect(
|
||||
((SkiaSurface*)src)->m_bitmap, srcRect, dstRect, &paint,
|
||||
@ -401,7 +402,7 @@ public:
|
||||
SkRect dstRect = SkRect::Make(SkIRect::MakeXYWH(clip.dst.x, clip.dst.y, clip.size.w, clip.size.h));
|
||||
|
||||
SkPaint paint;
|
||||
paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kSrcOver);
|
||||
|
||||
m_canvas->drawBitmapRect(
|
||||
((SkiaSurface*)src)->m_bitmap, srcRect, dstRect, &paint,
|
||||
@ -417,7 +418,7 @@ public:
|
||||
SkRect dstRect = SkRect::Make(SkIRect::MakeXYWH(clip.dst.x, clip.dst.y, clip.size.w, clip.size.h));
|
||||
|
||||
SkPaint paint;
|
||||
paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
|
||||
paint.setBlendMode(SkBlendMode::kSrcOver);
|
||||
|
||||
if (gfx::geta(bg) > 0) {
|
||||
SkPaint paint;
|
||||
@ -447,6 +448,8 @@ public:
|
||||
rebuild();
|
||||
}
|
||||
|
||||
static Surface* loadSurface(const char* filename);
|
||||
|
||||
private:
|
||||
void rebuild() {
|
||||
ASSERT(!m_surface);
|
||||
@ -456,12 +459,16 @@ private:
|
||||
m_clip = gfx::Rect(0, 0, width(), height());
|
||||
}
|
||||
|
||||
static sk_sp<SkColorSpace> colorSpace();
|
||||
|
||||
SkBitmap m_bitmap;
|
||||
sk_sp<SkSurface> m_surface;
|
||||
SkCanvas* m_canvas;
|
||||
SkPaint m_paint;
|
||||
gfx::Rect m_clip;
|
||||
int m_lock;
|
||||
static sk_sp<SkColorSpace> m_colorSpace;
|
||||
|
||||
};
|
||||
|
||||
} // namespace she
|
||||
|
@ -9,11 +9,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "base/base.h"
|
||||
#include "base/file_handle.h"
|
||||
|
||||
#include "SkCodec.h"
|
||||
#include "SkPixelRef.h"
|
||||
#include "SkStream.h"
|
||||
|
||||
#include "she/common/system.h"
|
||||
#include "she/skia/skia_display.h"
|
||||
@ -32,6 +27,8 @@
|
||||
#define SkiaSystemBase CommonSystem
|
||||
#endif
|
||||
|
||||
#include "SkGraphics.h"
|
||||
|
||||
namespace she {
|
||||
|
||||
EventQueueImpl g_queue;
|
||||
@ -41,9 +38,11 @@ public:
|
||||
SkiaSystem()
|
||||
: m_defaultDisplay(nullptr)
|
||||
, m_gpuAcceleration(false) {
|
||||
SkGraphics::Init();
|
||||
}
|
||||
|
||||
~SkiaSystem() {
|
||||
SkGraphics::Term();
|
||||
}
|
||||
|
||||
void dispose() override {
|
||||
@ -129,28 +128,7 @@ public:
|
||||
}
|
||||
|
||||
Surface* loadSurface(const char* filename) override {
|
||||
base::FileHandle fp(base::open_file_with_exception(filename, "rb"));
|
||||
|
||||
SkAutoTDelete<SkCodec> codec(
|
||||
SkCodec::NewFromStream(
|
||||
new SkFILEStream(fp.get(), SkFILEStream::kCallerRetains_Ownership)));
|
||||
if (!codec)
|
||||
return nullptr;
|
||||
|
||||
SkImageInfo info = codec->getInfo()
|
||||
.makeColorType(kN32_SkColorType)
|
||||
.makeAlphaType(kPremul_SkAlphaType);
|
||||
SkBitmap bm;
|
||||
if (!bm.tryAllocPixels(info))
|
||||
return nullptr;
|
||||
|
||||
const SkCodec::Result r = codec->getPixels(info, bm.getPixels(), bm.rowBytes());
|
||||
if (r != SkCodec::kSuccess)
|
||||
return nullptr;
|
||||
|
||||
SkiaSurface* sur = new SkiaSurface();
|
||||
sur->swapBitmap(bm);
|
||||
return sur;
|
||||
return SkiaSurface::loadSurface(filename);
|
||||
}
|
||||
|
||||
Surface* loadRgbaSurface(const char* filename) override {
|
||||
|
@ -229,7 +229,6 @@ private:
|
||||
|
||||
m_skSurface.reset(nullptr);
|
||||
m_skSurfaceDirect.reset(nullptr);
|
||||
m_grRenderTarget.reset(nullptr);
|
||||
m_grCtx.reset(nullptr);
|
||||
m_glCtx.reset(nullptr);
|
||||
}
|
||||
@ -246,11 +245,10 @@ private:
|
||||
desc.fSampleCnt = m_glCtx->getSampleCount();
|
||||
desc.fStencilBits = m_glCtx->getStencilBits();
|
||||
desc.fRenderTargetHandle = 0; // direct frame buffer
|
||||
m_grRenderTarget.reset(m_grCtx->textureProvider()->wrapBackendRenderTarget(desc));
|
||||
|
||||
m_skSurface.reset(nullptr); // set m_skSurface comparing with the old m_skSurfaceDirect
|
||||
m_skSurfaceDirect =
|
||||
SkSurface::MakeRenderTargetDirect(m_grRenderTarget.get());
|
||||
m_skSurfaceDirect = SkSurface::MakeFromBackendRenderTarget(
|
||||
m_grCtx.get(), desc, nullptr);
|
||||
|
||||
if (scale == 1) {
|
||||
m_skSurface = m_skSurfaceDirect;
|
||||
@ -330,7 +328,6 @@ private:
|
||||
SkAutoTUnref<const GrGLInterface> m_glInterfaces;
|
||||
NSOpenGLContext* m_nsGL;
|
||||
sk_sp<GrContext> m_grCtx;
|
||||
sk_sp<GrRenderTarget> m_grRenderTarget;
|
||||
sk_sp<SkSurface> m_skSurfaceDirect;
|
||||
sk_sp<SkSurface> m_skSurface;
|
||||
gfx::Size m_lastSize;
|
||||
|
@ -272,7 +272,6 @@ void SkiaWindow::detachGL()
|
||||
|
||||
m_skSurface.reset(nullptr);
|
||||
m_skSurfaceDirect.reset(nullptr);
|
||||
m_grRenderTarget.reset(nullptr);
|
||||
m_grCtx.reset(nullptr);
|
||||
m_glCtx.reset(nullptr);
|
||||
}
|
||||
@ -290,11 +289,10 @@ void SkiaWindow::createRenderTarget(const gfx::Size& size)
|
||||
desc.fSampleCnt = m_sampleCount;
|
||||
desc.fStencilBits = m_stencilBits;
|
||||
desc.fRenderTargetHandle = 0; // direct frame buffer
|
||||
m_grRenderTarget.reset(m_grCtx->textureProvider()->wrapBackendRenderTarget(desc));
|
||||
|
||||
m_skSurface.reset(nullptr); // set m_skSurface comparing with the old m_skSurfaceDirect
|
||||
m_skSurfaceDirect =
|
||||
SkSurface::MakeRenderTargetDirect(m_grRenderTarget.get());
|
||||
m_skSurfaceDirect = SkSurface::MakeFromBackendRenderTarget(
|
||||
m_grCtx.get(), desc, nullptr);
|
||||
|
||||
if (scale == 1) {
|
||||
m_skSurface = m_skSurfaceDirect;
|
||||
|
@ -54,7 +54,6 @@ private:
|
||||
base::UniquePtr<GLContext> m_glCtx;
|
||||
SkAutoTUnref<const GrGLInterface> m_glInterfaces;
|
||||
sk_sp<GrContext> m_grCtx;
|
||||
sk_sp<GrRenderTarget> m_grRenderTarget;
|
||||
sk_sp<SkSurface> m_skSurfaceDirect;
|
||||
sk_sp<SkSurface> m_skSurface;
|
||||
int m_sampleCount;
|
||||
|
3
third_party/CMakeLists.txt
vendored
3
third_party/CMakeLists.txt
vendored
@ -31,9 +31,12 @@ endif()
|
||||
|
||||
if(WITH_WEBP_SUPPORT)
|
||||
if(NOT USE_SHARED_LIBWEBP)
|
||||
# Skia already includes webp library
|
||||
if(NOT USE_SKIA_BACKEND)
|
||||
add_subdirectory(libwebp-cmake)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT USE_SHARED_GIFLIB)
|
||||
add_subdirectory(giflib)
|
||||
|
2
third_party/libwebp
vendored
2
third_party/libwebp
vendored
@ -1 +1 @@
|
||||
Subproject commit 03fb75221c36ff773379eb5f018d7206f1ef30c9
|
||||
Subproject commit 31b1e3434227c9614e441adf017baf6002d686ab
|
Loading…
Reference in New Issue
Block a user