mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-25 03:02:31 +00:00
Update skia to chrome/m53
This commit is contained in:
parent
691ff2c08a
commit
8e7b700c35
@ -73,59 +73,52 @@ if(USE_SKIA_BACKEND)
|
|||||||
set(SKIA_BUILD_OUT_DIR "${SKIA_DIR}/out/Release")
|
set(SKIA_BUILD_OUT_DIR "${SKIA_DIR}/out/Release")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
find_library(SKIA_CODEC_LIBRARY skia_codec PATH "${SKIA_BUILD_OUT_DIR}")
|
||||||
find_library(SKIA_CORE_LIBRARY skia_core PATH "${SKIA_BUILD_OUT_DIR}")
|
find_library(SKIA_CORE_LIBRARY skia_core PATH "${SKIA_BUILD_OUT_DIR}")
|
||||||
|
find_library(SKIA_DNG_SDK_LIBRARY dng_sdk PATHS "${SKIA_BUILD_OUT_DIR}" "${SKIA_BUILD_OUT_DIR}/obj/gyp" NO_DEFAULT_PATH)
|
||||||
find_library(SKIA_EFFECTS_LIBRARY skia_effects PATH "${SKIA_BUILD_OUT_DIR}")
|
find_library(SKIA_EFFECTS_LIBRARY skia_effects PATH "${SKIA_BUILD_OUT_DIR}")
|
||||||
|
find_library(SKIA_ETC1_LIBRARY etc1 NAMES libetc1 PATHS "${SKIA_BUILD_OUT_DIR}" "${SKIA_BUILD_OUT_DIR}/obj/gyp" NO_DEFAULT_PATH)
|
||||||
|
find_library(SKIA_FLAGS_LIBRARY flags PATHS "${SKIA_BUILD_OUT_DIR}" "${SKIA_BUILD_OUT_DIR}/obj/gyp" NO_DEFAULT_PATH)
|
||||||
|
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_IMAGES_LIBRARY skia_images PATH "${SKIA_BUILD_OUT_DIR}")
|
||||||
find_library(SKIA_OPTS_LIBRARY skia_opts 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_AVX_LIBRARY skia_opts_avx PATH "${SKIA_BUILD_OUT_DIR}")
|
|
||||||
find_library(SKIA_OPTS_AVX2_LIBRARY skia_opts_avx2 PATH "${SKIA_BUILD_OUT_DIR}")
|
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_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_SSE41_LIBRARY skia_opts_sse41 PATH "${SKIA_BUILD_OUT_DIR}")
|
||||||
find_library(SKIA_OPTS_SSE42_LIBRARY skia_opts_sse42 PATH "${SKIA_BUILD_OUT_DIR}")
|
find_library(SKIA_OPTS_SSE42_LIBRARY skia_opts_sse42 PATH "${SKIA_BUILD_OUT_DIR}")
|
||||||
find_library(SKIA_OPTS_SSSE3_LIBRARY skia_opts_ssse3 PATH "${SKIA_BUILD_OUT_DIR}")
|
find_library(SKIA_OPTS_SSSE3_LIBRARY skia_opts_ssse3 PATH "${SKIA_BUILD_OUT_DIR}")
|
||||||
find_library(SKIA_OPTS_AVX_LIBRARY skia_opts_avx PATH "${SKIA_BUILD_OUT_DIR}")
|
find_library(SKIA_PIEX_LIBRARY piex PATHS "${SKIA_BUILD_OUT_DIR}" "${SKIA_BUILD_OUT_DIR}/obj/gyp" NO_DEFAULT_PATH)
|
||||||
|
find_library(SKIA_PNG_LIBRARY png_static NAMES libpng_static PATHS "${SKIA_BUILD_OUT_DIR}" "${SKIA_BUILD_OUT_DIR}/obj/gyp" NO_DEFAULT_PATH)
|
||||||
find_library(SKIA_PORTS_LIBRARY skia_ports PATH "${SKIA_BUILD_OUT_DIR}")
|
find_library(SKIA_PORTS_LIBRARY skia_ports PATH "${SKIA_BUILD_OUT_DIR}")
|
||||||
|
find_library(SKIA_RAW_CODEC_LIBRARY raw_codec PATHS "${SKIA_BUILD_OUT_DIR}" "${SKIA_BUILD_OUT_DIR}/obj/gyp" NO_DEFAULT_PATH)
|
||||||
find_library(SKIA_SFNT_LIBRARY skia_sfnt PATH "${SKIA_BUILD_OUT_DIR}")
|
find_library(SKIA_SFNT_LIBRARY skia_sfnt PATH "${SKIA_BUILD_OUT_DIR}")
|
||||||
|
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_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_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_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)
|
||||||
|
|
||||||
find_library(SKIA_GPU_LIBRARY skia_skgpu PATH "${SKIA_BUILD_OUT_DIR}")
|
find_library(SKIA_GPU_LIBRARY skia_skgpu PATH "${SKIA_BUILD_OUT_DIR}")
|
||||||
if(SKIA_GPU_LIBRARY)
|
if(SKIA_GPU_LIBRARY)
|
||||||
add_definitions(-DSK_SUPPORT_GPU=1)
|
add_definitions(-DSK_SUPPORT_GPU=1)
|
||||||
else()
|
|
||||||
add_definitions(-DSK_SUPPORT_GPU=0)
|
|
||||||
set(SKIA_GPU_LIBRARY "")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_library(SKIA_ETC1_LIBRARY etc1 PATH "${SKIA_BUILD_OUT_DIR}")
|
|
||||||
if(NOT SKIA_ETC1_LIBRARY)
|
|
||||||
set(SKIA_ETC1_LIBRARY "")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_library(SKIA_FLAGS_LIBRARY flags PATH "${SKIA_BUILD_OUT_DIR}")
|
|
||||||
if(NOT SKIA_FLAGS_LIBRARY)
|
|
||||||
set(SKIA_FLAGS_LIBRARY "")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_library(SKIA_SKKTX_LIBRARY SkKTX PATH "${SKIA_BUILD_OUT_DIR}")
|
|
||||||
if(NOT SKIA_SKKTX_LIBRARY)
|
|
||||||
set(SKIA_SKKTX_LIBRARY "")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
if(SKIA_GPU_LIBRARY)
|
|
||||||
find_library(SKIA_OPENGL_LIBRARY opengl32)
|
find_library(SKIA_OPENGL_LIBRARY opengl32)
|
||||||
find_library(SKIA_LIBEGL_LIBRARY libEGL.dll PATH "${SKIA_BUILD_OUT_DIR}")
|
find_library(SKIA_LIBEGL_LIBRARY libEGL.dll PATH "${SKIA_BUILD_OUT_DIR}")
|
||||||
if(SKIA_LIBEGL_LIBRARY)
|
if(SKIA_LIBEGL_LIBRARY)
|
||||||
add_definitions(-DSK_ANGLE=1)
|
add_definitions(-DSK_ANGLE=1)
|
||||||
endif()
|
endif()
|
||||||
|
else()
|
||||||
|
find_library(SKIA_OPENGL_LIBRARY opengl NAMES GL)
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
if(SKIA_GPU_LIBRARY)
|
add_definitions(-DSK_SUPPORT_GPU=0)
|
||||||
find_library(SKIA_OPENGL_LIBRARY opengl)
|
set(SKIA_GPU_LIBRARY "")
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT SKIA_OPENGL_LIBRARY)
|
|
||||||
set(SKIA_OPENGL_LIBRARY "")
|
set(SKIA_OPENGL_LIBRARY "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT SKIA_LIBEGL_LIBRARY)
|
if(NOT SKIA_LIBEGL_LIBRARY)
|
||||||
set(SKIA_LIBEGL_LIBRARY "")
|
set(SKIA_LIBEGL_LIBRARY "")
|
||||||
endif()
|
endif()
|
||||||
@ -133,7 +126,8 @@ if(USE_SKIA_BACKEND)
|
|||||||
find_path(SKIA_CONFIG_INCLUDE_DIR SkUserConfig.h HINTS "${SKIA_DIR}/include/config")
|
find_path(SKIA_CONFIG_INCLUDE_DIR SkUserConfig.h HINTS "${SKIA_DIR}/include/config")
|
||||||
find_path(SKIA_CORE_INCLUDE_DIR SkCanvas.h HINTS "${SKIA_DIR}/include/core")
|
find_path(SKIA_CORE_INCLUDE_DIR SkCanvas.h HINTS "${SKIA_DIR}/include/core")
|
||||||
find_path(SKIA_UTILS_INCLUDE_DIR SkRandom.h HINTS "${SKIA_DIR}/include/utils")
|
find_path(SKIA_UTILS_INCLUDE_DIR SkRandom.h HINTS "${SKIA_DIR}/include/utils")
|
||||||
find_path(SKIA_EFFECTS_INCLUDE_DIR SkBitmapSource.h HINTS "${SKIA_DIR}/include/effects")
|
find_path(SKIA_CODEC_INCLUDE_DIR SkCodec.h HINTS "${SKIA_DIR}/include/codec")
|
||||||
|
find_path(SKIA_EFFECTS_INCLUDE_DIR SkImageSource.h HINTS "${SKIA_DIR}/include/effects")
|
||||||
if(SKIA_GPU_LIBRARY)
|
if(SKIA_GPU_LIBRARY)
|
||||||
find_path(SKIA_GPU_INCLUDE_DIR SkGr.h HINTS "${SKIA_DIR}/include/gpu")
|
find_path(SKIA_GPU_INCLUDE_DIR SkGr.h HINTS "${SKIA_DIR}/include/gpu")
|
||||||
find_path(SKIA_ANGLE_INCLUDE_DIR angle_gl.h HINTS "${SKIA_DIR}/third_party/externals/angle2/include")
|
find_path(SKIA_ANGLE_INCLUDE_DIR angle_gl.h HINTS "${SKIA_DIR}/third_party/externals/angle2/include")
|
||||||
@ -143,7 +137,8 @@ if(USE_SKIA_BACKEND)
|
|||||||
${SKIA_CONFIG_INCLUDE_DIR}
|
${SKIA_CONFIG_INCLUDE_DIR}
|
||||||
${SKIA_CORE_INCLUDE_DIR}
|
${SKIA_CORE_INCLUDE_DIR}
|
||||||
${SKIA_PORTS_INCLUDE_DIR}
|
${SKIA_PORTS_INCLUDE_DIR}
|
||||||
${SKIA_UTILS_INCLUDE_DIR})
|
${SKIA_UTILS_INCLUDE_DIR}
|
||||||
|
${SKIA_CODEC_INCLUDE_DIR})
|
||||||
if(SKIA_GPU_LIBRARY)
|
if(SKIA_GPU_LIBRARY)
|
||||||
include_directories(${SKIA_GPU_INCLUDE_DIR})
|
include_directories(${SKIA_GPU_INCLUDE_DIR})
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
@ -151,14 +146,7 @@ if(USE_SKIA_BACKEND)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Patch for Skia (branch m50) as we don't link with skia_codec library
|
|
||||||
add_library(skia_missing_files ${SKIA_DIR}/src/ports/SkImageGenerator_none.cpp)
|
|
||||||
set(SKIA_MISSING_FILES skia_missing_files)
|
|
||||||
|
|
||||||
set(SKIA_LIBRARIES
|
set(SKIA_LIBRARIES
|
||||||
${SKIA_ETC1_LIBRARY}
|
|
||||||
${SKIA_FLAGS_LIBRARY}
|
|
||||||
${SKIA_SKKTX_LIBRARY}
|
|
||||||
${SKIA_CORE_LIBRARY}
|
${SKIA_CORE_LIBRARY}
|
||||||
${SKIA_IMAGES_LIBRARY}
|
${SKIA_IMAGES_LIBRARY}
|
||||||
${SKIA_OPTS_LIBRARY}
|
${SKIA_OPTS_LIBRARY}
|
||||||
@ -169,15 +157,28 @@ if(USE_SKIA_BACKEND)
|
|||||||
${SKIA_OPTS_AVX2_LIBRARY}
|
${SKIA_OPTS_AVX2_LIBRARY}
|
||||||
${SKIA_PORTS_LIBRARY}
|
${SKIA_PORTS_LIBRARY}
|
||||||
${SKIA_EFFECTS_LIBRARY}
|
${SKIA_EFFECTS_LIBRARY}
|
||||||
|
${SKIA_CODEC_LIBRARY}
|
||||||
|
${SKIA_RAW_CODEC_LIBRARY}
|
||||||
|
${SKIA_PIEX_LIBRARY}
|
||||||
|
${SKIA_DNG_SDK_LIBRARY}
|
||||||
|
${SKIA_GIF_LIBRARY}
|
||||||
|
${SKIA_JPG_LIBRARY}
|
||||||
|
${SKIA_WEBP_DEC_LIBRARY}
|
||||||
|
${SKIA_WEBP_DSP_LIBRARY}
|
||||||
|
${SKIA_WEBP_UTILS_LIBRARY}
|
||||||
|
${SKIA_PNG_LIBRARY}
|
||||||
|
${SKIA_ZLIB_LIBRARY}
|
||||||
|
${SKIA_GPU_LIBRARY}
|
||||||
# We've to include two times skia_core as a dependency as it looks
|
# We've to include two times skia_core as a dependency as it looks
|
||||||
# like Skia libraries depends one each other (core+ports+effects)
|
# like Skia libraries depends one each other (core+ports+effects)
|
||||||
${SKIA_CORE_LIBRARY}
|
${SKIA_CORE_LIBRARY}
|
||||||
${SKIA_MISSING_FILES}
|
|
||||||
${SKIA_UTILS_LIBRARY}
|
${SKIA_UTILS_LIBRARY}
|
||||||
${SKIA_SFNT_LIBRARY}
|
${SKIA_SFNT_LIBRARY}
|
||||||
${SKIA_OPENGL_LIBRARY}
|
${SKIA_OPENGL_LIBRARY}
|
||||||
${SKIA_LIBEGL_LIBRARY}
|
${SKIA_LIBEGL_LIBRARY}
|
||||||
${SKIA_GPU_LIBRARY}
|
${SKIA_SKKTX_LIBRARY}
|
||||||
|
${SKIA_ETC1_LIBRARY}
|
||||||
|
${SKIA_FLAGS_LIBRARY}
|
||||||
CACHE INTERNAL "Skia libraries")
|
CACHE INTERNAL "Skia libraries")
|
||||||
|
|
||||||
list(APPEND SHE_SOURCES
|
list(APPEND SHE_SOURCES
|
||||||
|
@ -38,7 +38,7 @@ public:
|
|||||||
, m_lock(0) {
|
, m_lock(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SkiaSurface(SkSurface* surface)
|
SkiaSurface(const sk_sp<SkSurface>& surface)
|
||||||
: m_surface(surface)
|
: m_surface(surface)
|
||||||
, m_canvas(nullptr)
|
, m_canvas(nullptr)
|
||||||
, m_clip(0, 0, width(), height())
|
, m_clip(0, 0, width(), height())
|
||||||
@ -149,11 +149,11 @@ public:
|
|||||||
bitmap.unlockPixels();
|
bitmap.unlockPixels();
|
||||||
}
|
}
|
||||||
|
|
||||||
SkAutoTUnref<SkShader> shader(
|
sk_sp<SkShader> shader(
|
||||||
SkShader::CreateBitmapShader(
|
SkShader::MakeBitmapShader(
|
||||||
bitmap,
|
bitmap,
|
||||||
SkShader::kRepeat_TileMode,
|
SkShader::kRepeat_TileMode,
|
||||||
SkShader::kRepeat_TileMode, nullptr));
|
SkShader::kRepeat_TileMode));
|
||||||
m_paint.setShader(shader);
|
m_paint.setShader(shader);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -426,8 +426,8 @@ public:
|
|||||||
m_canvas->drawRect(dstRect, paint);
|
m_canvas->drawRect(dstRect, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
SkAutoTUnref<SkColorFilter> colorFilter(
|
sk_sp<SkColorFilter> colorFilter(
|
||||||
SkColorFilter::CreateModeFilter(to_skia(fg), SkXfermode::kSrcIn_Mode));
|
SkColorFilter::MakeModeFilter(to_skia(fg), SkXfermode::kSrcIn_Mode));
|
||||||
paint.setColorFilter(colorFilter);
|
paint.setColorFilter(colorFilter);
|
||||||
|
|
||||||
m_canvas->drawBitmapRect(
|
m_canvas->drawBitmapRect(
|
||||||
@ -457,7 +457,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkBitmap m_bitmap;
|
SkBitmap m_bitmap;
|
||||||
SkSurface* m_surface;
|
sk_sp<SkSurface> m_surface;
|
||||||
SkCanvas* m_canvas;
|
SkCanvas* m_canvas;
|
||||||
SkPaint m_paint;
|
SkPaint m_paint;
|
||||||
gfx::Rect m_clip;
|
gfx::Rect m_clip;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "base/base.h"
|
#include "base/base.h"
|
||||||
#include "base/file_handle.h"
|
#include "base/file_handle.h"
|
||||||
|
|
||||||
#include "SkImageDecoder.h"
|
#include "SkCodec.h"
|
||||||
#include "SkPixelRef.h"
|
#include "SkPixelRef.h"
|
||||||
#include "SkStream.h"
|
#include "SkStream.h"
|
||||||
|
|
||||||
@ -41,13 +41,6 @@ public:
|
|||||||
SkiaSystem()
|
SkiaSystem()
|
||||||
: m_defaultDisplay(nullptr)
|
: m_defaultDisplay(nullptr)
|
||||||
, m_gpuAcceleration(false) {
|
, m_gpuAcceleration(false) {
|
||||||
#if !defined(__APPLE__) && !defined(_WIN32)
|
|
||||||
// Create one decoder on Linux to load .png files with
|
|
||||||
// libpng. Without this, SkImageDecoder::Factory() returns null
|
|
||||||
// for .png files.
|
|
||||||
SkAutoTDelete<SkImageDecoder> decoder(
|
|
||||||
CreatePNGImageDecoder());
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~SkiaSystem() {
|
~SkiaSystem() {
|
||||||
@ -133,23 +126,28 @@ public:
|
|||||||
|
|
||||||
Surface* loadSurface(const char* filename) override {
|
Surface* loadSurface(const char* filename) override {
|
||||||
base::FileHandle fp(base::open_file_with_exception(filename, "rb"));
|
base::FileHandle fp(base::open_file_with_exception(filename, "rb"));
|
||||||
SkAutoTDelete<SkStreamAsset> stream(new SkFILEStream(fp.get(), SkFILEStream::kCallerRetains_Ownership));
|
|
||||||
|
|
||||||
SkAutoTDelete<SkImageDecoder> decoder(SkImageDecoder::Factory(stream));
|
SkAutoTDelete<SkCodec> codec(
|
||||||
if (decoder) {
|
SkCodec::NewFromStream(
|
||||||
stream->rewind();
|
new SkFILEStream(fp.get(), SkFILEStream::kCallerRetains_Ownership)));
|
||||||
|
if (!codec)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
SkImageInfo info = codec->getInfo()
|
||||||
|
.makeColorType(kN32_SkColorType)
|
||||||
|
.makeAlphaType(kPremul_SkAlphaType);
|
||||||
SkBitmap bm;
|
SkBitmap bm;
|
||||||
SkImageDecoder::Result res = decoder->decode(stream, &bm,
|
if (!bm.tryAllocPixels(info))
|
||||||
kN32_SkColorType, SkImageDecoder::kDecodePixels_Mode);
|
return nullptr;
|
||||||
|
|
||||||
|
const SkCodec::Result r = codec->getPixels(info, bm.getPixels(), bm.rowBytes());
|
||||||
|
if (r != SkCodec::kSuccess)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
if (res == SkImageDecoder::kSuccess) {
|
|
||||||
SkiaSurface* sur = new SkiaSurface();
|
SkiaSurface* sur = new SkiaSurface();
|
||||||
sur->swapBitmap(bm);
|
sur->swapBitmap(bm);
|
||||||
return sur;
|
return sur;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
Surface* loadRgbaSurface(const char* filename) override {
|
Surface* loadRgbaSurface(const char* filename) override {
|
||||||
return loadSurface(filename);
|
return loadSurface(filename);
|
||||||
|
@ -216,7 +216,7 @@ private:
|
|||||||
if (m_nsGL)
|
if (m_nsGL)
|
||||||
m_nsGL = nil;
|
m_nsGL = nil;
|
||||||
|
|
||||||
setSurface(nullptr);
|
m_skSurface.reset(nullptr);
|
||||||
m_skSurfaceDirect.reset(nullptr);
|
m_skSurfaceDirect.reset(nullptr);
|
||||||
m_grRenderTarget.reset(nullptr);
|
m_grRenderTarget.reset(nullptr);
|
||||||
m_grCtx.reset(nullptr);
|
m_grCtx.reset(nullptr);
|
||||||
@ -237,21 +237,22 @@ private:
|
|||||||
desc.fRenderTargetHandle = 0; // direct frame buffer
|
desc.fRenderTargetHandle = 0; // direct frame buffer
|
||||||
m_grRenderTarget.reset(m_grCtx->textureProvider()->wrapBackendRenderTarget(desc));
|
m_grRenderTarget.reset(m_grCtx->textureProvider()->wrapBackendRenderTarget(desc));
|
||||||
|
|
||||||
setSurface(nullptr); // set m_skSurface comparing with the old m_skSurfaceDirect
|
m_skSurface.reset(nullptr); // set m_skSurface comparing with the old m_skSurfaceDirect
|
||||||
m_skSurfaceDirect.reset(
|
m_skSurfaceDirect =
|
||||||
SkSurface::NewRenderTargetDirect(m_grRenderTarget));
|
SkSurface::MakeRenderTargetDirect(m_grRenderTarget.get());
|
||||||
|
|
||||||
if (scale == 1) {
|
if (scale == 1) {
|
||||||
setSurface(m_skSurfaceDirect);
|
m_skSurface = m_skSurfaceDirect;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setSurface(
|
m_skSurface =
|
||||||
SkSurface::NewRenderTarget(
|
SkSurface::MakeRenderTarget(
|
||||||
m_grCtx,
|
m_grCtx.get(),
|
||||||
SkSurface::kYes_Budgeted,
|
SkBudgeted::kYes,
|
||||||
SkImageInfo::MakeN32Premul(MAX(1, size.w / scale),
|
SkImageInfo::MakeN32Premul(MAX(1, size.w / scale),
|
||||||
MAX(1, size.h / scale)),
|
MAX(1, size.h / scale)),
|
||||||
m_glCtx->getSampleCount()));
|
m_glCtx->getSampleCount(),
|
||||||
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_skSurface)
|
if (!m_skSurface)
|
||||||
@ -263,12 +264,6 @@ private:
|
|||||||
[m_nsGL update];
|
[m_nsGL update];
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSurface(SkSurface* surface) {
|
|
||||||
if (m_skSurface && m_skSurface != m_skSurfaceDirect)
|
|
||||||
delete m_skSurface;
|
|
||||||
m_skSurface = surface;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void paintGC(const gfx::Rect& rect) {
|
void paintGC(const gfx::Rect& rect) {
|
||||||
@ -310,10 +305,10 @@ private:
|
|||||||
base::UniquePtr<GLContext> m_glCtx;
|
base::UniquePtr<GLContext> m_glCtx;
|
||||||
SkAutoTUnref<const GrGLInterface> m_glInterfaces;
|
SkAutoTUnref<const GrGLInterface> m_glInterfaces;
|
||||||
NSOpenGLContext* m_nsGL;
|
NSOpenGLContext* m_nsGL;
|
||||||
SkAutoTUnref<GrContext> m_grCtx;
|
sk_sp<GrContext> m_grCtx;
|
||||||
SkAutoTUnref<GrRenderTarget> m_grRenderTarget;
|
sk_sp<GrRenderTarget> m_grRenderTarget;
|
||||||
SkAutoTDelete<SkSurface> m_skSurfaceDirect;
|
sk_sp<SkSurface> m_skSurfaceDirect;
|
||||||
SkSurface* m_skSurface;
|
sk_sp<SkSurface> m_skSurface;
|
||||||
gfx::Size m_lastSize;
|
gfx::Size m_lastSize;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "she/gl/gl_context_wgl.h"
|
#include "she/gl/gl_context_wgl.h"
|
||||||
#if SK_ANGLE
|
#if SK_ANGLE
|
||||||
#include "she/gl/gl_context_egl.h"
|
#include "she/gl/gl_context_egl.h"
|
||||||
|
#include "gl/GrGLAssembleInterface.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -106,7 +107,7 @@ void SkiaWindow::paintImpl(HDC hdc)
|
|||||||
texDesc.fConfig = kSkia8888_GrPixelConfig;
|
texDesc.fConfig = kSkia8888_GrPixelConfig;
|
||||||
texDesc.fSampleCnt = m_sampleCount;
|
texDesc.fSampleCnt = m_sampleCount;
|
||||||
texDesc.fTextureHandle = texID;
|
texDesc.fTextureHandle = texID;
|
||||||
SkAutoTUnref<SkImage> image(SkImage::NewFromTexture(m_grCtx, texDesc));
|
sk_sp<SkImage> image(SkImage::MakeFromTexture(m_grCtx.get(), texDesc));
|
||||||
|
|
||||||
SkRect dstRect(SkRect::MakeWH(SkIntToScalar(m_lastSize.w),
|
SkRect dstRect(SkRect::MakeWH(SkIntToScalar(m_lastSize.w),
|
||||||
SkIntToScalar(m_lastSize.h)));
|
SkIntToScalar(m_lastSize.h)));
|
||||||
@ -160,22 +161,55 @@ void SkiaWindow::paintHDC(HDC hdc)
|
|||||||
|
|
||||||
#if SK_ANGLE
|
#if SK_ANGLE
|
||||||
|
|
||||||
|
struct ANGLEAssembleContext {
|
||||||
|
ANGLEAssembleContext() {
|
||||||
|
fEGL = GetModuleHandle(L"libEGL.dll");
|
||||||
|
fGL = GetModuleHandle(L"libGLESv2.dll");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isValid() const { return SkToBool(fEGL) && SkToBool(fGL); }
|
||||||
|
|
||||||
|
HMODULE fEGL;
|
||||||
|
HMODULE fGL;
|
||||||
|
};
|
||||||
|
|
||||||
|
static GrGLFuncPtr angle_get_gl_proc(void* ctx, const char name[]) {
|
||||||
|
const ANGLEAssembleContext& context = *reinterpret_cast<const ANGLEAssembleContext*>(ctx);
|
||||||
|
GrGLFuncPtr proc = (GrGLFuncPtr) GetProcAddress(context.fGL, name);
|
||||||
|
if (proc) {
|
||||||
|
return proc;
|
||||||
|
}
|
||||||
|
proc = (GrGLFuncPtr) GetProcAddress(context.fEGL, name);
|
||||||
|
if (proc) {
|
||||||
|
return proc;
|
||||||
|
}
|
||||||
|
return eglGetProcAddress(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const GrGLInterface* get_angle_gl_interface() {
|
||||||
|
ANGLEAssembleContext context;
|
||||||
|
if (!context.isValid()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return GrGLAssembleGLESInterface(&context, angle_get_gl_proc);
|
||||||
|
}
|
||||||
|
|
||||||
bool SkiaWindow::attachANGLE()
|
bool SkiaWindow::attachANGLE()
|
||||||
{
|
{
|
||||||
if (!m_glCtx) {
|
if (!m_glCtx) {
|
||||||
try {
|
try {
|
||||||
SkAutoTDelete<GLContext> ctx(new GLContextEGL(handle()));
|
base::UniquePtr<GLContext> ctx(new GLContextEGL(handle()));
|
||||||
if (!ctx->createGLContext())
|
if (!ctx->createGLContext())
|
||||||
throw std::runtime_error("Cannot create EGL context");
|
throw std::runtime_error("Cannot create EGL context");
|
||||||
|
|
||||||
m_glInterfaces.reset(GrGLCreateANGLEInterface());
|
m_glInterfaces.reset(get_angle_gl_interface());
|
||||||
if (!m_glInterfaces || !m_glInterfaces->validate())
|
if (!m_glInterfaces || !m_glInterfaces->validate())
|
||||||
throw std::runtime_error("Cannot create EGL interfaces\n");
|
throw std::runtime_error("Cannot create EGL interfaces\n");
|
||||||
|
|
||||||
m_stencilBits = ctx->getStencilBits();
|
m_stencilBits = ctx->getStencilBits();
|
||||||
m_sampleCount = ctx->getSampleCount();
|
m_sampleCount = ctx->getSampleCount();
|
||||||
|
|
||||||
m_glCtx.reset(ctx.detach());
|
m_glCtx.reset(ctx.release());
|
||||||
m_grCtx.reset(
|
m_grCtx.reset(
|
||||||
GrContext::Create(kOpenGL_GrBackend,
|
GrContext::Create(kOpenGL_GrBackend,
|
||||||
(GrBackendContext)m_glInterfaces.get()));
|
(GrBackendContext)m_glInterfaces.get()));
|
||||||
@ -200,7 +234,7 @@ bool SkiaWindow::attachGL()
|
|||||||
{
|
{
|
||||||
if (!m_glCtx) {
|
if (!m_glCtx) {
|
||||||
try {
|
try {
|
||||||
SkAutoTDelete<GLContext> ctx(new GLContextWGL(handle()));
|
base::UniquePtr<GLContext> ctx(new GLContextWGL(handle()));
|
||||||
if (!ctx->createGLContext())
|
if (!ctx->createGLContext())
|
||||||
throw std::runtime_error("Cannot create WGL context\n");
|
throw std::runtime_error("Cannot create WGL context\n");
|
||||||
|
|
||||||
@ -211,8 +245,9 @@ bool SkiaWindow::attachGL()
|
|||||||
m_stencilBits = ctx->getStencilBits();
|
m_stencilBits = ctx->getStencilBits();
|
||||||
m_sampleCount = ctx->getSampleCount();
|
m_sampleCount = ctx->getSampleCount();
|
||||||
|
|
||||||
m_glCtx.reset(ctx.detach());
|
m_glCtx.reset(ctx.release());
|
||||||
m_grCtx.reset(GrContext::Create(kOpenGL_GrBackend,
|
m_grCtx.reset(
|
||||||
|
GrContext::Create(kOpenGL_GrBackend,
|
||||||
(GrBackendContext)m_glInterfaces.get()));
|
(GrBackendContext)m_glInterfaces.get()));
|
||||||
|
|
||||||
LOG("Using WGL backend\n");
|
LOG("Using WGL backend\n");
|
||||||
@ -234,7 +269,7 @@ void SkiaWindow::detachGL()
|
|||||||
if (m_glCtx && m_display)
|
if (m_glCtx && m_display)
|
||||||
m_display->resetSkiaSurface();
|
m_display->resetSkiaSurface();
|
||||||
|
|
||||||
setSurface(nullptr);
|
m_skSurface.reset(nullptr);
|
||||||
m_skSurfaceDirect.reset(nullptr);
|
m_skSurfaceDirect.reset(nullptr);
|
||||||
m_grRenderTarget.reset(nullptr);
|
m_grRenderTarget.reset(nullptr);
|
||||||
m_grCtx.reset(nullptr);
|
m_grCtx.reset(nullptr);
|
||||||
@ -256,21 +291,22 @@ void SkiaWindow::createRenderTarget(const gfx::Size& size)
|
|||||||
desc.fRenderTargetHandle = 0; // direct frame buffer
|
desc.fRenderTargetHandle = 0; // direct frame buffer
|
||||||
m_grRenderTarget.reset(m_grCtx->textureProvider()->wrapBackendRenderTarget(desc));
|
m_grRenderTarget.reset(m_grCtx->textureProvider()->wrapBackendRenderTarget(desc));
|
||||||
|
|
||||||
setSurface(nullptr); // set m_skSurface comparing with the old m_skSurfaceDirect
|
m_skSurface.reset(nullptr); // set m_skSurface comparing with the old m_skSurfaceDirect
|
||||||
m_skSurfaceDirect.reset(
|
m_skSurfaceDirect =
|
||||||
SkSurface::NewRenderTargetDirect(m_grRenderTarget));
|
SkSurface::MakeRenderTargetDirect(m_grRenderTarget.get());
|
||||||
|
|
||||||
if (scale == 1) {
|
if (scale == 1) {
|
||||||
setSurface(m_skSurfaceDirect);
|
m_skSurface = m_skSurfaceDirect;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setSurface(
|
m_skSurface =
|
||||||
SkSurface::NewRenderTarget(
|
SkSurface::MakeRenderTarget(
|
||||||
m_grCtx,
|
m_grCtx.get(),
|
||||||
SkSurface::kYes_Budgeted,
|
SkBudgeted::kYes,
|
||||||
SkImageInfo::MakeN32Premul(MAX(1, size.w / scale),
|
SkImageInfo::MakeN32Premul(MAX(1, size.w / scale),
|
||||||
MAX(1, size.h / scale)),
|
MAX(1, size.h / scale)),
|
||||||
m_sampleCount));
|
m_sampleCount,
|
||||||
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_skSurface)
|
if (!m_skSurface)
|
||||||
@ -279,13 +315,6 @@ void SkiaWindow::createRenderTarget(const gfx::Size& size)
|
|||||||
m_display->setSkiaSurface(new SkiaSurface(m_skSurface));
|
m_display->setSkiaSurface(new SkiaSurface(m_skSurface));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkiaWindow::setSurface(SkSurface* surface)
|
|
||||||
{
|
|
||||||
if (m_skSurface && m_skSurface != m_skSurfaceDirect)
|
|
||||||
delete m_skSurface;
|
|
||||||
m_skSurface = surface;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // SK_SUPPORT_GPU
|
#endif // SK_SUPPORT_GPU
|
||||||
|
|
||||||
void SkiaWindow::resizeImpl(const gfx::Size& size)
|
void SkiaWindow::resizeImpl(const gfx::Size& size)
|
||||||
|
@ -45,7 +45,6 @@ private:
|
|||||||
bool attachGL();
|
bool attachGL();
|
||||||
void detachGL();
|
void detachGL();
|
||||||
void createRenderTarget(const gfx::Size& size);
|
void createRenderTarget(const gfx::Size& size);
|
||||||
void setSurface(SkSurface* surface);
|
|
||||||
#endif // SK_SUPPORT_GPU
|
#endif // SK_SUPPORT_GPU
|
||||||
|
|
||||||
EventQueue* m_queue;
|
EventQueue* m_queue;
|
||||||
@ -54,10 +53,10 @@ private:
|
|||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
base::UniquePtr<GLContext> m_glCtx;
|
base::UniquePtr<GLContext> m_glCtx;
|
||||||
SkAutoTUnref<const GrGLInterface> m_glInterfaces;
|
SkAutoTUnref<const GrGLInterface> m_glInterfaces;
|
||||||
SkAutoTUnref<GrContext> m_grCtx;
|
sk_sp<GrContext> m_grCtx;
|
||||||
SkAutoTUnref<GrRenderTarget> m_grRenderTarget;
|
sk_sp<GrRenderTarget> m_grRenderTarget;
|
||||||
SkAutoTDelete<SkSurface> m_skSurfaceDirect;
|
sk_sp<SkSurface> m_skSurfaceDirect;
|
||||||
SkSurface* m_skSurface;
|
sk_sp<SkSurface> m_skSurface;
|
||||||
int m_sampleCount;
|
int m_sampleCount;
|
||||||
int m_stencilBits;
|
int m_stencilBits;
|
||||||
gfx::Size m_lastSize;
|
gfx::Size m_lastSize;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user