Revert "Revert "Don't build GL on Metal, Vulkan, Dawn, Direct3D bots""

This reverts commit 00ba5ef4a6.

Bug: skia:10051

Change-Id: I13fd5494b7e7e64159e6330f168ab8c16a2db149
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277609
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Brian Salomon 2020-03-18 13:40:01 -04:00 committed by Skia Commit-Bot
parent 6a32672cb4
commit fb27c9a25f
33 changed files with 262 additions and 178 deletions

294
BUILD.gn
View File

@ -74,7 +74,7 @@ config("skia_private") {
}
libs = []
lib_dirs = []
if (skia_use_angle) {
if (skia_use_gl && skia_use_angle) {
defines += [ "SK_ANGLE" ]
}
}
@ -531,36 +531,37 @@ optional("gpu") {
}
libs = []
if (is_android) {
sources += [ "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ]
# this lib is required to link against AHardwareBuffer
if (defined(ndk_api) && ndk_api >= 26) {
libs += [ "android" ]
}
} else if (skia_use_egl) {
sources += [ "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ]
libs += [ "EGL" ]
} else if (is_linux && skia_use_x11) {
sources += [ "src/gpu/gl/glx/GrGLMakeNativeInterface_glx.cpp" ]
libs += [ "GL" ]
} else if (is_mac) {
sources += [ "src/gpu/gl/mac/GrGLMakeNativeInterface_mac.cpp" ]
} else if (is_ios) {
sources += [ "src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp" ]
} else if (is_win) {
sources += [ "src/gpu/gl/win/GrGLMakeNativeInterface_win.cpp" ]
if (target_cpu != "arm64") {
libs += [ "OpenGL32.lib" ]
}
} else {
sources += [ "src/gpu/gl/GrGLMakeNativeInterface_none.cpp" ]
}
if (skia_use_gl) {
public_defines += [ "SK_GL" ]
if (is_android) {
sources += [ "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ]
# this lib is required to link against AHardwareBuffer
if (defined(ndk_api) && ndk_api >= 26) {
libs += [ "android" ]
}
} else if (skia_use_egl) {
sources += [ "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ]
libs += [ "EGL" ]
} else if (is_linux && skia_use_x11) {
sources += [ "src/gpu/gl/glx/GrGLMakeNativeInterface_glx.cpp" ]
libs += [ "GL" ]
} else if (is_mac) {
sources += [ "src/gpu/gl/mac/GrGLMakeNativeInterface_mac.cpp" ]
} else if (is_ios) {
sources += [ "src/gpu/gl/iOS/GrGLMakeNativeInterface_iOS.cpp" ]
} else if (is_win) {
sources += [ "src/gpu/gl/win/GrGLMakeNativeInterface_win.cpp" ]
if (target_cpu != "arm64") {
libs += [ "OpenGL32.lib" ]
}
} else {
sources += [ "src/gpu/gl/GrGLMakeNativeInterface_none.cpp" ]
}
sources += skia_gl_gpu_sources
}
if (skia_use_vulkan) {
public_defines += [ "SK_VULKAN" ]
deps += [ "third_party/vulkanmemoryallocator" ]
@ -577,6 +578,13 @@ optional("gpu") {
}
}
if (is_android && (skia_use_gl || skia_use_vulkan)) {
# this lib is required to link against AHardwareBuffer
if (defined(ndk_api) && ndk_api >= 26) {
libs += [ "android" ]
}
}
if (skia_use_dawn) {
public_defines += [ "SK_DAWN" ]
sources += skia_dawn_sources
@ -1376,45 +1384,39 @@ if (skia_enable_tools) {
"tools/gpu/YUVUtils.h",
"tools/gpu/mock/MockTestContext.cpp",
]
libs = []
if (skia_use_gl) {
sources += [
"tools/gpu/atlastext/GLTestAtlasTextRenderer.cpp",
"tools/gpu/gl/GLTestContext.cpp",
"tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp",
]
}
libs = []
if (is_android || skia_use_egl) {
sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
} else if (is_ios) {
sources += [ "tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ]
libs += [ "OpenGLES.framework" ]
} else if (is_linux) {
sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
libs += [
"GLU",
"X11",
]
} else if (is_mac) {
sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
} else if (is_win) {
sources += [ "tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp" ]
libs += [ "Gdi32.lib" ]
if (target_cpu != "arm64") {
libs += [ "OpenGL32.lib" ]
if (is_android || skia_use_egl) {
sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
} else if (is_ios) {
sources += [ "tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ]
libs += [ "OpenGLES.framework" ]
} else if (is_linux) {
sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
libs += [
"GLU",
"X11",
]
} else if (is_mac) {
sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
} else if (is_win) {
sources += [ "tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp" ]
libs += [ "Gdi32.lib" ]
if (target_cpu != "arm64") {
libs += [ "OpenGL32.lib" ]
}
}
if (skia_use_angle) {
deps += [ "//third_party/angle2" ]
sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
}
} else if (is_fuchsia && using_fuchsia_sdk) {
libs +=
[ "${fuchsia_sdk_path}/arch/${target_cpu}/sysroot/lib/libzircon.so" ]
}
cflags_objcc = [ "-fobjc-arc" ]
if (skia_use_angle) {
deps += [ "//third_party/angle2" ]
sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
}
if (skia_use_vulkan) {
@ -1433,6 +1435,13 @@ if (skia_enable_tools) {
sources += [ "tools/gpu/dawn/DawnTestContext.cpp" ]
cflags_cc = [ "-Wno-microsoft-cast" ]
}
if (is_fuchsia && using_fuchsia_sdk) {
libs +=
[ "${fuchsia_sdk_path}/arch/${target_cpu}/sysroot/lib/libzircon.so" ]
}
cflags_objcc = [ "-fobjc-arc" ]
} # test_lib("gpu_tool_utils")
test_lib("flags") {
@ -2183,7 +2192,7 @@ if (skia_enable_tools) {
libs = [ "android" ]
}
}
if (is_android && skia_enable_gpu) {
if (is_android && skia_use_gl) {
test_app("skottie_android") {
is_shared_library = true
@ -2228,18 +2237,12 @@ if (skia_enable_tools) {
]
sources = [
"tools/sk_app/CommandSet.cpp",
"tools/sk_app/GLWindowContext.cpp",
"tools/sk_app/Window.cpp",
]
libs = []
if (skia_use_dawn) {
sources += [ "tools/sk_app/DawnWindowContext.cpp" ]
}
if (is_android) {
sources += [
"tools/sk_app/android/GLWindowContext_android.cpp",
"tools/sk_app/android/RasterWindowContext_android.cpp",
"tools/sk_app/android/Window_android.cpp",
"tools/sk_app/android/main_android.cpp",
@ -2248,50 +2251,27 @@ if (skia_enable_tools) {
libs += [ "android" ]
} else if (is_linux) {
sources += [
"tools/sk_app/unix/GLWindowContext_unix.cpp",
"tools/sk_app/unix/RasterWindowContext_unix.cpp",
"tools/sk_app/unix/Window_unix.cpp",
"tools/sk_app/unix/keysym2ucs.c",
"tools/sk_app/unix/main_unix.cpp",
]
if (skia_use_dawn) {
if (dawn_enable_vulkan) {
sources += [ "tools/sk_app/unix/DawnVulkanWindowContext_unix.cpp" ]
defines = [ "VK_USE_PLATFORM_XCB_KHR" ]
libs += [ "X11-xcb" ]
}
}
libs += [
"GL",
"GL", # Used by raster window context, so cannot be behind skia_use_gl.
"X11",
]
} else if (is_win) {
sources += [
"tools/sk_app/win/GLWindowContext_win.cpp",
"tools/sk_app/win/RasterWindowContext_win.cpp",
"tools/sk_app/win/Window_win.cpp",
"tools/sk_app/win/main_win.cpp",
]
if (skia_use_angle) {
sources += [ "tools/sk_app/win/ANGLEWindowContext_win.cpp" ]
}
if (skia_use_dawn) {
if (dawn_enable_d3d12) {
sources += [ "tools/sk_app/win/DawnD3D12WindowContext_win.cpp" ]
}
}
} else if (is_mac) {
sources += [
"tools/sk_app/mac/GLWindowContext_mac.mm",
"tools/sk_app/mac/RasterWindowContext_mac.mm",
"tools/sk_app/mac/Window_mac.mm",
"tools/sk_app/mac/main_mac.mm",
]
if (skia_use_dawn) {
if (dawn_enable_metal) {
sources += [ "tools/sk_app/mac/DawnMTLWindowContext_mac.mm" ]
}
}
libs += [
"QuartzCore.framework",
"Cocoa.framework",
@ -2299,7 +2279,6 @@ if (skia_enable_tools) {
]
} else if (is_ios) {
sources += [
"tools/sk_app/ios/GLWindowContext_ios.mm",
"tools/sk_app/ios/RasterWindowContext_ios.mm",
"tools/sk_app/ios/Window_ios.mm",
"tools/sk_app/ios/main_ios.mm",
@ -2307,6 +2286,24 @@ if (skia_enable_tools) {
libs += [ "QuartzCore.framework" ]
}
if (skia_use_gl) {
sources += [ "tools/sk_app/GLWindowContext.cpp" ]
if (is_android) {
sources += [ "tools/sk_app/android/GLWindowContext_android.cpp" ]
} else if (is_linux) {
sources += [ "tools/sk_app/unix/GLWindowContext_unix.cpp" ]
} else if (is_win) {
sources += [ "tools/sk_app/win/GLWindowContext_win.cpp" ]
if (skia_use_angle) {
sources += [ "tools/sk_app/win/ANGLEWindowContext_win.cpp" ]
}
} else if (is_mac) {
sources += [ "tools/sk_app/mac/GLWindowContext_mac.mm" ]
} else if (is_ios) {
sources += [ "tools/sk_app/ios/GLWindowContext_ios.mm" ]
}
}
if (skia_use_vulkan) {
sources += [ "tools/sk_app/VulkanWindowContext.cpp" ]
if (is_android) {
@ -2328,13 +2325,32 @@ if (skia_enable_tools) {
}
}
if (skia_use_dawn) {
sources += [ "tools/sk_app/DawnWindowContext.cpp" ]
if (is_linux) {
if (dawn_enable_vulkan) {
sources += [ "tools/sk_app/unix/DawnVulkanWindowContext_unix.cpp" ]
defines = [ "VK_USE_PLATFORM_XCB_KHR" ]
libs += [ "X11-xcb" ]
}
} else if (is_win) {
if (dawn_enable_d3d12) {
sources += [ "tools/sk_app/win/DawnD3D12WindowContext_win.cpp" ]
}
} else if (is_mac) {
if (dawn_enable_metal) {
sources += [ "tools/sk_app/mac/DawnMTLWindowContext_mac.mm" ]
}
}
}
deps = [
":tool_utils",
]
if (is_android) {
deps += [ "//third_party/native_app_glue" ]
}
if (skia_use_angle) {
if (skia_use_gl && skia_use_angle) {
deps += [ "//third_party/angle2" ]
}
}
@ -2360,53 +2376,57 @@ if (skia_enable_tools) {
]
}
}
test_app("viewer") {
is_shared_library = is_android
sources = [
"tools/viewer/AnimTimer.h",
"tools/viewer/BisectSlide.cpp",
"tools/viewer/GMSlide.cpp",
"tools/viewer/ImGuiLayer.cpp",
"tools/viewer/ImageSlide.cpp",
"tools/viewer/ParticlesSlide.cpp",
"tools/viewer/SKPSlide.cpp",
"tools/viewer/SampleSlide.cpp",
"tools/viewer/SkSLSlide.cpp",
"tools/viewer/SkottieSlide.cpp",
"tools/viewer/SlideDir.cpp",
"tools/viewer/StatsLayer.cpp",
"tools/viewer/SvgSlide.cpp",
"tools/viewer/TouchGesture.cpp",
"tools/viewer/TouchGesture.h",
"tools/viewer/Viewer.cpp",
]
libs = []
deps = [
":common_flags_gpu",
":experimental_svg_model",
":flags",
":gm",
":gpu_tool_utils",
":samples",
":sk_app",
":skia",
":tool_utils",
":trace",
"modules/particles",
"modules/skottie",
"modules/skottie:utils",
"modules/sksg",
"modules/sksg:samples",
"//third_party/imgui",
]
if (skia_use_experimental_xform) {
deps += [ ":experimental_xform" ]
sources += [ "gm/xform.cpp" ]
# sk_app can work without GL but viewer always runs raster through a GL window context.
if (skia_use_gl) {
test_app("viewer") {
is_shared_library = is_android
sources = [
"tools/viewer/AnimTimer.h",
"tools/viewer/BisectSlide.cpp",
"tools/viewer/GMSlide.cpp",
"tools/viewer/ImGuiLayer.cpp",
"tools/viewer/ImageSlide.cpp",
"tools/viewer/ParticlesSlide.cpp",
"tools/viewer/SKPSlide.cpp",
"tools/viewer/SampleSlide.cpp",
"tools/viewer/SkSLSlide.cpp",
"tools/viewer/SkottieSlide.cpp",
"tools/viewer/SlideDir.cpp",
"tools/viewer/StatsLayer.cpp",
"tools/viewer/SvgSlide.cpp",
"tools/viewer/TouchGesture.cpp",
"tools/viewer/TouchGesture.h",
"tools/viewer/Viewer.cpp",
]
libs = []
deps = [
":common_flags_gpu",
":experimental_svg_model",
":flags",
":gm",
":gpu_tool_utils",
":samples",
":sk_app",
":skia",
":tool_utils",
":trace",
"modules/particles",
"modules/skottie",
"modules/skottie:utils",
"modules/sksg",
"modules/sksg:samples",
"//third_party/imgui",
]
if (skia_use_experimental_xform) {
deps += [ ":experimental_xform" ]
sources += [ "gm/xform.cpp" ]
}
}
}
if (!skia_use_angle && (is_linux || is_win || is_mac)) {
if (skia_use_gl && !skia_use_angle && (is_linux || is_win || is_mac)) {
test_app("HelloWorld") {
sources = [
"example/HelloWorld.cpp",
@ -2423,8 +2443,8 @@ if (skia_enable_tools) {
}
}
if ((is_linux || is_mac || is_ios) && target_cpu != "mips64el" &&
target_cpu != "loongson3a") {
if (skia_use_gl && (is_linux || is_mac || is_ios) &&
target_cpu != "mips64el" && target_cpu != "loongson3a") {
test_app("SkiaSDLExample") {
sources = [
"example/SkiaSDLExample.cpp",
@ -2539,7 +2559,7 @@ if (skia_enable_tools) {
]
}
if (skia_use_icu && skia_use_harfbuzz) {
if (skia_use_gl && skia_use_icu && skia_use_harfbuzz) {
test_app("editor") {
is_shared_library = is_android
deps = [

View File

@ -9,6 +9,9 @@ Milestone 83
<Insert new notes here- top is most recent.>
* SkImage::makeTextureImage() takes an optional SkBudgeted param
* Made non-GL builds of GPU backend more robust.
https://review.skia.org/277456
*
* * *

View File

@ -252,6 +252,7 @@ struct GPUTarget : public Target {
return true;
}
void fillOptions(NanoJSONResultsWriter& log) override {
#ifdef SK_GL
const GrGLubyte* version;
if (this->contextInfo.backend() == GrBackendApi::kOpenGL) {
const GrGLInterface* gl =
@ -269,6 +270,7 @@ struct GPUTarget : public Target {
GR_GL_CALL_RET(gl, version, GetString(GR_GL_SHADING_LANGUAGE_VERSION));
log.appendString("GL_SHADING_LANGUAGE_VERSION", (const char*) version);
}
#endif
}
void dumpStats() override {

View File

@ -46,7 +46,7 @@ python tools/embed_resources.py \
--align 4
GN_GPU_FLAGS="\"-DSK_DISABLE_LEGACY_SHADERCONTEXT\","
WASM_GPU="-lEGL -lGLESv2 -DSK_SUPPORT_GPU=1 \
WASM_GPU="-lEGL -lGLESv2 -DSK_SUPPORT_GPU=1 -DSK_GL \
-DSK_DISABLE_LEGACY_SHADERCONTEXT --pre-js $BASE_DIR/cpu.js --pre-js $BASE_DIR/gpu.js"
# Turn off exiting while we check for ninja (which may not be on PATH)

View File

@ -22,7 +22,7 @@
#include <emscripten.h>
#include <emscripten/bind.h>
#if SK_SUPPORT_GPU
#ifdef SK_GL
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrContext.h"
#include "include/gpu/gl/GrGLInterface.h"
@ -369,7 +369,7 @@ class SkpDebugPlayer {
int fInspectedLayer = -1;
};
#if SK_SUPPORT_GPU
#ifdef SK_GL
sk_sp<GrContext> MakeGrContext(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context)
{
EMSCRIPTEN_RESULT r = emscripten_webgl_make_context_current(context);
@ -507,7 +507,7 @@ EMSCRIPTEN_BINDINGS(my_module) {
self.clear(SkColor(color));
}));
#if SK_SUPPORT_GPU
#ifdef SK_GL
class_<GrContext>("GrContext")
.smart_ptr<sk_sp<GrContext>>("sk_sp<GrContext>");
function("currentContext", &emscripten_webgl_get_current_context);

View File

@ -48,7 +48,7 @@
#include "src/utils/SkUTF.h"
#include "tools/flags/CommandLineFlags.h"
#if SK_SUPPORT_GPU
#ifdef SK_GL
#include "include/gpu/gl/GrGLFunctions.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/gl/GrGLGpu.h"
@ -1607,7 +1607,7 @@ DEF_FUZZ(SerializedImageFilter, fuzz) {
canvas.restore();
}
#if SK_SUPPORT_GPU
#ifdef SK_GL
static void dump_GPU_info(GrContext* context) {
const GrGLInterface* gl = static_cast<GrGLGpu*>(context->priv().getGpu())

View File

@ -5,9 +5,11 @@
* found in the LICENSE file.
*/
// This test only works with the GPU backend.
// This test only works with the GL backend.
#include "gm/gm.h"
#ifdef SK_GL
#include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
@ -270,3 +272,4 @@ private:
DEF_GM(return new RectangleTexture;)
}
#endif

View File

@ -15,6 +15,7 @@ tests_sources = [
"$_tests/ApplyGammaTest.cpp",
"$_tests/ArenaAllocTest.cpp",
"$_tests/AsADashTest.cpp",
"$_tests/BackendAllocationTest.cpp",
"$_tests/BadIcoTest.cpp",
"$_tests/BitSetTest.cpp",
"$_tests/BitmapCopyTest.cpp",
@ -48,6 +49,7 @@ tests_sources = [
"$_tests/ColorPrivTest.cpp",
"$_tests/ColorSpaceTest.cpp",
"$_tests/ColorTest.cpp",
"$_tests/CompressedBackendAllocationTest.cpp",
"$_tests/CopySurfaceTest.cpp",
"$_tests/CubicMapTest.cpp",
"$_tests/DebugLayerManagerTest.cpp",
@ -196,6 +198,7 @@ tests_sources = [
"$_tests/ProgramsTest.cpp",
"$_tests/PromiseImageTest.cpp",
"$_tests/ProxyConversionTest.cpp",
"$_tests/ProxyTest.cpp",
"$_tests/ProxyRefTest.cpp",
"$_tests/QuickRejectTest.cpp",
"$_tests/RRectInPathTest.cpp",
@ -217,6 +220,7 @@ tests_sources = [
"$_tests/RenderTargetContextTest.cpp",
"$_tests/RepeatedClippedBlurTest.cpp",
"$_tests/ResourceAllocatorTest.cpp",
"$_tests/ResourceCacheTest.cpp",
"$_tests/RoundRectTest.cpp",
"$_tests/SRGBReadWritePixelsTest.cpp",
"$_tests/SRGBTest.cpp",
@ -275,6 +279,7 @@ tests_sources = [
"$_tests/StrokerTest.cpp",
"$_tests/SubsetPath.cpp",
"$_tests/SubsetPath.h",
"$_tests/SurfaceSemaphoreTest.cpp",
"$_tests/SurfaceTest.cpp",
"$_tests/SwizzlerTest.cpp",
"$_tests/TArrayTest.cpp",
@ -293,6 +298,7 @@ tests_sources = [
"$_tests/TextureStripAtlasManagerTest.cpp",
"$_tests/Time.cpp",
"$_tests/TopoSortTest.cpp",
"$_tests/TraceMemoryDumpTest.cpp",
"$_tests/TracingTest.cpp",
"$_tests/TransferPixelsTest.cpp",
"$_tests/TypefaceTest.cpp",
@ -315,16 +321,10 @@ tests_sources = [
]
gl_tests_sources = [
"$_tests/BackendAllocationTest.cpp",
"$_tests/CompressedBackendAllocationTest.cpp",
"$_tests/EGLImageTest.cpp",
"$_tests/GrGLExtensionsTest.cpp",
"$_tests/ProxyTest.cpp",
"$_tests/RectangleTextureTest.cpp",
"$_tests/ResourceCacheTest.cpp",
"$_tests/SurfaceSemaphoreTest.cpp",
"$_tests/TextureBindingsResetTest.cpp",
"$_tests/TraceMemoryDumpTest.cpp",
]
metal_tests_sources = [

View File

@ -248,9 +248,15 @@
* and opting in to additional backends. TODO: Require explicit opt in for GL.
*/
#if SK_SUPPORT_GPU
# if !defined(SK_GL) && !defined(SK_VULKAN) && !defined(SK_METAL)
# if !defined(SK_GL) && !defined(SK_VULKAN) && !defined(SK_METAL) && !defined(SK_DAWN) && !defined(SK_DIRECT3D)
# define SK_GL
# endif
#else
# undef SK_GL
# undef SK_VULKAN
# undef SK_METAL
# undef SK_DAWN
# undef SK_DIRECT3D
#endif
#if !defined(SK_SUPPORT_ATLAS_TEXT)

View File

@ -47,6 +47,7 @@ class SkTraceMemoryDump;
class SK_API GrContext : public GrRecordingContext {
public:
#ifdef SK_GL
/**
* Creates a GrContext for a backend context. If no GrGLInterface is provided then the result of
* GrGLMakeNativeInterface() is used if it succeeds.
@ -55,6 +56,7 @@ public:
static sk_sp<GrContext> MakeGL(sk_sp<const GrGLInterface>);
static sk_sp<GrContext> MakeGL(const GrContextOptions&);
static sk_sp<GrContext> MakeGL();
#endif
/**
* The Vulkan context (VkQueue, VkDevice, VkInstance) must be kept alive until the returned

View File

@ -213,6 +213,7 @@ def compile_fn(api, checkout_root, out_dir):
args['is_debug'] = 'false'
if 'Dawn' in extra_tokens:
args['skia_use_dawn'] = 'true'
args['skia_use_gl'] = 'false'
# Dawn imports jinja2, which imports markupsafe. Along with DEPS, make it
# importable.
env['PYTHONPATH'] = api.path.pathsep.join([
@ -270,12 +271,15 @@ def compile_fn(api, checkout_root, out_dir):
if 'Vulkan' in extra_tokens and not 'Android' in extra_tokens:
args['skia_use_vulkan'] = 'true'
args['skia_enable_vulkan_debug_layers'] = 'true'
args['skia_use_gl'] = 'false'
if 'MoltenVK' in extra_tokens:
args['skia_moltenvk_path'] = '"%s"' % moltenvk
if 'Direct3D' in extra_tokens:
args['skia_use_direct3d'] = 'true'
args['skia_use_gl'] = 'false'
if 'Metal' in extra_tokens:
args['skia_use_metal'] = 'true'
args['skia_use_gl'] = 'false'
if 'OpenCL' in extra_tokens:
args['skia_use_opencl'] = 'true'
if api.vars.is_linux:

View File

@ -52,7 +52,7 @@
"[START_DIR]/cache/work/skia/bin/gn",
"gen",
"[START_DIR]/cache/work/skia/out/Build-Debian9-Clang-x86_64-Release-Vulkan/Release",
"--args=cc=\"[START_DIR]/clang_linux/bin/clang\" cc_wrapper=\"[START_DIR]/ccache_linux/bin/ccache\" cxx=\"[START_DIR]/clang_linux/bin/clang++\" extra_cflags=[\"-B[START_DIR]/clang_linux/bin\", \"-DDUMMY_clang_linux_version=42\"] extra_ldflags=[\"-B[START_DIR]/clang_linux/bin\", \"-fuse-ld=lld\", \"-L[START_DIR]/clang_linux/lib\"] is_debug=false skia_enable_vulkan_debug_layers=true skia_use_vulkan=true target_cpu=\"x86_64\" werror=true"
"--args=cc=\"[START_DIR]/clang_linux/bin/clang\" cc_wrapper=\"[START_DIR]/ccache_linux/bin/ccache\" cxx=\"[START_DIR]/clang_linux/bin/clang++\" extra_cflags=[\"-B[START_DIR]/clang_linux/bin\", \"-DDUMMY_clang_linux_version=42\"] extra_ldflags=[\"-B[START_DIR]/clang_linux/bin\", \"-fuse-ld=lld\", \"-L[START_DIR]/clang_linux/lib\"] is_debug=false skia_enable_vulkan_debug_layers=true skia_use_gl=false skia_use_vulkan=true target_cpu=\"x86_64\" werror=true"
],
"cwd": "[START_DIR]/cache/work/skia",
"env": {

View File

@ -70,7 +70,7 @@
"[START_DIR]/cache/work/skia/bin/gn",
"gen",
"[START_DIR]/cache/work/skia/out/Build-Mac-Clang-x86_64-Debug-Metal/Debug",
"--args=cc=\"clang\" cc_wrapper=\"[START_DIR]/ccache_mac/bin/ccache\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_xcode_build_version=11c29\", \"-O1\"] skia_use_metal=true target_cpu=\"x86_64\" werror=true"
"--args=cc=\"clang\" cc_wrapper=\"[START_DIR]/ccache_mac/bin/ccache\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_xcode_build_version=11c29\", \"-O1\"] skia_use_gl=false skia_use_metal=true target_cpu=\"x86_64\" werror=true"
],
"cwd": "[START_DIR]/cache/work/skia",
"env": {

View File

@ -70,7 +70,7 @@
"[START_DIR]/cache/work/skia/bin/gn",
"gen",
"[START_DIR]/cache/work/skia/out/Build-Mac-Clang-x86_64-Release-MoltenVK_Vulkan/Release",
"--args=cc=\"clang\" cc_wrapper=\"[START_DIR]/ccache_mac/bin/ccache\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_xcode_build_version=11c29\"] is_debug=false skia_enable_vulkan_debug_layers=true skia_moltenvk_path=\"[START_DIR]/moltenvk\" skia_use_vulkan=true target_cpu=\"x86_64\" werror=true"
"--args=cc=\"clang\" cc_wrapper=\"[START_DIR]/ccache_mac/bin/ccache\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_xcode_build_version=11c29\"] is_debug=false skia_enable_vulkan_debug_layers=true skia_moltenvk_path=\"[START_DIR]/moltenvk\" skia_use_gl=false skia_use_vulkan=true target_cpu=\"x86_64\" werror=true"
],
"cwd": "[START_DIR]/cache/work/skia",
"env": {

View File

@ -36,7 +36,7 @@
"[START_DIR]\\cache\\work\\skia\\bin\\gn",
"gen",
"[START_DIR]\\cache\\work\\skia\\out\\Build-Win-Clang-x86_64-Release-Dawn\\Release_x64",
"--args=cc=\"clang\" clang_win=\"[START_DIR]\\clang_win\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_clang_win_version=42\"] is_debug=false skia_use_dawn=true target_cpu=\"x86_64\" werror=true win_sdk=\"[START_DIR]\\win_toolchain/win_sdk\" win_vc=\"[START_DIR]\\win_toolchain/VC\""
"--args=cc=\"clang\" clang_win=\"[START_DIR]\\clang_win\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_clang_win_version=42\"] is_debug=false skia_use_dawn=true skia_use_gl=false target_cpu=\"x86_64\" werror=true win_sdk=\"[START_DIR]\\win_toolchain/win_sdk\" win_vc=\"[START_DIR]\\win_toolchain/VC\""
],
"cwd": "[START_DIR]\\cache\\work\\skia",
"env": {

View File

@ -36,7 +36,7 @@
"[START_DIR]\\cache\\work\\skia\\bin\\gn",
"gen",
"[START_DIR]\\cache\\work\\skia\\out\\Build-Win-Clang-x86_64-Release-Direct3D\\Release_x64",
"--args=cc=\"clang\" clang_win=\"[START_DIR]\\clang_win\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_clang_win_version=42\"] is_debug=false skia_use_direct3d=true target_cpu=\"x86_64\" werror=true win_sdk=\"[START_DIR]\\win_toolchain/win_sdk\" win_vc=\"[START_DIR]\\win_toolchain/VC\""
"--args=cc=\"clang\" clang_win=\"[START_DIR]\\clang_win\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_clang_win_version=42\"] is_debug=false skia_use_direct3d=true skia_use_gl=false target_cpu=\"x86_64\" werror=true win_sdk=\"[START_DIR]\\win_toolchain/win_sdk\" win_vc=\"[START_DIR]\\win_toolchain/VC\""
],
"cwd": "[START_DIR]\\cache\\work\\skia",
"env": {

View File

@ -36,7 +36,7 @@
"[START_DIR]\\cache\\work\\skia\\bin\\gn",
"gen",
"[START_DIR]\\cache\\work\\skia\\out\\Build-Win-Clang-x86_64-Release-Vulkan\\Release_x64",
"--args=cc=\"clang\" clang_win=\"[START_DIR]\\clang_win\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_clang_win_version=42\"] is_debug=false skia_enable_vulkan_debug_layers=true skia_use_vulkan=true target_cpu=\"x86_64\" werror=true win_sdk=\"[START_DIR]\\win_toolchain/win_sdk\" win_vc=\"[START_DIR]\\win_toolchain/VC\""
"--args=cc=\"clang\" clang_win=\"[START_DIR]\\clang_win\" cxx=\"clang++\" extra_cflags=[\"-DDUMMY_clang_win_version=42\"] is_debug=false skia_enable_vulkan_debug_layers=true skia_use_gl=false skia_use_vulkan=true target_cpu=\"x86_64\" werror=true win_sdk=\"[START_DIR]\\win_toolchain/win_sdk\" win_vc=\"[START_DIR]\\win_toolchain/VC\""
],
"cwd": "[START_DIR]\\cache\\work\\skia",
"env": {

View File

@ -59,7 +59,7 @@
#include <emscripten.h>
#include <emscripten/bind.h>
#if SK_SUPPORT_GPU
#ifdef SK_GL
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrContext.h"
#include "include/gpu/gl/GrGLInterface.h"
@ -147,7 +147,7 @@ SkImageInfo toSkImageInfo(const SimpleImageInfo& sii) {
return SkImageInfo::Make(sii.width, sii.height, sii.colorType, sii.alphaType);
}
#if SK_SUPPORT_GPU
#ifdef SK_GL
sk_sp<GrContext> MakeGrContext(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context)
{
EMSCRIPTEN_RESULT r = emscripten_webgl_make_context_current(context);
@ -722,7 +722,7 @@ namespace emscripten {
// types Pi, Pf"). But, we can just pretend they are numbers and cast them to be pointers and
// the compiler is happy.
EMSCRIPTEN_BINDINGS(Skia) {
#if SK_SUPPORT_GPU
#ifdef SK_GL
function("currentContext", &emscripten_webgl_get_current_context);
function("setCurrentContext", &emscripten_webgl_make_context_current);
function("MakeGrContext", &MakeGrContext);
@ -918,7 +918,7 @@ EMSCRIPTEN_BINDINGS(Skia) {
flags, &localMatrix);
}), allow_raw_pointers());
#if SK_SUPPORT_GPU
#ifdef SK_GL
class_<GrContext>("GrContext")
.smart_ptr<sk_sp<GrContext>>("sk_sp<GrContext>")
.function("getResourceCacheLimitBytes", optional_override([](GrContext& self)->size_t {

View File

@ -57,7 +57,7 @@ rm -f $BUILD_DIR/*.a
GN_GPU="skia_enable_gpu=true skia_gl_standard = \"webgl\""
GN_GPU_FLAGS="\"-DSK_DISABLE_LEGACY_SHADERCONTEXT\","
WASM_GPU="-lEGL -lGLESv2 -DSK_SUPPORT_GPU=1 \
WASM_GPU="-lEGL -lGLESv2 -DSK_SUPPORT_GPU=1 -DSK_GL \
-DSK_DISABLE_LEGACY_SHADERCONTEXT --pre-js $BASE_DIR/cpu.js --pre-js $BASE_DIR/gpu.js\
-s USE_WEBGL2=1"
if [[ $@ == *cpu* ]]; then

View File

@ -16,6 +16,7 @@
#include "src/core/SkRectPriv.h"
#include "src/gpu/GrClip.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrGpu.h"
#include "src/gpu/GrMemoryPool.h"
#include "src/gpu/GrRenderTargetContext.h"
#include "src/gpu/GrRenderTargetContextPriv.h"
@ -26,10 +27,13 @@
#include "src/gpu/ccpr/GrGSCoverageProcessor.h"
#include "src/gpu/ccpr/GrVSCoverageProcessor.h"
#include "src/gpu/geometry/GrPathUtils.h"
#include "src/gpu/gl/GrGLGpu.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/ops/GrDrawOp.h"
#ifdef SK_GL
#include "src/gpu/gl/GrGLGpu.h"
#endif
using TriPointInstance = GrCCCoverageProcessor::TriPointInstance;
using QuadPointInstance = GrCCCoverageProcessor::QuadPointInstance;
using PrimitiveType = GrCCCoverageProcessor::PrimitiveType;
@ -329,6 +333,7 @@ void CCPRGeometryView::DrawCoverageCountOp::onExecute(GrOpFlushState* state,
const SkRect& chainBounds) {
GrResourceProvider* rp = state->resourceProvider();
GrContext* context = state->gpu()->getContext();
#ifdef SK_GL
GrGLGpu* glGpu = GrBackendApi::kOpenGL == context->backend()
? static_cast<GrGLGpu*>(state->gpu())
: nullptr;
@ -337,6 +342,7 @@ void CCPRGeometryView::DrawCoverageCountOp::onExecute(GrOpFlushState* state,
// GR_GL_CALL(glGpu->glInterface(), PolygonMode(GR_GL_FRONT_AND_BACK, GR_GL_LINE));
GR_GL_CALL(glGpu->glInterface(), Enable(GR_GL_LINE_SMOOTH));
}
#endif
GrPipeline pipeline(GrScissorTest::kDisabled, SkBlendMode::kPlus,
state->drawOpArgs().outputSwizzle());
@ -399,9 +405,11 @@ void CCPRGeometryView::DrawCoverageCountOp::onExecute(GrOpFlushState* state,
stroker.drawStrokes(state, proc.get(), batchID, ibounds);
}
#ifdef SK_GL
if (glGpu) {
context->resetContext(kMisc_GrGLBackendState);
}
#endif
}
class CCPRGeometryView::Click : public Sample::Click {

View File

@ -92,6 +92,7 @@ GrBackendFormat::GrBackendFormat(GrGLenum format, GrGLenum target)
SK_ABORT("Unexpected texture target");
}
}
#endif
GrGLFormat GrBackendFormat::asGLFormat() const {
if (this->isValid() && GrBackendApi::kOpenGL == fBackend) {
@ -99,7 +100,6 @@ GrGLFormat GrBackendFormat::asGLFormat() const {
}
return GrGLFormat::kUnknown;
}
#endif
GrBackendFormat GrBackendFormat::MakeVk(const GrVkYcbcrConversionInfo& ycbcrInfo) {
SkASSERT(ycbcrInfo.isValid());

View File

@ -18,19 +18,19 @@
#include "src/gpu/GrPipeline.h"
#include "src/gpu/GrRenderTargetContextPriv.h"
#include "src/gpu/GrXferProcessor.h"
#include "tests/Test.h"
#include "tools/gpu/GrContextFactory.h"
#include "src/gpu/ops/GrDrawOp.h"
#include "src/gpu/effects/GrPorterDuffXferProcessor.h"
#include "src/gpu/effects/GrXfermodeFragmentProcessor.h"
#include "src/gpu/effects/generated/GrConfigConversionEffect.h"
#include "src/gpu/gl/GrGLGpu.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
#include "src/gpu/ops/GrDrawOp.h"
#include "tests/Test.h"
#include "tools/gpu/GrContextFactory.h"
#ifdef SK_GL
#include "src/gpu/gl/GrGLGpu.h"
#endif
/*
* A dummy processor which just tries to insert a massive key and verify that it can retrieve the
@ -343,8 +343,9 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma
#endif
static int get_programs_max_stages(const sk_gpu_test::ContextInfo& ctxInfo) {
GrContext* context = ctxInfo.grContext();
int maxStages = 6;
#ifdef SK_GL
GrContext* context = ctxInfo.grContext();
if (skiatest::IsGLContextType(ctxInfo.type())) {
GrGLGpu* gpu = static_cast<GrGLGpu*>(context->priv().getGpu());
if (kGLES_GrGLStandard == gpu->glStandard()) {
@ -367,6 +368,7 @@ static int get_programs_max_stages(const sk_gpu_test::ContextInfo& ctxInfo) {
maxStages = 3;
}
}
#endif
return maxStages;
}

View File

@ -118,6 +118,7 @@ static SkCanvas* prepare_canvas(SkCanvas * canvas) {
return canvas;
}
#ifdef SK_GL
static bool setup_backend_objects(GrContext* context,
const SkBitmap& bm,
const DrawOptions& options) {
@ -243,6 +244,7 @@ static bool setup_backend_objects(GrContext* context,
return true;
}
#endif
int main(int argc, char** argv) {
CommandLineFlags::Parse(argc, argv);
@ -289,6 +291,7 @@ int main(int argc, char** argv) {
draw(prepare_canvas(rasterSurface->getCanvas()));
rasterData = encode_snapshot(rasterSurface);
}
#ifdef SK_GL
if (options.gpu) {
std::unique_ptr<sk_gpu_test::GLTestContext> glContext;
sk_sp<GrContext> grContext = create_grcontext(gGLDriverInfo, &glContext);
@ -310,6 +313,7 @@ int main(int argc, char** argv) {
gpuData = encode_snapshot(surface);
}
}
#endif
if (options.pdf) {
SkDynamicMemoryWStream pdfStream;
auto document = SkPDF::MakeDocument(&pdfStream);

View File

@ -160,7 +160,9 @@ private:
bool fAbandoned;
};
SkTArray<Context, true> fContexts;
#ifdef SK_GL
std::unique_ptr<GLTestContext> fSentinelGLContext;
#endif
const GrContextOptions fGlobalOptions;
};
@ -176,10 +178,12 @@ public:
TestContext* testContext() const { return fTestContext; }
#ifdef SK_GL
GLTestContext* glContext() const {
SkASSERT(GrBackendApi::kOpenGL == this->backend());
return static_cast<GLTestContext*>(fTestContext);
}
#endif
const GrContextOptions& options() const { return fOptions; }

View File

@ -45,7 +45,9 @@ public:
virtual bool scaleContentToFit() const { return false; }
enum BackendType {
#ifdef SK_GL
kNativeGL_BackendType,
#endif
#if SK_ANGLE && defined(SK_BUILD_FOR_WIN)
kANGLE_BackendType,
#endif

View File

@ -47,11 +47,15 @@ bool Window_android::attach(BackendType attachType) {
void Window_android::initDisplay(ANativeWindow* window) {
SkASSERT(window);
switch (fBackendType) {
#ifdef SK_GL
case kNativeGL_BackendType:
default:
fWindowContext =
window_context_factory::MakeGLForAndroid(window, fRequestedDisplayParams);
break;
#else
default:
#endif
case kRaster_BackendType:
fWindowContext =
window_context_factory::MakeRasterForAndroid(window, fRequestedDisplayParams);

View File

@ -80,18 +80,22 @@ bool Window_ios::attach(BackendType attachType) {
info.fWindow = this;
info.fViewController = fWindow.rootViewController;
switch (attachType) {
case kRaster_BackendType:
fWindowContext = MakeRasterForIOS(info, fRequestedDisplayParams);
break;
#ifdef SK_METAL
case kMetal_BackendType:
fWindowContext = MakeMetalForIOS(info, fRequestedDisplayParams);
break;
#endif
#ifdef SK_GL
case kNativeGL_BackendType:
default:
fWindowContext = MakeGLForIOS(info, fRequestedDisplayParams);
break;
#else
default:
#endif
case kRaster_BackendType:
fWindowContext = MakeRasterForIOS(info, fRequestedDisplayParams);
break;
}
this->onBackendCreated();

View File

@ -119,9 +119,6 @@ bool Window_mac::attach(BackendType attachType) {
window_context_factory::MacWindowInfo info;
info.fMainView = [fWindow contentView];
switch (attachType) {
case kRaster_BackendType:
fWindowContext = MakeRasterForMac(info, fRequestedDisplayParams);
break;
#ifdef SK_DAWN
case kDawn_BackendType:
fWindowContext = MakeDawnMTLForMac(info, fRequestedDisplayParams);
@ -137,10 +134,17 @@ bool Window_mac::attach(BackendType attachType) {
fWindowContext = MakeMetalForMac(info, fRequestedDisplayParams);
break;
#endif
#ifdef SK_GL
case kNativeGL_BackendType:
default:
fWindowContext = MakeGLForMac(info, fRequestedDisplayParams);
break;
#else
default:
#endif
case kRaster_BackendType:
fWindowContext = MakeRasterForMac(info, fRequestedDisplayParams);
break;
}
this->onBackendCreated();

View File

@ -370,10 +370,12 @@ bool Window_unix::attach(BackendType attachType) {
window_context_factory::MakeVulkanForXlib(winInfo, fRequestedDisplayParams);
break;
#endif
#ifdef SK_GL
case kNativeGL_BackendType:
fWindowContext =
window_context_factory::MakeGLForXlib(winInfo, fRequestedDisplayParams);
break;
#endif
case kRaster_BackendType:
fWindowContext =
window_context_factory::MakeRasterForXlib(winInfo, fRequestedDisplayParams);

View File

@ -350,9 +350,11 @@ bool Window_win::attach(BackendType attachType) {
fBackend = attachType;
switch (attachType) {
#ifdef SK_GL
case kNativeGL_BackendType:
fWindowContext = window_context_factory::MakeGLForWin(fHWnd, fRequestedDisplayParams);
break;
#endif
#if SK_ANGLE
case kANGLE_BackendType:
fWindowContext =

View File

@ -49,6 +49,7 @@ sk_sp<SkData> Request::writeCanvasToPng(SkCanvas* canvas) {
}
SkCanvas* Request::getCanvas() {
#ifdef SK_GL
GrContextFactory* factory = fContextFactory;
GLTestContext* gl = factory->getContextInfo(GrContextFactory::kGL_ContextType,
GrContextFactory::ContextOverrides::kNone).glContext();
@ -59,6 +60,7 @@ SkCanvas* Request::getCanvas() {
if (gl) {
gl->makeCurrent();
}
#endif
SkASSERT(fDebugCanvas);
// create the appropriate surface if necessary

View File

@ -11,9 +11,11 @@
#include "include/gpu/GrContextOptions.h"
#include "include/gpu/gl/GrGLInterface.h"
#ifdef SK_GL
GrContextHolder SkMakeGLContext() {
return GrContextHolder(GrContext::MakeGL(nullptr, GrContextOptions()).release());
}
#endif
void GrContextRelease::operator()(GrContext* ptr) { SkSafeUnref(ptr); }

View File

@ -131,6 +131,10 @@ static DEFINE_bool(redraw, false, "Toggle continuous redraw.");
static DEFINE_bool(offscreen, false, "Force rendering to an offscreen surface.");
#ifndef SK_GL
static_assert(false, "viewer requires GL backend for raster.")
#endif
const char* kBackendTypeStrings[sk_app::Window::kBackendTypeCount] = {
"OpenGL",
#if SK_ANGLE && defined(SK_BUILD_FOR_WIN)