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

122
BUILD.gn
View File

@ -74,7 +74,7 @@ config("skia_private") {
} }
libs = [] libs = []
lib_dirs = [] lib_dirs = []
if (skia_use_angle) { if (skia_use_gl && skia_use_angle) {
defines += [ "SK_ANGLE" ] defines += [ "SK_ANGLE" ]
} }
} }
@ -531,6 +531,9 @@ optional("gpu") {
} }
libs = [] libs = []
if (skia_use_gl) {
public_defines += [ "SK_GL" ]
if (is_android) { if (is_android) {
sources += [ "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ] sources += [ "src/gpu/gl/egl/GrGLMakeNativeInterface_egl.cpp" ]
@ -556,11 +559,9 @@ optional("gpu") {
} else { } else {
sources += [ "src/gpu/gl/GrGLMakeNativeInterface_none.cpp" ] sources += [ "src/gpu/gl/GrGLMakeNativeInterface_none.cpp" ]
} }
if (skia_use_gl) {
public_defines += [ "SK_GL" ]
sources += skia_gl_gpu_sources sources += skia_gl_gpu_sources
} }
if (skia_use_vulkan) { if (skia_use_vulkan) {
public_defines += [ "SK_VULKAN" ] public_defines += [ "SK_VULKAN" ]
deps += [ "third_party/vulkanmemoryallocator" ] 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) { if (skia_use_dawn) {
public_defines += [ "SK_DAWN" ] public_defines += [ "SK_DAWN" ]
sources += skia_dawn_sources sources += skia_dawn_sources
@ -1376,16 +1384,15 @@ if (skia_enable_tools) {
"tools/gpu/YUVUtils.h", "tools/gpu/YUVUtils.h",
"tools/gpu/mock/MockTestContext.cpp", "tools/gpu/mock/MockTestContext.cpp",
] ]
libs = []
if (skia_use_gl) { if (skia_use_gl) {
sources += [ sources += [
"tools/gpu/atlastext/GLTestAtlasTextRenderer.cpp", "tools/gpu/atlastext/GLTestAtlasTextRenderer.cpp",
"tools/gpu/gl/GLTestContext.cpp", "tools/gpu/gl/GLTestContext.cpp",
"tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp", "tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp",
] ]
}
libs = []
if (is_android || skia_use_egl) { if (is_android || skia_use_egl) {
sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ] sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
} else if (is_ios) { } else if (is_ios) {
@ -1405,17 +1412,12 @@ if (skia_enable_tools) {
if (target_cpu != "arm64") { if (target_cpu != "arm64") {
libs += [ "OpenGL32.lib" ] libs += [ "OpenGL32.lib" ]
} }
} 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) { if (skia_use_angle) {
deps += [ "//third_party/angle2" ] deps += [ "//third_party/angle2" ]
sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ] sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
} }
}
if (skia_use_vulkan) { if (skia_use_vulkan) {
sources += [ "tools/gpu/vk/VkTestContext.cpp" ] sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
@ -1433,6 +1435,13 @@ if (skia_enable_tools) {
sources += [ "tools/gpu/dawn/DawnTestContext.cpp" ] sources += [ "tools/gpu/dawn/DawnTestContext.cpp" ]
cflags_cc = [ "-Wno-microsoft-cast" ] 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("gpu_tool_utils")
test_lib("flags") { test_lib("flags") {
@ -2183,7 +2192,7 @@ if (skia_enable_tools) {
libs = [ "android" ] libs = [ "android" ]
} }
} }
if (is_android && skia_enable_gpu) { if (is_android && skia_use_gl) {
test_app("skottie_android") { test_app("skottie_android") {
is_shared_library = true is_shared_library = true
@ -2228,18 +2237,12 @@ if (skia_enable_tools) {
] ]
sources = [ sources = [
"tools/sk_app/CommandSet.cpp", "tools/sk_app/CommandSet.cpp",
"tools/sk_app/GLWindowContext.cpp",
"tools/sk_app/Window.cpp", "tools/sk_app/Window.cpp",
] ]
libs = [] libs = []
if (skia_use_dawn) {
sources += [ "tools/sk_app/DawnWindowContext.cpp" ]
}
if (is_android) { if (is_android) {
sources += [ sources += [
"tools/sk_app/android/GLWindowContext_android.cpp",
"tools/sk_app/android/RasterWindowContext_android.cpp", "tools/sk_app/android/RasterWindowContext_android.cpp",
"tools/sk_app/android/Window_android.cpp", "tools/sk_app/android/Window_android.cpp",
"tools/sk_app/android/main_android.cpp", "tools/sk_app/android/main_android.cpp",
@ -2248,50 +2251,27 @@ if (skia_enable_tools) {
libs += [ "android" ] libs += [ "android" ]
} else if (is_linux) { } else if (is_linux) {
sources += [ sources += [
"tools/sk_app/unix/GLWindowContext_unix.cpp",
"tools/sk_app/unix/RasterWindowContext_unix.cpp", "tools/sk_app/unix/RasterWindowContext_unix.cpp",
"tools/sk_app/unix/Window_unix.cpp", "tools/sk_app/unix/Window_unix.cpp",
"tools/sk_app/unix/keysym2ucs.c", "tools/sk_app/unix/keysym2ucs.c",
"tools/sk_app/unix/main_unix.cpp", "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 += [ libs += [
"GL", "GL", # Used by raster window context, so cannot be behind skia_use_gl.
"X11", "X11",
] ]
} else if (is_win) { } else if (is_win) {
sources += [ sources += [
"tools/sk_app/win/GLWindowContext_win.cpp",
"tools/sk_app/win/RasterWindowContext_win.cpp", "tools/sk_app/win/RasterWindowContext_win.cpp",
"tools/sk_app/win/Window_win.cpp", "tools/sk_app/win/Window_win.cpp",
"tools/sk_app/win/main_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) { } else if (is_mac) {
sources += [ sources += [
"tools/sk_app/mac/GLWindowContext_mac.mm",
"tools/sk_app/mac/RasterWindowContext_mac.mm", "tools/sk_app/mac/RasterWindowContext_mac.mm",
"tools/sk_app/mac/Window_mac.mm", "tools/sk_app/mac/Window_mac.mm",
"tools/sk_app/mac/main_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 += [ libs += [
"QuartzCore.framework", "QuartzCore.framework",
"Cocoa.framework", "Cocoa.framework",
@ -2299,7 +2279,6 @@ if (skia_enable_tools) {
] ]
} else if (is_ios) { } else if (is_ios) {
sources += [ sources += [
"tools/sk_app/ios/GLWindowContext_ios.mm",
"tools/sk_app/ios/RasterWindowContext_ios.mm", "tools/sk_app/ios/RasterWindowContext_ios.mm",
"tools/sk_app/ios/Window_ios.mm", "tools/sk_app/ios/Window_ios.mm",
"tools/sk_app/ios/main_ios.mm", "tools/sk_app/ios/main_ios.mm",
@ -2307,6 +2286,24 @@ if (skia_enable_tools) {
libs += [ "QuartzCore.framework" ] 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) { if (skia_use_vulkan) {
sources += [ "tools/sk_app/VulkanWindowContext.cpp" ] sources += [ "tools/sk_app/VulkanWindowContext.cpp" ]
if (is_android) { 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 = [ deps = [
":tool_utils", ":tool_utils",
] ]
if (is_android) { if (is_android) {
deps += [ "//third_party/native_app_glue" ] deps += [ "//third_party/native_app_glue" ]
} }
if (skia_use_angle) { if (skia_use_gl && skia_use_angle) {
deps += [ "//third_party/angle2" ] deps += [ "//third_party/angle2" ]
} }
} }
@ -2360,6 +2376,9 @@ if (skia_enable_tools) {
] ]
} }
} }
# sk_app can work without GL but viewer always runs raster through a GL window context.
if (skia_use_gl) {
test_app("viewer") { test_app("viewer") {
is_shared_library = is_android is_shared_library = is_android
sources = [ sources = [
@ -2405,8 +2424,9 @@ if (skia_enable_tools) {
sources += [ "gm/xform.cpp" ] 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") { test_app("HelloWorld") {
sources = [ sources = [
"example/HelloWorld.cpp", "example/HelloWorld.cpp",
@ -2423,8 +2443,8 @@ if (skia_enable_tools) {
} }
} }
if ((is_linux || is_mac || is_ios) && target_cpu != "mips64el" && if (skia_use_gl && (is_linux || is_mac || is_ios) &&
target_cpu != "loongson3a") { target_cpu != "mips64el" && target_cpu != "loongson3a") {
test_app("SkiaSDLExample") { test_app("SkiaSDLExample") {
sources = [ sources = [
"example/SkiaSDLExample.cpp", "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") { test_app("editor") {
is_shared_library = is_android is_shared_library = is_android
deps = [ deps = [

View File

@ -9,6 +9,9 @@ Milestone 83
<Insert new notes here- top is most recent.> <Insert new notes here- top is most recent.>
* SkImage::makeTextureImage() takes an optional SkBudgeted param * 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; return true;
} }
void fillOptions(NanoJSONResultsWriter& log) override { void fillOptions(NanoJSONResultsWriter& log) override {
#ifdef SK_GL
const GrGLubyte* version; const GrGLubyte* version;
if (this->contextInfo.backend() == GrBackendApi::kOpenGL) { if (this->contextInfo.backend() == GrBackendApi::kOpenGL) {
const GrGLInterface* gl = const GrGLInterface* gl =
@ -269,6 +270,7 @@ struct GPUTarget : public Target {
GR_GL_CALL_RET(gl, version, GetString(GR_GL_SHADING_LANGUAGE_VERSION)); GR_GL_CALL_RET(gl, version, GetString(GR_GL_SHADING_LANGUAGE_VERSION));
log.appendString("GL_SHADING_LANGUAGE_VERSION", (const char*) version); log.appendString("GL_SHADING_LANGUAGE_VERSION", (const char*) version);
} }
#endif
} }
void dumpStats() override { void dumpStats() override {

View File

@ -46,7 +46,7 @@ python tools/embed_resources.py \
--align 4 --align 4
GN_GPU_FLAGS="\"-DSK_DISABLE_LEGACY_SHADERCONTEXT\"," 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" -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) # 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.h>
#include <emscripten/bind.h> #include <emscripten/bind.h>
#if SK_SUPPORT_GPU #ifdef SK_GL
#include "include/gpu/GrBackendSurface.h" #include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrContext.h" #include "include/gpu/GrContext.h"
#include "include/gpu/gl/GrGLInterface.h" #include "include/gpu/gl/GrGLInterface.h"
@ -369,7 +369,7 @@ class SkpDebugPlayer {
int fInspectedLayer = -1; int fInspectedLayer = -1;
}; };
#if SK_SUPPORT_GPU #ifdef SK_GL
sk_sp<GrContext> MakeGrContext(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context) sk_sp<GrContext> MakeGrContext(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context)
{ {
EMSCRIPTEN_RESULT r = emscripten_webgl_make_context_current(context); EMSCRIPTEN_RESULT r = emscripten_webgl_make_context_current(context);
@ -507,7 +507,7 @@ EMSCRIPTEN_BINDINGS(my_module) {
self.clear(SkColor(color)); self.clear(SkColor(color));
})); }));
#if SK_SUPPORT_GPU #ifdef SK_GL
class_<GrContext>("GrContext") class_<GrContext>("GrContext")
.smart_ptr<sk_sp<GrContext>>("sk_sp<GrContext>"); .smart_ptr<sk_sp<GrContext>>("sk_sp<GrContext>");
function("currentContext", &emscripten_webgl_get_current_context); function("currentContext", &emscripten_webgl_get_current_context);

View File

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

View File

@ -5,9 +5,11 @@
* found in the LICENSE file. * 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" #include "gm/gm.h"
#ifdef SK_GL
#include "include/core/SkBitmap.h" #include "include/core/SkBitmap.h"
#include "include/core/SkCanvas.h" #include "include/core/SkCanvas.h"
#include "include/core/SkColor.h" #include "include/core/SkColor.h"
@ -270,3 +272,4 @@ private:
DEF_GM(return new RectangleTexture;) DEF_GM(return new RectangleTexture;)
} }
#endif

View File

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

View File

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

View File

@ -47,6 +47,7 @@ class SkTraceMemoryDump;
class SK_API GrContext : public GrRecordingContext { class SK_API GrContext : public GrRecordingContext {
public: public:
#ifdef SK_GL
/** /**
* Creates a GrContext for a backend context. If no GrGLInterface is provided then the result of * Creates a GrContext for a backend context. If no GrGLInterface is provided then the result of
* GrGLMakeNativeInterface() is used if it succeeds. * 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(sk_sp<const GrGLInterface>);
static sk_sp<GrContext> MakeGL(const GrContextOptions&); static sk_sp<GrContext> MakeGL(const GrContextOptions&);
static sk_sp<GrContext> MakeGL(); static sk_sp<GrContext> MakeGL();
#endif
/** /**
* The Vulkan context (VkQueue, VkDevice, VkInstance) must be kept alive until the returned * 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' args['is_debug'] = 'false'
if 'Dawn' in extra_tokens: if 'Dawn' in extra_tokens:
args['skia_use_dawn'] = 'true' args['skia_use_dawn'] = 'true'
args['skia_use_gl'] = 'false'
# Dawn imports jinja2, which imports markupsafe. Along with DEPS, make it # Dawn imports jinja2, which imports markupsafe. Along with DEPS, make it
# importable. # importable.
env['PYTHONPATH'] = api.path.pathsep.join([ 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: if 'Vulkan' in extra_tokens and not 'Android' in extra_tokens:
args['skia_use_vulkan'] = 'true' args['skia_use_vulkan'] = 'true'
args['skia_enable_vulkan_debug_layers'] = 'true' args['skia_enable_vulkan_debug_layers'] = 'true'
args['skia_use_gl'] = 'false'
if 'MoltenVK' in extra_tokens: if 'MoltenVK' in extra_tokens:
args['skia_moltenvk_path'] = '"%s"' % moltenvk args['skia_moltenvk_path'] = '"%s"' % moltenvk
if 'Direct3D' in extra_tokens: if 'Direct3D' in extra_tokens:
args['skia_use_direct3d'] = 'true' args['skia_use_direct3d'] = 'true'
args['skia_use_gl'] = 'false'
if 'Metal' in extra_tokens: if 'Metal' in extra_tokens:
args['skia_use_metal'] = 'true' args['skia_use_metal'] = 'true'
args['skia_use_gl'] = 'false'
if 'OpenCL' in extra_tokens: if 'OpenCL' in extra_tokens:
args['skia_use_opencl'] = 'true' args['skia_use_opencl'] = 'true'
if api.vars.is_linux: if api.vars.is_linux:

View File

@ -52,7 +52,7 @@
"[START_DIR]/cache/work/skia/bin/gn", "[START_DIR]/cache/work/skia/bin/gn",
"gen", "gen",
"[START_DIR]/cache/work/skia/out/Build-Debian9-Clang-x86_64-Release-Vulkan/Release", "[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", "cwd": "[START_DIR]/cache/work/skia",
"env": { "env": {

View File

@ -70,7 +70,7 @@
"[START_DIR]/cache/work/skia/bin/gn", "[START_DIR]/cache/work/skia/bin/gn",
"gen", "gen",
"[START_DIR]/cache/work/skia/out/Build-Mac-Clang-x86_64-Debug-Metal/Debug", "[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", "cwd": "[START_DIR]/cache/work/skia",
"env": { "env": {

View File

@ -70,7 +70,7 @@
"[START_DIR]/cache/work/skia/bin/gn", "[START_DIR]/cache/work/skia/bin/gn",
"gen", "gen",
"[START_DIR]/cache/work/skia/out/Build-Mac-Clang-x86_64-Release-MoltenVK_Vulkan/Release", "[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", "cwd": "[START_DIR]/cache/work/skia",
"env": { "env": {

View File

@ -36,7 +36,7 @@
"[START_DIR]\\cache\\work\\skia\\bin\\gn", "[START_DIR]\\cache\\work\\skia\\bin\\gn",
"gen", "gen",
"[START_DIR]\\cache\\work\\skia\\out\\Build-Win-Clang-x86_64-Release-Dawn\\Release_x64", "[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", "cwd": "[START_DIR]\\cache\\work\\skia",
"env": { "env": {

View File

@ -36,7 +36,7 @@
"[START_DIR]\\cache\\work\\skia\\bin\\gn", "[START_DIR]\\cache\\work\\skia\\bin\\gn",
"gen", "gen",
"[START_DIR]\\cache\\work\\skia\\out\\Build-Win-Clang-x86_64-Release-Direct3D\\Release_x64", "[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", "cwd": "[START_DIR]\\cache\\work\\skia",
"env": { "env": {

View File

@ -36,7 +36,7 @@
"[START_DIR]\\cache\\work\\skia\\bin\\gn", "[START_DIR]\\cache\\work\\skia\\bin\\gn",
"gen", "gen",
"[START_DIR]\\cache\\work\\skia\\out\\Build-Win-Clang-x86_64-Release-Vulkan\\Release_x64", "[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", "cwd": "[START_DIR]\\cache\\work\\skia",
"env": { "env": {

View File

@ -59,7 +59,7 @@
#include <emscripten.h> #include <emscripten.h>
#include <emscripten/bind.h> #include <emscripten/bind.h>
#if SK_SUPPORT_GPU #ifdef SK_GL
#include "include/gpu/GrBackendSurface.h" #include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrContext.h" #include "include/gpu/GrContext.h"
#include "include/gpu/gl/GrGLInterface.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); 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) sk_sp<GrContext> MakeGrContext(EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context)
{ {
EMSCRIPTEN_RESULT r = emscripten_webgl_make_context_current(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 // types Pi, Pf"). But, we can just pretend they are numbers and cast them to be pointers and
// the compiler is happy. // the compiler is happy.
EMSCRIPTEN_BINDINGS(Skia) { EMSCRIPTEN_BINDINGS(Skia) {
#if SK_SUPPORT_GPU #ifdef SK_GL
function("currentContext", &emscripten_webgl_get_current_context); function("currentContext", &emscripten_webgl_get_current_context);
function("setCurrentContext", &emscripten_webgl_make_context_current); function("setCurrentContext", &emscripten_webgl_make_context_current);
function("MakeGrContext", &MakeGrContext); function("MakeGrContext", &MakeGrContext);
@ -918,7 +918,7 @@ EMSCRIPTEN_BINDINGS(Skia) {
flags, &localMatrix); flags, &localMatrix);
}), allow_raw_pointers()); }), allow_raw_pointers());
#if SK_SUPPORT_GPU #ifdef SK_GL
class_<GrContext>("GrContext") class_<GrContext>("GrContext")
.smart_ptr<sk_sp<GrContext>>("sk_sp<GrContext>") .smart_ptr<sk_sp<GrContext>>("sk_sp<GrContext>")
.function("getResourceCacheLimitBytes", optional_override([](GrContext& self)->size_t { .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="skia_enable_gpu=true skia_gl_standard = \"webgl\""
GN_GPU_FLAGS="\"-DSK_DISABLE_LEGACY_SHADERCONTEXT\"," 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\ -DSK_DISABLE_LEGACY_SHADERCONTEXT --pre-js $BASE_DIR/cpu.js --pre-js $BASE_DIR/gpu.js\
-s USE_WEBGL2=1" -s USE_WEBGL2=1"
if [[ $@ == *cpu* ]]; then if [[ $@ == *cpu* ]]; then

View File

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

View File

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

View File

@ -18,19 +18,19 @@
#include "src/gpu/GrPipeline.h" #include "src/gpu/GrPipeline.h"
#include "src/gpu/GrRenderTargetContextPriv.h" #include "src/gpu/GrRenderTargetContextPriv.h"
#include "src/gpu/GrXferProcessor.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/GrPorterDuffXferProcessor.h"
#include "src/gpu/effects/GrXfermodeFragmentProcessor.h" #include "src/gpu/effects/GrXfermodeFragmentProcessor.h"
#include "src/gpu/effects/generated/GrConfigConversionEffect.h" #include "src/gpu/effects/generated/GrConfigConversionEffect.h"
#include "src/gpu/gl/GrGLGpu.h"
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h" #include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h" #include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/glsl/GrGLSLProgramBuilder.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 * 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 #endif
static int get_programs_max_stages(const sk_gpu_test::ContextInfo& ctxInfo) { static int get_programs_max_stages(const sk_gpu_test::ContextInfo& ctxInfo) {
GrContext* context = ctxInfo.grContext();
int maxStages = 6; int maxStages = 6;
#ifdef SK_GL
GrContext* context = ctxInfo.grContext();
if (skiatest::IsGLContextType(ctxInfo.type())) { if (skiatest::IsGLContextType(ctxInfo.type())) {
GrGLGpu* gpu = static_cast<GrGLGpu*>(context->priv().getGpu()); GrGLGpu* gpu = static_cast<GrGLGpu*>(context->priv().getGpu());
if (kGLES_GrGLStandard == gpu->glStandard()) { if (kGLES_GrGLStandard == gpu->glStandard()) {
@ -367,6 +368,7 @@ static int get_programs_max_stages(const sk_gpu_test::ContextInfo& ctxInfo) {
maxStages = 3; maxStages = 3;
} }
} }
#endif
return maxStages; return maxStages;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,9 +11,11 @@
#include "include/gpu/GrContextOptions.h" #include "include/gpu/GrContextOptions.h"
#include "include/gpu/gl/GrGLInterface.h" #include "include/gpu/gl/GrGLInterface.h"
#ifdef SK_GL
GrContextHolder SkMakeGLContext() { GrContextHolder SkMakeGLContext() {
return GrContextHolder(GrContext::MakeGL(nullptr, GrContextOptions()).release()); return GrContextHolder(GrContext::MakeGL(nullptr, GrContextOptions()).release());
} }
#endif
void GrContextRelease::operator()(GrContext* ptr) { SkSafeUnref(ptr); } 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."); 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] = { const char* kBackendTypeStrings[sk_app::Window::kBackendTypeCount] = {
"OpenGL", "OpenGL",
#if SK_ANGLE && defined(SK_BUILD_FOR_WIN) #if SK_ANGLE && defined(SK_BUILD_FOR_WIN)