aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2016-03-30 08:35:09 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-30 08:35:09 -0700
commitfe3456cb006110d045b26ff3f8681b893a757b58 (patch)
tree8d07fbc43230b807d0cf7174c79d5757c397b07f
parentb4a7f144b41dbe8341d26abb71d87b13d072a5cf (diff)
Move SkGLContext and some GrGLInterface implementations to skgputest module
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1815823002 CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Ubuntu-GCC-x86_64-Release-CMake-Trybot,Build-Mac-Clang-x86_64-Release-CMake-Trybot Review URL: https://codereview.chromium.org/1815823002
-rw-r--r--bench/nanobench.cpp19
-rw-r--r--bench/nanobench.h4
-rw-r--r--cmake/CMakeLists.txt3
-rw-r--r--dm/DM.cpp4
-rw-r--r--dm/DMGpuSupport.h21
-rw-r--r--dm/DMSrcSink.cpp2
-rw-r--r--dm/DMSrcSink.h17
-rw-r--r--gm/image.cpp2
-rw-r--r--gyp/SampleApp.gyp1
-rw-r--r--gyp/flags.gyp9
-rw-r--r--gyp/gpu.gyp56
-rw-r--r--gyp/gpu.gypi59
-rw-r--r--gyp/gputest.gyp79
-rw-r--r--gyp/kilobench.gyp2
-rw-r--r--gyp/pathops_unittest.gyp9
-rw-r--r--gyp/skiaserve.gyp1
-rw-r--r--gyp/visualbench.gyp1
-rw-r--r--include/gpu/gl/GrGLInterface.h31
-rw-r--r--include/gpu/gl/SkNullGLContext.h26
-rw-r--r--include/gpu/gl/angle/SkANGLEGLContext.h61
-rw-r--r--include/gpu/gl/command_buffer/SkCommandBufferGLContext.h63
-rw-r--r--samplecode/SampleApp.cpp15
-rw-r--r--src/gpu/gl/GrGLTestInterface.h4
-rw-r--r--src/gpu/gl/SkNullGLContext.cpp26
-rw-r--r--src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp57
-rw-r--r--src/gpu/gl/debug/SkDebugGLContext.cpp16
-rw-r--r--src/gpu/gl/debug/SkDebugGLContext.h27
-rw-r--r--src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp24
-rw-r--r--src/gpu/gl/mesa/SkMesaGLContext.h44
-rw-r--r--src/gpu/gl/nacl/SkCreatePlatformGLContext_nacl.cpp12
-rw-r--r--src/views/win/SkOSWindow_win.cpp32
-rw-r--r--tests/EGLImageTest.cpp8
-rw-r--r--tests/GLProgramsTest.cpp2
-rw-r--r--tests/GrContextFactoryTest.cpp2
-rw-r--r--tests/GrPorterDuffTest.cpp4
-rw-r--r--tests/ImageTest.cpp2
-rw-r--r--tests/RectangleTextureTest.cpp2
-rw-r--r--tests/Test.h32
-rw-r--r--tests/TestConfigParsing.cpp2
-rw-r--r--tests/TestTest.cpp4
-rw-r--r--tests/TextureStorageAllocator.cpp2
-rw-r--r--tests/skia_test.cpp1
-rw-r--r--tools/VisualBench/VisualBench.h2
-rw-r--r--tools/flags/SkCommonFlagsConfig.cpp4
-rw-r--r--tools/flags/SkCommonFlagsConfig.h2
-rwxr-xr-xtools/gpu/GrContextFactory.cpp (renamed from src/gpu/GrContextFactory.cpp)41
-rw-r--r--tools/gpu/GrContextFactory.h (renamed from src/gpu/GrContextFactory.h)19
-rw-r--r--tools/gpu/GrTest.cpp (renamed from src/gpu/GrTest.cpp)0
-rw-r--r--tools/gpu/GrTest.h (renamed from src/gpu/GrTest.h)0
-rw-r--r--tools/gpu/gl/GLContext.cpp (renamed from src/gpu/gl/SkGLContext.cpp)45
-rw-r--r--tools/gpu/gl/GLContext.h (renamed from include/gpu/gl/SkGLContext.h)70
-rw-r--r--tools/gpu/gl/angle/GLContext_angle.cpp (renamed from src/gpu/gl/angle/SkANGLEGLContext.cpp)149
-rw-r--r--tools/gpu/gl/angle/GLContext_angle.h30
-rw-r--r--tools/gpu/gl/command_buffer/GLContext_command_buffer.cpp (renamed from src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp)71
-rw-r--r--tools/gpu/gl/command_buffer/GLContext_command_buffer.h68
-rw-r--r--tools/gpu/gl/debug/DebugGLContext.cpp (renamed from src/gpu/gl/debug/GrGLCreateDebugInterface.cpp)478
-rw-r--r--tools/gpu/gl/debug/DebugGLContext.h17
-rw-r--r--tools/gpu/gl/debug/GrBufferObj.cpp (renamed from src/gpu/gl/debug/GrBufferObj.cpp)1
-rw-r--r--tools/gpu/gl/debug/GrBufferObj.h (renamed from src/gpu/gl/debug/GrBufferObj.h)3
-rw-r--r--tools/gpu/gl/debug/GrFBBindableObj.h (renamed from src/gpu/gl/debug/GrFBBindableObj.h)1
-rw-r--r--tools/gpu/gl/debug/GrFakeRefObj.h (renamed from src/gpu/gl/debug/GrFakeRefObj.h)0
-rw-r--r--tools/gpu/gl/debug/GrFrameBufferObj.cpp (renamed from src/gpu/gl/debug/GrFrameBufferObj.cpp)1
-rw-r--r--tools/gpu/gl/debug/GrFrameBufferObj.h (renamed from src/gpu/gl/debug/GrFrameBufferObj.h)1
-rw-r--r--tools/gpu/gl/debug/GrProgramObj.cpp (renamed from src/gpu/gl/debug/GrProgramObj.cpp)1
-rw-r--r--tools/gpu/gl/debug/GrProgramObj.h (renamed from src/gpu/gl/debug/GrProgramObj.h)1
-rw-r--r--tools/gpu/gl/debug/GrRenderBufferObj.h (renamed from src/gpu/gl/debug/GrRenderBufferObj.h)1
-rw-r--r--tools/gpu/gl/debug/GrShaderObj.cpp (renamed from src/gpu/gl/debug/GrShaderObj.cpp)1
-rw-r--r--tools/gpu/gl/debug/GrShaderObj.h (renamed from src/gpu/gl/debug/GrShaderObj.h)3
-rw-r--r--tools/gpu/gl/debug/GrTextureObj.cpp (renamed from src/gpu/gl/debug/GrTextureObj.cpp)1
-rw-r--r--tools/gpu/gl/debug/GrTextureObj.h (renamed from src/gpu/gl/debug/GrTextureObj.h)1
-rw-r--r--tools/gpu/gl/debug/GrTextureUnitObj.cpp (renamed from src/gpu/gl/debug/GrTextureUnitObj.cpp)1
-rw-r--r--tools/gpu/gl/debug/GrTextureUnitObj.h (renamed from src/gpu/gl/debug/GrTextureUnitObj.h)0
-rw-r--r--tools/gpu/gl/debug/GrVertexArrayObj.h (renamed from src/gpu/gl/debug/GrVertexArrayObj.h)0
-rw-r--r--tools/gpu/gl/egl/CreatePlatformGLContext_egl.cpp (renamed from src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp)20
-rw-r--r--tools/gpu/gl/glx/CreatePlatformGLContext_glx.cpp (renamed from src/gpu/gl/glx/SkCreatePlatformGLContext_glx.cpp)13
-rw-r--r--tools/gpu/gl/iOS/CreatePlatformGLContext_iOS.mm (renamed from src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm)12
-rw-r--r--tools/gpu/gl/mac/CreatePlatformGLContext_mac.cpp (renamed from src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp)14
-rw-r--r--tools/gpu/gl/mesa/GLContext_mesa.cpp (renamed from src/gpu/gl/mesa/SkMesaGLContext.cpp)81
-rw-r--r--tools/gpu/gl/mesa/GLContext_mesa.h17
-rw-r--r--tools/gpu/gl/mesa/osmesa_wrapper.h16
-rw-r--r--tools/gpu/gl/null/NullGLContext.cpp630
-rw-r--r--tools/gpu/gl/null/NullGLContext.h17
-rw-r--r--tools/gpu/gl/win/CreatePlatformGLContext_win.cpp (renamed from src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp)12
-rw-r--r--tools/kilobench/kilobench.cpp21
-rw-r--r--tools/skiaserve/Request.cpp6
-rw-r--r--tools/skiaserve/Request.h4
86 files changed, 1645 insertions, 1019 deletions
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index c0f674fc59..235de02f57 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -56,6 +56,9 @@
#include "gl/GrGLDefines.h"
#include "GrCaps.h"
#include "GrContextFactory.h"
+ #include "gl/GrGLUtil.h"
+ using sk_gpu_test::GrContextFactory;
+ using sk_gpu_test::GLContext;
SkAutoTDelete<GrContextFactory> gGrFactory;
#endif
@@ -155,21 +158,21 @@ bool Target::capturePixels(SkBitmap* bmp) {
#if SK_SUPPORT_GPU
struct GPUTarget : public Target {
explicit GPUTarget(const Config& c) : Target(c), gl(nullptr) { }
- SkGLContext* gl;
+ GLContext* gl;
void setup() override {
this->gl->makeCurrent();
// Make sure we're done with whatever came before.
- SK_GL(*this->gl, Finish());
+ GR_GL_CALL(this->gl->gl(), Finish());
}
void endTiming() override {
if (this->gl) {
- SK_GL(*this->gl, Flush());
+ GR_GL_CALL(this->gl->gl(), Flush());
this->gl->waitOnSyncOrSwap();
}
}
void fence() override {
- SK_GL(*this->gl, Finish());
+ GR_GL_CALL(this->gl->gl(), Finish());
}
bool needsFrameTiming(int* maxFrameLag) const override {
@@ -200,16 +203,16 @@ struct GPUTarget : public Target {
}
void fillOptions(ResultsWriter* log) override {
const GrGLubyte* version;
- SK_GL_RET(*this->gl, version, GetString(GR_GL_VERSION));
+ GR_GL_CALL_RET(this->gl->gl(), version, GetString(GR_GL_VERSION));
log->configOption("GL_VERSION", (const char*)(version));
- SK_GL_RET(*this->gl, version, GetString(GR_GL_RENDERER));
+ GR_GL_CALL_RET(this->gl->gl(), version, GetString(GR_GL_RENDERER));
log->configOption("GL_RENDERER", (const char*) version);
- SK_GL_RET(*this->gl, version, GetString(GR_GL_VENDOR));
+ GR_GL_CALL_RET(this->gl->gl(), version, GetString(GR_GL_VENDOR));
log->configOption("GL_VENDOR", (const char*) version);
- SK_GL_RET(*this->gl, version, GetString(GR_GL_SHADING_LANGUAGE_VERSION));
+ GR_GL_CALL_RET(this->gl->gl(), version, GetString(GR_GL_SHADING_LANGUAGE_VERSION));
log->configOption("GL_SHADING_LANGUAGE_VERSION", (const char*) version);
}
};
diff --git a/bench/nanobench.h b/bench/nanobench.h
index 5e4efbf077..844811e26d 100644
--- a/bench/nanobench.h
+++ b/bench/nanobench.h
@@ -29,8 +29,8 @@ struct Config {
SkColorProfileType profile;
int samples;
#if SK_SUPPORT_GPU
- GrContextFactory::GLContextType ctxType;
- GrContextFactory::GLContextOptions ctxOptions;
+ sk_gpu_test::GrContextFactory::GLContextType ctxType;
+ sk_gpu_test::GrContextFactory::GLContextOptions ctxOptions;
bool useDFText;
#else
int bogusInt;
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index d3ffa35e90..67cdb1d719 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -90,7 +90,6 @@ remove_srcs(
../src/gpu/GrContextFactory.cpp # For internal testing only.
../src/gpu/gl/GrGLCreateNativeInterface_none.cpp
../src/gpu/gl/GrGLDefaultInterface_none.cpp
- ../src/gpu/gl/SkCreatePlatformGLContext*.cpp # For internal testing only.
../src/gpu/gl/command_buffer/*
../src/gpu/gl/egl/*
../src/gpu/gl/glfw/*
@@ -121,8 +120,6 @@ if (WIN32)
endif()
endif()
-remove_srcs(../src/gpu/gl/angle/*) # TODO
-
# Certain files must be compiled with support for SSSE3, SSE4.1, AVX, or AVX2 intrinsics.
file (GLOB_RECURSE ssse3_srcs ../src/*ssse3*.cpp ../src/*SSSE3*.cpp)
file (GLOB_RECURSE sse41_srcs ../src/*sse4*.cpp ../src/*SSE4*.cpp)
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 34f8a961e3..363f9f078c 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -70,6 +70,8 @@ DEFINE_int32(shard, 0, "Which shard do I run?");
DEFINE_bool(simpleCodec, false, "Only decode images to native scale");
using namespace DM;
+using sk_gpu_test::GrContextFactory;
+using sk_gpu_test::GLContext;
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
@@ -1411,7 +1413,7 @@ int dm_main() {
namespace skiatest {
namespace {
typedef void(*TestWithGrContext)(skiatest::Reporter*, GrContext*);
-typedef void(*TestWithGrContextAndGLContext)(skiatest::Reporter*, GrContext*, SkGLContext*);
+typedef void(*TestWithGrContextAndGLContext)(skiatest::Reporter*, GrContext*, GLContext*);
#if SK_SUPPORT_GPU
template<typename T>
void call_test(T test, skiatest::Reporter* reporter, const GrContextFactory::ContextInfo& context);
diff --git a/dm/DMGpuSupport.h b/dm/DMGpuSupport.h
index 73adeb0302..c713244e9d 100644
--- a/dm/DMGpuSupport.h
+++ b/dm/DMGpuSupport.h
@@ -28,12 +28,13 @@ namespace DM {
static const bool kGPUDisabled = false;
-static inline sk_sp<SkSurface> NewGpuSurface(GrContextFactory* grFactory,
- GrContextFactory::GLContextType type,
- GrContextFactory::GLContextOptions options,
- SkImageInfo info,
- int samples,
- bool useDIText) {
+static inline sk_sp<SkSurface> NewGpuSurface(
+ sk_gpu_test::GrContextFactory* grFactory,
+ sk_gpu_test::GrContextFactory::GLContextType type,
+ sk_gpu_test::GrContextFactory::GLContextOptions options,
+ SkImageInfo info,
+ int samples,
+ bool useDIText) {
uint32_t flags = useDIText ? SkSurfaceProps::kUseDeviceIndependentFonts_Flag : 0;
SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
return SkSurface::MakeRenderTarget(grFactory->get(type, options), SkBudgeted::kNo,
@@ -59,6 +60,7 @@ public:
void dumpGpuStats(SkString*) const {}
};
+namespace sk_gpu_test {
class GrContextFactory {
public:
GrContextFactory() {};
@@ -83,14 +85,15 @@ public:
void abandonContexts() {}
};
+} // namespace sk_gpu_test
namespace DM {
static const bool kGPUDisabled = true;
-static inline SkSurface* NewGpuSurface(GrContextFactory*,
- GrContextFactory::GLContextType,
- GrContextFactory::GLContextOptions,
+static inline SkSurface* NewGpuSurface(sk_gpu_test::GrContextFactory*,
+ sk_gpu_test::GrContextFactory::GLContextType,
+ sk_gpu_test::GrContextFactory::GLContextOptions,
SkImageInfo,
int,
bool) {
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 9e9ba9ed82..e704f74d03 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -45,6 +45,8 @@ DEFINE_bool(multiPage, false, "For document-type backends, render the source"
" into multiple pages");
DEFINE_bool(RAW_threading, true, "Allow RAW decodes to run on multiple threads?");
+using sk_gpu_test::GrContextFactory;
+
namespace DM {
GMSrc::GMSrc(skiagm::GMRegistry::Factory factory) : fFactory(factory) {}
diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h
index 1a56e817ca..3a35acf005 100644
--- a/dm/DMSrcSink.h
+++ b/dm/DMSrcSink.h
@@ -232,7 +232,8 @@ public:
class GPUSink : public Sink {
public:
- GPUSink(GrContextFactory::GLContextType, GrContextFactory::GLContextOptions,
+ GPUSink(sk_gpu_test::GrContextFactory::GLContextType,
+ sk_gpu_test::GrContextFactory::GLContextOptions,
int samples, bool diText, SkColorType colorType, SkColorProfileType profileType,
bool threaded);
@@ -241,13 +242,13 @@ public:
const char* fileExtension() const override { return "png"; }
SinkFlags flags() const override { return SinkFlags{ SinkFlags::kGPU, SinkFlags::kDirect }; }
private:
- GrContextFactory::GLContextType fContextType;
- GrContextFactory::GLContextOptions fContextOptions;
- int fSampleCount;
- bool fUseDIText;
- SkColorType fColorType;
- SkColorProfileType fProfileType;
- bool fThreaded;
+ sk_gpu_test::GrContextFactory::GLContextType fContextType;
+ sk_gpu_test::GrContextFactory::GLContextOptions fContextOptions;
+ int fSampleCount;
+ bool fUseDIText;
+ SkColorType fColorType;
+ SkColorProfileType fProfileType;
+ bool fThreaded;
};
class PDFSink : public Sink {
diff --git a/gm/image.cpp b/gm/image.cpp
index 5333b1725d..a84e19b3f7 100644
--- a/gm/image.cpp
+++ b/gm/image.cpp
@@ -433,7 +433,7 @@ DEF_SIMPLE_GM(new_texture_image, canvas, 225, 60) {
GrContext* context = nullptr;
#if SK_SUPPORT_GPU
context = canvas->getGrContext();
- GrContextFactory factory;
+ sk_gpu_test::GrContextFactory factory;
#endif
if (!context) {
skiagm::GM::DrawGpuOnlyMessage(canvas);
diff --git a/gyp/SampleApp.gyp b/gyp/SampleApp.gyp
index 47a2e90365..52061f28b3 100644
--- a/gyp/SampleApp.gyp
+++ b/gyp/SampleApp.gyp
@@ -153,6 +153,7 @@
'lua.gyp:lua',
'pdf.gyp:pdf',
'skia_lib.gyp:skia_lib',
+ 'gputest.gyp:skgputest',
'tools.gyp:resources',
'tools.gyp:sk_tool_utils',
'tools.gyp:timer',
diff --git a/gyp/flags.gyp b/gyp/flags.gyp
index 258ca40fab..166e24b55a 100644
--- a/gyp/flags.gyp
+++ b/gyp/flags.gyp
@@ -24,7 +24,14 @@
'include_dirs': [
'../tools/flags',
],
- }
+ },
+ 'conditions': [
+ ['skia_gpu', {
+ 'dependencies': [
+ 'gputest.gyp:skgputest',
+ ],
+ }],
+ ],
},
{
'target_name': 'flags_common',
diff --git a/gyp/gpu.gyp b/gyp/gpu.gyp
index 80fc932b8a..2fedbed93c 100644
--- a/gyp/gpu.gyp
+++ b/gyp/gpu.gyp
@@ -102,11 +102,6 @@
'sources': [
'<@(skgpu_sources)',
'<@(skgpu_native_gl_sources)',
- '<@(skgpu_angle_gl_sources)',
- '<@(skgpu_command_buffer_gl_sources)',
- '<@(skgpu_mesa_gl_sources)',
- '<@(skgpu_debug_gl_sources)',
- '<@(skgpu_null_gl_sources)',
'<@(skgpu_vk_sources)',
'gpu.gypi', # Makes the gypi appear in IDEs (but does not modify the build).
],
@@ -151,23 +146,6 @@
],
},
}],
- [ 'skia_egl == 1', {
- 'defines': [
- 'SK_EGL=1',
- ],
- }],
- [ 'skia_egl == 0', {
- 'defines': [
- 'SK_EGL=0',
- ],
- }],
- [ 'skia_mesa and skia_os == "linux"', {
- 'link_settings': {
- 'libraries': [
- '-lOSMesa',
- ],
- },
- }],
[ 'skia_os == "mac"', {
'link_settings': {
'libraries': [
@@ -179,46 +157,12 @@
'../src/gpu/gl/GrGLCreateNativeInterface_none.cpp',
],
}],
- [ 'not skia_mesa', {
- 'sources!': [
- '../src/gpu/gl/mesa/SkMesaGLContext.cpp',
- '../src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp',
- ],
- }],
- [ 'skia_mesa and skia_os == "mac"', {
- 'link_settings': {
- 'libraries': [
- '/opt/X11/lib/libOSMesa.dylib',
- ],
- },
- 'include_dirs': [
- '/opt/X11/include/',
- ],
- }],
[ 'skia_os in ["win", "ios"]', {
'sources!': [
'../src/gpu/gl/GrGLDefaultInterface_none.cpp',
'../src/gpu/gl/GrGLCreateNativeInterface_none.cpp',
],
}],
- [ 'skia_angle', {
- 'dependencies': [
- 'angle.gyp:*',
- ],
- 'export_dependent_settings': [
- 'angle.gyp:*',
- ],
- }, { # not skia_angle
- 'sources!': [
- '<@(skgpu_angle_gl_sources)',
- ],
- }],
- [ 'skia_command_buffer', {
- }, { # not skia_command_buffer
- 'sources!': [
- '<@(skgpu_command_buffer_gl_sources)',
- ],
- }],
[ 'skia_os == "android"', {
'sources!': [
'../src/gpu/gl/GrGLDefaultInterface_none.cpp',
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi
index 9e1f9118b4..bcc7def624 100644
--- a/gyp/gpu.gypi
+++ b/gyp/gpu.gypi
@@ -318,6 +318,7 @@
'<(skia_src_path)/gpu/gl/GrGLContext.cpp',
'<(skia_src_path)/gpu/gl/GrGLContext.h',
'<(skia_src_path)/gpu/gl/GrGLCreateNativeInterface_none.cpp',
+ '<(skia_src_path)/gpu/gl/GrGLCreateNullInterface.cpp',
'<(skia_src_path)/gpu/gl/GrGLDefaultInterface_none.cpp',
'<(skia_src_path)/gpu/gl/GrGLDefines.h',
'<(skia_src_path)/gpu/gl/GrGLGLSL.cpp',
@@ -408,8 +409,6 @@
'<(skia_include_path)/gpu/SkGrPixelRef.h',
'<(skia_include_path)/gpu/SkGrTexturePixelRef.h',
- '<(skia_include_path)/gpu/gl/SkGLContext.h',
-
'<(skia_src_path)/gpu/SkGpuDevice.cpp',
'<(skia_src_path)/gpu/SkGpuDevice.h',
'<(skia_src_path)/gpu/SkGpuDevice_drawTexture.cpp',
@@ -422,8 +421,6 @@
'<(skia_src_path)/image/SkImage_Gpu.cpp',
'<(skia_src_path)/image/SkSurface_Gpu.h',
'<(skia_src_path)/image/SkSurface_Gpu.cpp',
-
- '<(skia_src_path)/gpu/gl/SkGLContext.cpp'
],
'skgpu_vk_sources': [
'<(skia_include_path)/gpu/vk/GrVkBackendContext.h',
@@ -501,60 +498,6 @@
'<(skia_src_path)/gpu/gl/egl/GrGLCreateNativeInterface_egl.cpp',
'<(skia_src_path)/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp',
'<(skia_src_path)/gpu/gl/android/GrGLCreateNativeInterface_android.cpp',
-
- # Sk files
- '<(skia_src_path)/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp',
- '<(skia_src_path)/gpu/gl/win/SkCreatePlatformGLContext_win.cpp',
- '<(skia_src_path)/gpu/gl/glx/SkCreatePlatformGLContext_glx.cpp',
- '<(skia_src_path)/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp',
- '<(skia_src_path)/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm',
- ],
- 'skgpu_mesa_gl_sources': [
- '<(skia_src_path)/gpu/gl/mesa/GrGLCreateMesaInterface.cpp',
-
- # Sk files
- '<(skia_src_path)/gpu/gl/mesa/SkMesaGLContext.cpp',
- '<(skia_src_path)/gpu/gl/mesa/SkMesaGLContext.h',
- ],
- 'skgpu_angle_gl_sources': [
- '<(skia_src_path)/gpu/gl/angle/GrGLCreateANGLEInterface.cpp',
-
- # Sk files
- '<(skia_include_path)/gpu/gl/angle/SkANGLEGLContext.h',
- '<(skia_src_path)/gpu/gl/angle/SkANGLEGLContext.cpp',
- ],
- 'skgpu_command_buffer_gl_sources': [
- # Sk files
- '<(skia_include_path)/gpu/gl/command_buffer/SkCommandBufferGLContext.h',
- '<(skia_src_path)/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp',
- ],
- 'skgpu_debug_gl_sources': [
- '<(skia_src_path)/gpu/gl/debug/GrGLCreateDebugInterface.cpp',
- '<(skia_src_path)/gpu/gl/debug/GrFakeRefObj.h',
- '<(skia_src_path)/gpu/gl/debug/GrBufferObj.h',
- '<(skia_src_path)/gpu/gl/debug/GrBufferObj.cpp',
- '<(skia_src_path)/gpu/gl/debug/GrFBBindableObj.h',
- '<(skia_src_path)/gpu/gl/debug/GrRenderBufferObj.h',
- '<(skia_src_path)/gpu/gl/debug/GrTextureObj.h',
- '<(skia_src_path)/gpu/gl/debug/GrTextureObj.cpp',
- '<(skia_src_path)/gpu/gl/debug/GrTextureUnitObj.h',
- '<(skia_src_path)/gpu/gl/debug/GrTextureUnitObj.cpp',
- '<(skia_src_path)/gpu/gl/debug/GrFrameBufferObj.h',
- '<(skia_src_path)/gpu/gl/debug/GrFrameBufferObj.cpp',
- '<(skia_src_path)/gpu/gl/debug/GrShaderObj.h',
- '<(skia_src_path)/gpu/gl/debug/GrShaderObj.cpp',
- '<(skia_src_path)/gpu/gl/debug/GrProgramObj.h',
- '<(skia_src_path)/gpu/gl/debug/GrProgramObj.cpp',
- '<(skia_src_path)/gpu/gl/debug/GrVertexArrayObj.h',
-
- # Sk files
- '<(skia_src_path)/gpu/gl/debug/SkDebugGLContext.cpp',
- '<(skia_src_path)/gpu/gl/debug/SkDebugGLContext.h',
- ],
- 'skgpu_null_gl_sources': [
- '<(skia_src_path)/gpu/gl/GrGLCreateNullInterface.cpp',
- '<(skia_src_path)/gpu/gl/SkNullGLContext.cpp',
- '<(skia_include_path)/gpu/gl/SkNullGLContext.h',
],
},
}
diff --git a/gyp/gputest.gyp b/gyp/gputest.gyp
index 36db43403f..af812a1986 100644
--- a/gyp/gputest.gyp
+++ b/gyp/gputest.gyp
@@ -9,28 +9,85 @@
'product_name': 'skia_skgputest',
'type': 'static_library',
'standalone_static_library': 1,
- 'dependencies': [
- 'skia_lib.gyp:skia_lib',
- ],
'include_dirs': [
+ '../include/core',
+ '../include/config',
'../include/gpu',
'../include/private',
'../include/utils',
'../src/core',
'../src/gpu',
- '../../src/gpu',
+ '../src/utils',
+ '../tools/gpu',
],
- 'direct_dependent_settings': {
+ 'all_dependent_settings': {
'include_dirs': [
- '../src/gpu',
- '../../src/gpu',
+ '../tools/gpu',
],
},
+ 'dependencies': [
+ 'gpu.gyp:skgpu',
+ ],
'sources': [
- '<(skia_src_path)/gpu/GrContextFactory.cpp',
- '<(skia_src_path)/gpu/GrContextFactory.h',
- '<(skia_src_path)/gpu/GrTest.cpp',
- '<(skia_src_path)/gpu/GrTest.h',
+ '<!@(python find.py ../tools/gpu "*")'
+ ],
+ 'conditions': [
+ [ 'skia_mesa and skia_os == "linux"', {
+ 'link_settings': {
+ 'libraries': [
+ '-lOSMesa',
+ ],
+ },
+ }],
+ [ 'skia_mesa and skia_os == "mac"', {
+ 'link_settings': {
+ 'libraries': [
+ '/opt/X11/lib/libOSMesa.dylib',
+ ],
+ },
+ 'include_dirs': [
+ '/opt/X11/include/',
+ ],
+ }],
+ [ 'skia_angle', {
+ 'dependencies': [
+ 'angle.gyp:*',
+ ],
+ 'export_dependent_settings': [
+ 'angle.gyp:*',
+ ],
+ }],
+ ['skia_os != "win"', {
+ 'sources/': [ ['exclude', '_win\.(h|cpp)$'],],
+ }],
+ ['skia_os != "mac"', {
+ 'sources/': [ ['exclude', '_mac\.(h|cpp|m|mm)$'],],
+ }],
+ ['skia_os != "linux" and skia_os != "chromeos"', {
+ 'sources/': [ ['exclude', '_glx\.(h|cpp)$'],],
+ }],
+ ['skia_os != "ios"', {
+ 'sources/': [ ['exclude', '_iOS\.(h|cpp|m|mm)$'],],
+ }],
+ ['skia_os != "android"', {
+ 'sources/': [ ['exclude', '_android\.(h|cpp)$'],],
+ }],
+ ['skia_egl == 0', {
+ 'sources/': [ ['exclude', '_egl\.(h|cpp)$'],],
+ }],
+ [ 'skia_mesa == 0', {
+ 'sources/': [
+ ['exclude', '_mesa\.(h|cpp)$'],
+ ],
+ }],
+ [ 'skia_angle == 0', {
+ 'sources/': [
+ ['exclude', '_angle\.(h|cpp)$'],
+ ],
+ }],
+ [ 'skia_command_buffer == 0', {
+ 'sources/': [ ['exclude', '_command_buffer\.(h|cpp)$'], ],
+ }],
],
},
],
diff --git a/gyp/kilobench.gyp b/gyp/kilobench.gyp
index 2d0ae22c53..8223547a7d 100644
--- a/gyp/kilobench.gyp
+++ b/gyp/kilobench.gyp
@@ -17,6 +17,7 @@
'../gm',
'../include/private',
'../src/core',
+ '../src/gpu',
'../tools/VisualBench',
],
'sources': [
@@ -26,6 +27,7 @@
],
'dependencies': [
'flags.gyp:flags',
+ 'gpu.gyp:skgpu',
'gputest.gyp:skgputest',
'jsoncpp.gyp:jsoncpp',
'skia_lib.gyp:skia_lib',
diff --git a/gyp/pathops_unittest.gyp b/gyp/pathops_unittest.gyp
index 14b231c34c..a95d54cc0e 100644
--- a/gyp/pathops_unittest.gyp
+++ b/gyp/pathops_unittest.gyp
@@ -37,15 +37,6 @@
'-llog',
],
}],
- [ 'skia_gpu == 1', {
- 'include_dirs': [
- '../src/gpu',
- ],
- 'sources': [
- '../src/gpu/GrContextFactory.cpp',
- '../src/gpu/GrContextFactory.h',
- ]
- }],
],
},
],
diff --git a/gyp/skiaserve.gyp b/gyp/skiaserve.gyp
index 2cd13b5806..32b73f7c9c 100644
--- a/gyp/skiaserve.gyp
+++ b/gyp/skiaserve.gyp
@@ -14,6 +14,7 @@
'type': 'executable',
'include_dirs': [
'../src/core',
+ '../src/gpu',
'../src/ports',
'../tools/debugger',
'../tools/json',
diff --git a/gyp/visualbench.gyp b/gyp/visualbench.gyp
index 3ce9f1759f..371b665465 100644
--- a/gyp/visualbench.gyp
+++ b/gyp/visualbench.gyp
@@ -20,6 +20,7 @@
'../include/private',
'../src/core',
'../src/effects',
+ '../src/gpu',
'../src/images',
'../src/image',
'../src/pdf',
diff --git a/include/gpu/gl/GrGLInterface.h b/include/gpu/gl/GrGLInterface.h
index cbf9b1a59f..4ba516617f 100644
--- a/include/gpu/gl/GrGLInterface.h
+++ b/include/gpu/gl/GrGLInterface.h
@@ -43,39 +43,18 @@ const GrGLInterface* GrGLDefaultInterface();
*/
SK_API const GrGLInterface* GrGLCreateNativeInterface();
-#if SK_MESA
-/**
- * Creates a GrGLInterface for an OSMesa context.
- */
-SK_API const GrGLInterface* GrGLCreateMesaInterface();
-#endif
-
-#if SK_ANGLE
-/**
- * Creates a GrGLInterface for an ANGLE context.
- */
-SK_API const GrGLInterface* GrGLCreateANGLEInterface();
-#endif
-
-#if SK_COMMAND_BUFFER
-/**
- * Creates a GrGLInterface for a Command Buffer context.
- */
-SK_API const GrGLInterface* GrGLCreateCommandBufferInterface();
+#if GR_GL_PER_GL_FUNC_CALLBACK
+typedef void (*GrGLInterfaceCallbackProc)(const GrGLInterface*);
+typedef intptr_t GrGLInterfaceCallbackData;
#endif
/**
* Creates a null GrGLInterface that doesn't draw anything. Used for measuring
- * CPU overhead.
+ * CPU overhead. TODO: We would like to move this to tools/gpu/gl/null but currently
+ * Chromium is using it in its unit tests.
*/
const SK_API GrGLInterface* GrGLCreateNullInterface();
-/**
- * Creates a debugging GrGLInterface that doesn't draw anything. Used for
- * finding memory leaks and invalid memory accesses.
- */
-const GrGLInterface* GrGLCreateDebugInterface();
-
/** Function that returns a new interface identical to "interface" but without support for
GL_NV_path_rendering. */
const GrGLInterface* GrGLInterfaceRemoveNVPR(const GrGLInterface*);
diff --git a/include/gpu/gl/SkNullGLContext.h b/include/gpu/gl/SkNullGLContext.h
deleted file mode 100644
index 5a2a73fd8f..0000000000
--- a/include/gpu/gl/SkNullGLContext.h
+++ /dev/null
@@ -1,26 +0,0 @@
-
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#ifndef SkNullGLContext_DEFINED
-#define SkNullGLContext_DEFINED
-
-#include "gl/SkGLContext.h"
-
-class SK_API SkNullGLContext : public SkGLContext {
-public:
- ~SkNullGLContext() override;
- static SkNullGLContext* Create();
-
-private:
- SkNullGLContext();
-
- void onPlatformMakeCurrent() const override {};
- void onPlatformSwapBuffers() const override {}
- GrGLFuncPtr onPlatformGetProcAddress(const char*) const override { return nullptr; }
-};
-
-#endif
diff --git a/include/gpu/gl/angle/SkANGLEGLContext.h b/include/gpu/gl/angle/SkANGLEGLContext.h
deleted file mode 100644
index ea5e877ca2..0000000000
--- a/include/gpu/gl/angle/SkANGLEGLContext.h
+++ /dev/null
@@ -1,61 +0,0 @@
-
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#ifndef SkANGLEGLContext_DEFINED
-#define SkANGLEGLContext_DEFINED
-
-#if SK_ANGLE
-
-#include "gl/SkGLContext.h"
-
-class SkANGLEGLContext : public SkGLContext {
-public:
- ~SkANGLEGLContext() override;
-#ifdef SK_BUILD_FOR_WIN
- static SkANGLEGLContext* CreateDirectX() {
- SkANGLEGLContext* ctx = new SkANGLEGLContext(false);
- if (!ctx->isValid()) {
- delete ctx;
- return NULL;
- }
- return ctx;
- }
-#endif
- static SkANGLEGLContext* CreateOpenGL() {
- SkANGLEGLContext* ctx = new SkANGLEGLContext(true);
- if (!ctx->isValid()) {
- delete ctx;
- return NULL;
- }
- return ctx;
- }
-
- GrEGLImage texture2DToEGLImage(GrGLuint texID) const override;
- void destroyEGLImage(GrEGLImage) const override;
- GrGLuint eglImageToExternalTexture(GrEGLImage) const override;
- SkGLContext* createNew() const override;
-
- // The param is an EGLNativeDisplayType and the return is an EGLDispay.
- static void* GetD3DEGLDisplay(void* nativeDisplay, bool useGLBackend);
-
-private:
- SkANGLEGLContext(bool preferGLBackend);
- void destroyGLContext();
-
- void onPlatformMakeCurrent() const override;
- void onPlatformSwapBuffers() const override;
- GrGLFuncPtr onPlatformGetProcAddress(const char* name) const override;
-
- void* fContext;
- void* fDisplay;
- void* fSurface;
- bool fIsGLBackend;
-};
-
-#endif
-
-#endif
diff --git a/include/gpu/gl/command_buffer/SkCommandBufferGLContext.h b/include/gpu/gl/command_buffer/SkCommandBufferGLContext.h
deleted file mode 100644
index 47f3fd967a..0000000000
--- a/include/gpu/gl/command_buffer/SkCommandBufferGLContext.h
+++ /dev/null
@@ -1,63 +0,0 @@
-
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#ifndef SKCOMMANDBUFFERGLCONTEXT_DEFINED
-#define SKCOMMANDBUFFERGLCONTEXT_DEFINED
-
-#if SK_COMMAND_BUFFER
-
-#include "gl/SkGLContext.h"
-
-class SkCommandBufferGLContext : public SkGLContext {
-public:
- ~SkCommandBufferGLContext() override;
-
- static SkCommandBufferGLContext* Create() {
- SkCommandBufferGLContext* ctx = new SkCommandBufferGLContext;
- if (!ctx->isValid()) {
- delete ctx;
- return nullptr;
- }
- return ctx;
- }
-
- static SkCommandBufferGLContext* Create(void* nativeWindow, int msaaSampleCount) {
- SkCommandBufferGLContext* ctx = new SkCommandBufferGLContext(nativeWindow,
- msaaSampleCount);
- if (!ctx->isValid()) {
- delete ctx;
- return nullptr;
- }
- return ctx;
- }
-
- void presentCommandBuffer();
-
- bool makeCurrent();
- int getStencilBits();
- int getSampleCount();
-
-private:
- SkCommandBufferGLContext();
- SkCommandBufferGLContext(void* nativeWindow, int msaaSampleCount);
- void initializeGLContext(void* nativeWindow, const int* configAttribs,
- const int* surfaceAttribs);
- void destroyGLContext();
-
- void onPlatformMakeCurrent() const override;
- void onPlatformSwapBuffers() const override;
- GrGLFuncPtr onPlatformGetProcAddress(const char* name) const override;
-
- void* fContext;
- void* fDisplay;
- void* fSurface;
- void* fConfig;
-};
-
-#endif // SK_COMMAND_BUFFER
-
-#endif
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index e0d152d97b..780eabd1e3 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -33,11 +33,14 @@
#include "sk_tool_utils.h"
#if SK_SUPPORT_GPU
-#include "gl/GrGLInterface.h"
-#include "gl/GrGLUtil.h"
-#include "GrRenderTarget.h"
-#include "GrContext.h"
-#include "SkGpuDevice.h"
+# include "gl/GrGLInterface.h"
+# include "gl/GrGLUtil.h"
+# include "GrRenderTarget.h"
+# include "GrContext.h"
+# include "SkGpuDevice.h"
+# if SK_ANGLE
+# include "gl/angle/GLContext_angle.h"
+# endif
#else
class GrContext;
#endif
@@ -233,7 +236,7 @@ public:
break;
#if SK_ANGLE
case kANGLE_DeviceType:
- glInterface.reset(GrGLCreateANGLEInterface());
+ glInterface.reset(sk_gpu_test::CreateANGLEGLInterface());
break;
#endif // SK_ANGLE
#if SK_COMMAND_BUFFER
diff --git a/src/gpu/gl/GrGLTestInterface.h b/src/gpu/gl/GrGLTestInterface.h
index c5f91ee195..936d9b8a97 100644
--- a/src/gpu/gl/GrGLTestInterface.h
+++ b/src/gpu/gl/GrGLTestInterface.h
@@ -11,6 +11,10 @@
#include "gl/GrGLInterface.h"
#include "GrGLDefines.h"
+/**
+ * Base class for interfaces used for Skia testing. We would like to move this to tools/gpu/gl
+ * when Chromium is no longer using GrGLCreateNullInterface in its unit testing.
+ */
class GrGLTestInterface : public GrGLInterface {
public:
virtual GrGLvoid activeTexture(GrGLenum texture) {}
diff --git a/src/gpu/gl/SkNullGLContext.cpp b/src/gpu/gl/SkNullGLContext.cpp
deleted file mode 100644
index a2c5066273..0000000000
--- a/src/gpu/gl/SkNullGLContext.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "gl/SkNullGLContext.h"
-#include "gl/GrGLInterface.h"
-
-SkNullGLContext* SkNullGLContext::Create() {
- SkNullGLContext* ctx = new SkNullGLContext;
- if (!ctx->isValid()) {
- delete ctx;
- return nullptr;
- }
- return ctx;
-}
-
-SkNullGLContext::SkNullGLContext() {
- this->init(GrGLCreateNullInterface());
-}
-
-SkNullGLContext::~SkNullGLContext() {
- this->teardown();
-}
diff --git a/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp b/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp
deleted file mode 100644
index 48f9d8c8ff..0000000000
--- a/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "gl/GrGLInterface.h"
-#include "gl/GrGLAssembleInterface.h"
-#include "../ports/SkOSLibrary.h"
-
-#include <EGL/egl.h>
-
-namespace {
-struct Libs {
- void* fGLLib;
- void* fEGLLib;
-};
-}
-
-static GrGLFuncPtr angle_get_gl_proc(void* ctx, const char name[]) {
- const Libs* libs = reinterpret_cast<const Libs*>(ctx);
- GrGLFuncPtr proc = (GrGLFuncPtr) GetProcedureAddress(libs->fGLLib, name);
- if (proc) {
- return proc;
- }
- proc = (GrGLFuncPtr) GetProcedureAddress(libs->fEGLLib, name);
- if (proc) {
- return proc;
- }
- return eglGetProcAddress(name);
-}
-
-const GrGLInterface* GrGLCreateANGLEInterface() {
- static Libs gLibs = { nullptr, nullptr };
-
- if (nullptr == gLibs.fGLLib) {
- // We load the ANGLE library and never let it go
-#if defined _WIN32
- gLibs.fGLLib = DynamicLoadLibrary("libGLESv2.dll");
- gLibs.fEGLLib = DynamicLoadLibrary("libEGL.dll");
-#elif defined SK_BUILD_FOR_MAC
- gLibs.fGLLib = DynamicLoadLibrary("libGLESv2.dylib");
- gLibs.fEGLLib = DynamicLoadLibrary("libEGL.dylib");
-#else
- gLibs.fGLLib = DynamicLoadLibrary("libGLESv2.so");
- gLibs.fEGLLib = DynamicLoadLibrary("libEGL.so");
-#endif
- }
-
- if (nullptr == gLibs.fGLLib || nullptr == gLibs.fEGLLib) {
- // We can't setup the interface correctly w/o the so
- return nullptr;
- }
-
- return GrGLAssembleGLESInterface(&gLibs, angle_get_gl_proc);
-}
diff --git a/src/gpu/gl/debug/SkDebugGLContext.cpp b/src/gpu/gl/debug/SkDebugGLContext.cpp
deleted file mode 100644
index ecb27db95d..0000000000
--- a/src/gpu/gl/debug/SkDebugGLContext.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "gl/debug/SkDebugGLContext.h"
-
-SkDebugGLContext::SkDebugGLContext() {
- this->init(GrGLCreateDebugInterface());
-}
-
-SkDebugGLContext::~SkDebugGLContext() {
- this->teardown();
-}
diff --git a/src/gpu/gl/debug/SkDebugGLContext.h b/src/gpu/gl/debug/SkDebugGLContext.h
deleted file mode 100644
index 1ea7b62931..0000000000
--- a/src/gpu/gl/debug/SkDebugGLContext.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#ifndef SkDebugGLContext_DEFINED
-#define SkDebugGLContext_DEFINED
-
-#include "gl/SkGLContext.h"
-
-class SkDebugGLContext : public SkGLContext {
-public:
- ~SkDebugGLContext() override;
-
- static SkDebugGLContext* Create() {
- return new SkDebugGLContext;
- }
-private:
- void onPlatformMakeCurrent() const override {}
- void onPlatformSwapBuffers() const override {}
- GrGLFuncPtr onPlatformGetProcAddress(const char*) const override { return nullptr; }
-
- SkDebugGLContext();
-};
-
-#endif
diff --git a/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp b/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp
deleted file mode 100644
index 6a04d4f387..0000000000
--- a/src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "gl/GrGLAssembleInterface.h"
-#include "../GrGLUtil.h"
-
-#include "osmesa_wrapper.h"
-
-static GrGLFuncPtr osmesa_get(void* ctx, const char name[]) {
- SkASSERT(nullptr == ctx);
- SkASSERT(OSMesaGetCurrentContext());
- return OSMesaGetProcAddress(name);
-}
-
-const GrGLInterface* GrGLCreateMesaInterface() {
- if (nullptr == OSMesaGetCurrentContext()) {
- return nullptr;
- }
- return GrGLAssembleInterface(nullptr, osmesa_get);
-}
diff --git a/src/gpu/gl/mesa/SkMesaGLContext.h b/src/gpu/gl/mesa/SkMesaGLContext.h
deleted file mode 100644
index 7f700b6536..0000000000
--- a/src/gpu/gl/mesa/SkMesaGLContext.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#ifndef SkMesaGLContext_DEFINED
-#define SkMesaGLContext_DEFINED
-
-#include "gl/SkGLContext.h"
-
-#if SK_MESA
-
-class SkMesaGLContext : public SkGLContext {
-private:
- typedef intptr_t Context;
-
-public:
- ~SkMesaGLContext() override;
-
- static SkMesaGLContext* Create() {
- SkMesaGLContext* ctx = new SkMesaGLContext;
- if (!ctx->isValid()) {
- delete ctx;
- return nullptr;
- }
- return ctx;
- }
-
-private:
- SkMesaGLContext();
- void destroyGLContext();
-
- void onPlatformMakeCurrent() const override;
- void onPlatformSwapBuffers() const override;
- GrGLFuncPtr onPlatformGetProcAddress(const char*) const override;
-
- Context fContext;
- GrGLubyte *fImage;
-};
-
-#endif
-
-#endif
diff --git a/src/gpu/gl/nacl/SkCreatePlatformGLContext_nacl.cpp b/src/gpu/gl/nacl/SkCreatePlatformGLContext_nacl.cpp
deleted file mode 100644
index 855f0dc124..0000000000
--- a/src/gpu/gl/nacl/SkCreatePlatformGLContext_nacl.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include "gl/SkGLContext.h"
-
-SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* shareContext) {
- SkASSERT(!shareContext);
- return nullptr;
-}
diff --git a/src/views/win/SkOSWindow_win.cpp b/src/views/win/SkOSWindow_win.cpp
index 8b0211d64b..eba3a77e4d 100644
--- a/src/views/win/SkOSWindow_win.cpp
+++ b/src/views/win/SkOSWindow_win.cpp
@@ -395,6 +395,36 @@ void SkOSWindow::presentGL() {
#if SK_ANGLE
+void* get_angle_egl_display(void* nativeDisplay) {
+ PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT;
+ eglGetPlatformDisplayEXT =
+ (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
+
+ // We expect ANGLE to support this extension
+ if (!eglGetPlatformDisplayEXT) {
+ return EGL_NO_DISPLAY;
+ }
+
+ EGLDisplay display = EGL_NO_DISPLAY;
+ // Try for an ANGLE D3D11 context, fall back to D3D9, and finally GL.
+ EGLint attribs[3][3] = {
+ {
+ EGL_PLATFORM_ANGLE_TYPE_ANGLE,
+ EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE,
+ EGL_NONE
+ },
+ {
+ EGL_PLATFORM_ANGLE_TYPE_ANGLE,
+ EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE,
+ EGL_NONE
+ },
+ };
+ for (int i = 0; i < 3 && display == EGL_NO_DISPLAY; ++i) {
+ display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,nativeDisplay, attribs[i]);
+ }
+ return display;
+}
+
bool create_ANGLE(EGLNativeWindowType hWnd,
int msaaSampleCount,
EGLDisplay* eglDisplay,
@@ -418,7 +448,7 @@ bool create_ANGLE(EGLNativeWindowType hWnd,
EGL_NONE, EGL_NONE
};
- EGLDisplay display = SkANGLEGLContext::GetD3DEGLDisplay(GetDC(hWnd), false);
+ EGLDisplay display = get_angle_egl_display(GetDC(hWnd), false);
if (EGL_NO_DISPLAY == display) {
SkDebugf("Could not create ANGLE egl display!\n");
diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp
index f19592c530..7f0d7ea376 100644
--- a/tests/EGLImageTest.cpp
+++ b/tests/EGLImageTest.cpp
@@ -11,9 +11,11 @@
#include "GrContextFactory.h"
#include "gl/GrGLGpu.h"
#include "gl/GrGLUtil.h"
-#include "gl/SkGLContext.h"
+#include "gl/GLContext.h"
-static void cleanup(SkGLContext* glctx0, GrGLuint texID0, SkGLContext* glctx1, GrContext* grctx1,
+using sk_gpu_test::GLContext;
+
+static void cleanup(GLContext* glctx0, GrGLuint texID0, GLContext* glctx1, GrContext* grctx1,
const GrGLTextureInfo* grbackendtex1, GrEGLImage image1) {
if (glctx1) {
glctx1->makeCurrent();
@@ -91,7 +93,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(EGLImageTest, reporter, context0, glCtx0) {
return;
}
- SkAutoTDelete<SkGLContext> glCtx1 = glCtx0->createNew();
+ SkAutoTDelete<GLContext> glCtx1 = glCtx0->createNew();
if (!glCtx1) {
return;
}
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 03938fbb93..57274e0678 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -455,7 +455,7 @@ DEF_GPUTEST(GLPrograms, reporter, /*factory*/) {
// We suppress prints to avoid spew
GrContextOptions opts;
opts.fSuppressPrints = true;
- GrContextFactory debugFactory(opts);
+ sk_gpu_test::GrContextFactory debugFactory(opts);
skiatest::RunWithGPUTestContexts(test_glprograms_native, skiatest::kNative_GPUTestContexts,
reporter, &debugFactory);
skiatest::RunWithGPUTestContexts(test_glprograms_other_contexts,
diff --git a/tests/GrContextFactoryTest.cpp b/tests/GrContextFactoryTest.cpp
index 7dc02a56e6..0ba809524b 100644
--- a/tests/GrContextFactoryTest.cpp
+++ b/tests/GrContextFactoryTest.cpp
@@ -13,6 +13,8 @@
#include "GrCaps.h"
#include "Test.h"
+using sk_gpu_test::GrContextFactory;
+
DEF_GPUTEST(GrContextFactory_NVPRContextOptionHasPathRenderingSupport, reporter, /*factory*/) {
// Test that if NVPR is requested, the context always has path rendering
// or the context creation fails.
diff --git a/tests/GrPorterDuffTest.cpp b/tests/GrPorterDuffTest.cpp
index 54fcfc1d42..566ec12f5d 100644
--- a/tests/GrPorterDuffTest.cpp
+++ b/tests/GrPorterDuffTest.cpp
@@ -1147,8 +1147,8 @@ static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const
DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, /*factory*/) {
GrContextOptions opts;
opts.fSuppressDualSourceBlending = true;
- GrContextFactory mockFactory(opts);
- GrContext* ctx = mockFactory.get(GrContextFactory::kNull_GLContextType);
+ sk_gpu_test::GrContextFactory mockFactory(opts);
+ GrContext* ctx = mockFactory.get(sk_gpu_test::GrContextFactory::kNull_GLContextType);
if (!ctx) {
SkFAIL("Failed to create null context without ARB_blend_func_extended.");
return;
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index 15ee54c000..8485fdad68 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -26,6 +26,8 @@
#include "SkUtils.h"
#include "Test.h"
+using sk_gpu_test::GrContextFactory;
+
static void assert_equal(skiatest::Reporter* reporter, SkImage* a, const SkIRect* subsetA,
SkImage* b) {
const int widthA = subsetA ? subsetA->width() : a->width();
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index 114207d2fe..fc9e65e12d 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -11,7 +11,7 @@
#include "GrDrawContext.h"
#include "gl/GrGLGpu.h"
#include "gl/GrGLUtil.h"
-#include "gl/SkGLContext.h"
+#include "gl/GLContext.h"
static void test_read_pixels(skiatest::Reporter* reporter, GrContext* context,
GrTexture* rectangleTexture, uint32_t expectedPixelValues[]) {
diff --git a/tests/Test.h b/tests/Test.h
index 4b19a85c1d..119976f3ee 100644
--- a/tests/Test.h
+++ b/tests/Test.h
@@ -11,9 +11,11 @@
#include "SkTRegistry.h"
#include "SkTypes.h"
+namespace sk_gpu_test {
class GrContextFactory;
+class GLContext;
+} // namespace sk_gpu_test
class GrContext;
-class SkGLContext;
namespace skiatest {
@@ -41,7 +43,7 @@ public:
#define REPORT_FAILURE(reporter, cond, message) \
reporter->reportFailed(skiatest::Failure(__FILE__, __LINE__, cond, message))
-typedef void (*TestProc)(skiatest::Reporter*, GrContextFactory*);
+typedef void (*TestProc)(skiatest::Reporter*, sk_gpu_test::GrContextFactory*);
struct Test {
Test(const char* n, bool g, TestProc p) : name(n), needsGpu(g), proc(p) {}
@@ -83,7 +85,7 @@ enum GPUTestContexts {
};
template<typename T>
void RunWithGPUTestContexts(T testFunction, GPUTestContexts contexts, Reporter* reporter,
- GrContextFactory* factory);
+ sk_gpu_test::GrContextFactory* factory);
/** Timer provides wall-clock duration since its creation. */
class Timer {
@@ -133,32 +135,32 @@ private:
} \
} while (0)
-#define DEF_TEST(name, reporter) \
- static void test_##name(skiatest::Reporter*, GrContextFactory*); \
- skiatest::TestRegistry name##TestRegistry( \
- skiatest::Test(#name, false, test_##name)); \
- void test_##name(skiatest::Reporter* reporter, GrContextFactory*)
+#define DEF_TEST(name, reporter) \
+ static void test_##name(skiatest::Reporter*, sk_gpu_test::GrContextFactory*); \
+ skiatest::TestRegistry name##TestRegistry( \
+ skiatest::Test(#name, false, test_##name)); \
+ void test_##name(skiatest::Reporter* reporter, sk_gpu_test::GrContextFactory*)
#define GPUTEST_EXPAND_MSVC(x) x
#define GPUTEST_APPLY(C, ...) GPUTEST_EXPAND_MSVC(C(__VA_ARGS__))
#define GPUTEST_SELECT(a1, a2, N, ...) N
#define GPUTEST_CONTEXT_ARGS1(a1) GrContext* a1
-#define GPUTEST_CONTEXT_ARGS2(a1, a2) GrContext* a1, SkGLContext* a2
+#define GPUTEST_CONTEXT_ARGS2(a1, a2) GrContext* a1, sk_gpu_test::GLContext* a2
#define GPUTEST_CONTEXT_ARGS(...) \
GPUTEST_APPLY(GPUTEST_SELECT(__VA_ARGS__, GPUTEST_CONTEXT_ARGS2, GPUTEST_CONTEXT_ARGS1), \
__VA_ARGS__)
-#define DEF_GPUTEST(name, reporter, factory) \
- static void test_##name(skiatest::Reporter*, GrContextFactory*); \
- skiatest::TestRegistry name##TestRegistry( \
- skiatest::Test(#name, true, test_##name)); \
- void test_##name(skiatest::Reporter* reporter, GrContextFactory* factory)
+#define DEF_GPUTEST(name, reporter, factory) \
+ static void test_##name(skiatest::Reporter*, sk_gpu_test::GrContextFactory*); \
+ skiatest::TestRegistry name##TestRegistry( \
+ skiatest::Test(#name, true, test_##name)); \
+ void test_##name(skiatest::Reporter* reporter, sk_gpu_test::GrContextFactory* factory)
#define DEF_GPUTEST_FOR_CONTEXTS(name, contexts, reporter, ...) \
static void test_##name(skiatest::Reporter*, GPUTEST_CONTEXT_ARGS(__VA_ARGS__)); \
static void test_gpu_contexts_##name(skiatest::Reporter* reporter, \
- GrContextFactory* factory) { \
+ sk_gpu_test::GrContextFactory* factory) { \
skiatest::RunWithGPUTestContexts(test_##name, contexts, reporter, factory); \
} \
skiatest::TestRegistry name##TestRegistry( \
diff --git a/tests/TestConfigParsing.cpp b/tests/TestConfigParsing.cpp
index 9c030ed9ec..4057a37bb0 100644
--- a/tests/TestConfigParsing.cpp
+++ b/tests/TestConfigParsing.cpp
@@ -9,6 +9,8 @@
#include "Test.h"
#include <initializer_list>
+using sk_gpu_test::GrContextFactory;
+
namespace {
// The code
// SkCommandLineFlags::StringArray FLAGS_config1 = make_string_array({"a", "b"})
diff --git a/tests/TestTest.cpp b/tests/TestTest.cpp
index 890042e19d..05ab9ff697 100644
--- a/tests/TestTest.cpp
+++ b/tests/TestTest.cpp
@@ -9,7 +9,7 @@
#if SK_SUPPORT_GPU
#include "GrContext.h"
-#include "gl/SkGLContext.h"
+#include "gl/GLContext.h"
#endif
@@ -64,7 +64,7 @@ DEF_GPUTEST_FOR_NULL_CONTEXT(TestGpuNullContext, reporter, context) {
#endif
// This is an example of a GPU test that tests a property that should work for all GPU contexts.
-// It uses the additional SkGLContext* glContext to implement the test.
+// It uses the additional GLContext* glContext to implement the test.
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(TestGpuGrContextAndGLContext, reporter, context, glContext) {
REPORTER_ASSERT(reporter, reporter);
diff --git a/tests/TextureStorageAllocator.cpp b/tests/TextureStorageAllocator.cpp
index 1d226861e2..dd08354136 100644
--- a/tests/TextureStorageAllocator.cpp
+++ b/tests/TextureStorageAllocator.cpp
@@ -8,9 +8,9 @@
#include "Test.h"
#if SK_SUPPORT_GPU
#include "gl/GrGLGpu.h"
+#include "gl/GLContext.h"
#include "GrContext.h"
#include "SkSurface_Gpu.h"
-#include "../include/gpu/gl/SkGLContext.h"
#include "../include/gpu/GrTypes.h"
#include "../include/private/SkTemplates.h"
diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp
index 5d21d1ec15..9783db83a0 100644
--- a/tests/skia_test.cpp
+++ b/tests/skia_test.cpp
@@ -24,6 +24,7 @@
#endif
using namespace skiatest;
+using namespace sk_gpu_test;
DEFINE_bool2(extendedTest, x, false, "run extended tests for pathOps.");
diff --git a/tools/VisualBench/VisualBench.h b/tools/VisualBench/VisualBench.h
index 1920a52b2b..e9fbdfb8ae 100644
--- a/tools/VisualBench/VisualBench.h
+++ b/tools/VisualBench/VisualBench.h
@@ -16,7 +16,7 @@
#include "SkSurface.h"
#include "VisualFlags.h"
#include "VisualModule.h"
-#include "gl/SkGLContext.h"
+#include "gl/GLContext.h"
class GrContext;
struct GrGLInterface;
diff --git a/tools/flags/SkCommonFlagsConfig.cpp b/tools/flags/SkCommonFlagsConfig.cpp
index 9e0fd60b39..1ee3130bd7 100644
--- a/tools/flags/SkCommonFlagsConfig.cpp
+++ b/tools/flags/SkCommonFlagsConfig.cpp
@@ -9,6 +9,10 @@
#include <stdlib.h>
+#if SK_SUPPORT_GPU
+using sk_gpu_test::GrContextFactory;
+#endif
+
static const char defaultConfigs[] =
"565 8888 gpu nonrendering"
#if SK_ANGLE
diff --git a/tools/flags/SkCommonFlagsConfig.h b/tools/flags/SkCommonFlagsConfig.h
index 39f1f9788b..abf5946847 100644
--- a/tools/flags/SkCommonFlagsConfig.h
+++ b/tools/flags/SkCommonFlagsConfig.h
@@ -50,7 +50,7 @@ class SkCommandLineConfig {
// * backends that represent a shorthand of above (such as "msaa16" representing "gpu(samples=16)")
class SkCommandLineConfigGpu : public SkCommandLineConfig {
public:
- typedef GrContextFactory::GLContextType ContextType;
+ typedef sk_gpu_test::GrContextFactory::GLContextType ContextType;
SkCommandLineConfigGpu(const SkString& tag, const SkTArray<SkString>& viaParts,
ContextType contextType, bool useNVPR, bool useDIText, int samples,
SkColorType colorType, SkColorProfileType profileType);
diff --git a/src/gpu/GrContextFactory.cpp b/tools/gpu/GrContextFactory.cpp
index 00ae1226e8..0cf0cc781a 100755
--- a/src/gpu/GrContextFactory.cpp
+++ b/tools/gpu/GrContextFactory.cpp
@@ -1,3 +1,4 @@
+
/*
* Copyright 2014 Google Inc.
*
@@ -6,25 +7,23 @@
*/
#include "GrContextFactory.h"
+#include "gl/GLContext.h"
#if SK_ANGLE
- #include "gl/angle/SkANGLEGLContext.h"
+ #include "gl/angle/GLContext_angle.h"
#endif
#if SK_COMMAND_BUFFER
- #include "gl/command_buffer/SkCommandBufferGLContext.h"
+ #include "gl/command_buffer/GLContext_command_buffer.h"
#endif
-#include "gl/debug/SkDebugGLContext.h"
+#include "gl/debug/DebugGLContext.h"
#if SK_MESA
- #include "gl/mesa/SkMesaGLContext.h"
-#endif
-#if SK_VULKAN
-#include "vk/GrVkBackendContext.h"
+ #include "gl/mesa/GLContext_mesa.h"
#endif
-#include "gl/SkGLContext.h"
-#include "gl/SkNullGLContext.h"
+#include "gl/null/NullGLContext.h"
#include "gl/GrGLGpu.h"
#include "GrCaps.h"
+namespace sk_gpu_test {
GrContextFactory::GrContextFactory() { }
GrContextFactory::GrContextFactory(const GrContextOptions& opts)
@@ -74,43 +73,43 @@ GrContextFactory::ContextInfo GrContextFactory::getContextInfo(GLContextType typ
return ContextInfo(context.fGrContext, context.fGLContext);
}
}
- SkAutoTDelete<SkGLContext> glCtx;
+ SkAutoTDelete<GLContext> glCtx;
SkAutoTUnref<GrContext> grCtx;
switch (type) {
case kNative_GLContextType:
- glCtx.reset(SkCreatePlatformGLContext(kNone_GrGLStandard));
+ glCtx.reset(CreatePlatformGLContext(kNone_GrGLStandard));
break;
case kGL_GLContextType:
- glCtx.reset(SkCreatePlatformGLContext(kGL_GrGLStandard));
+ glCtx.reset(CreatePlatformGLContext(kGL_GrGLStandard));
break;
case kGLES_GLContextType:
- glCtx.reset(SkCreatePlatformGLContext(kGLES_GrGLStandard));
+ glCtx.reset(CreatePlatformGLContext(kGLES_GrGLStandard));
break;
#if SK_ANGLE
#ifdef SK_BUILD_FOR_WIN
case kANGLE_GLContextType:
- glCtx.reset(SkANGLEGLContext::CreateDirectX());
+ glCtx.reset(CreateANGLEDirect3DGLContext());
break;
#endif
case kANGLE_GL_GLContextType:
- glCtx.reset(SkANGLEGLContext::CreateOpenGL());
+ glCtx.reset(CreateANGLEOpenGLGLContext());
break;
#endif
#if SK_COMMAND_BUFFER
case kCommandBuffer_GLContextType:
- glCtx.reset(SkCommandBufferGLContext::Create());
+ glCtx.reset(CommandBufferGLContext::Create());
break;
#endif
#if SK_MESA
case kMESA_GLContextType:
- glCtx.reset(SkMesaGLContext::Create());
+ glCtx.reset(CreateMesaGLContext());
break;
#endif
case kNull_GLContextType:
- glCtx.reset(SkNullGLContext::Create());
+ glCtx.reset(CreateNullGLContext());
break;
case kDebug_GLContextType:
- glCtx.reset(SkDebugGLContext::Create());
+ glCtx.reset(CreateDebugGLContext());
break;
}
if (nullptr == glCtx.get()) {
@@ -129,15 +128,14 @@ GrContextFactory::ContextInfo GrContextFactory::getContextInfo(GLContextType typ
}
glCtx->makeCurrent();
+ GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(glInterface.get());
#ifdef SK_VULKAN
if (kEnableNVPR_GLContextOptions & options) {
return ContextInfo();
} else {
- GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(GrVkBackendContext::Create());
grCtx.reset(GrContext::Create(kVulkan_GrBackend, p3dctx, fGlobalOptions));
}
#else
- GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(glInterface.get());
grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, fGlobalOptions));
#endif
if (!grCtx.get()) {
@@ -156,3 +154,4 @@ GrContextFactory::ContextInfo GrContextFactory::getContextInfo(GLContextType typ
context.fOptions = options;
return ContextInfo(context.fGrContext, context.fGLContext);
}
+} // namespace sk_gpu_test
diff --git a/src/gpu/GrContextFactory.h b/tools/gpu/GrContextFactory.h
index 7afa3108c6..7e5c10e039 100644
--- a/src/gpu/GrContextFactory.h
+++ b/tools/gpu/GrContextFactory.h
@@ -11,9 +11,10 @@
#include "GrContext.h"
#include "GrContextOptions.h"
-#include "gl/SkGLContext.h"
+#include "gl/GLContext.h"
#include "SkTArray.h"
+namespace sk_gpu_test {
/**
* This is a simple class that is useful in test apps that use different
* GrContexts backed by different types of GL contexts. It manages creating the
@@ -109,11 +110,11 @@ public:
struct ContextInfo {
ContextInfo()
: fGrContext(nullptr), fGLContext(nullptr) { }
- ContextInfo(GrContext* grContext, SkGLContext* glContext)
+ ContextInfo(GrContext* grContext, GLContext* glContext)
: fGrContext(grContext), fGLContext(glContext) { }
GrContext* fGrContext;
- SkGLContext* fGLContext; //! Valid until the factory destroys it via abandonContexts() or
- //! destroyContexts().
+ GLContext* fGLContext; //! Valid until the factory destroys it via abandonContexts() or
+ //! destroyContexts().
};
/**
@@ -132,13 +133,13 @@ public:
private:
struct Context {
- GLContextType fType;
- GLContextOptions fOptions;
- SkGLContext* fGLContext;
- GrContext* fGrContext;
+ GLContextType fType;
+ GLContextOptions fOptions;
+ GLContext* fGLContext;
+ GrContext* fGrContext;
};
SkTArray<Context, true> fContexts;
const GrContextOptions fGlobalOptions;
};
-
+} // namespace sk_gpu_test
#endif
diff --git a/src/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp
index 2b6463d853..2b6463d853 100644
--- a/src/gpu/GrTest.cpp
+++ b/tools/gpu/GrTest.cpp
diff --git a/src/gpu/GrTest.h b/tools/gpu/GrTest.h
index 53aaac34e4..53aaac34e4 100644
--- a/src/gpu/GrTest.h
+++ b/tools/gpu/GrTest.h
diff --git a/src/gpu/gl/SkGLContext.cpp b/tools/gpu/gl/GLContext.cpp
index 1f9011fbd9..ac0e310014 100644
--- a/src/gpu/gl/SkGLContext.cpp
+++ b/tools/gpu/gl/GLContext.cpp
@@ -1,16 +1,18 @@
+
/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "gl/SkGLContext.h"
-#include "GrGLUtil.h"
+#include "GLContext.h"
+#include "gl/GrGLUtil.h"
#include "SkGpuFenceSync.h"
-class SkGLContext::GLFenceSync : public SkGpuFenceSync {
+namespace sk_gpu_test {
+class GLContext::GLFenceSync : public SkGpuFenceSync {
public:
- static GLFenceSync* CreateIfSupported(const SkGLContext*);
+ static GLFenceSync* CreateIfSupported(const GLContext*);
SkPlatformGpuFence SK_WARN_UNUSED_RESULT insertFence() const override;
bool waitFence(SkPlatformGpuFence fence, bool flush) const override;
@@ -36,12 +38,12 @@ private:
typedef SkGpuFenceSync INHERITED;
};
-SkGLContext::SkGLContext()
+GLContext::GLContext()
: fCurrentFenceIdx(0) {
memset(fFrameFences, 0, sizeof(fFrameFences));
}
-SkGLContext::~SkGLContext() {
+GLContext::~GLContext() {
// Subclass should call teardown.
#ifdef SK_DEBUG
for (size_t i = 0; i < SK_ARRAY_COUNT(fFrameFences); i++) {
@@ -52,13 +54,13 @@ SkGLContext::~SkGLContext() {
SkASSERT(nullptr == fFenceSync.get());
}
-void SkGLContext::init(const GrGLInterface* gl, SkGpuFenceSync* fenceSync) {
+void GLContext::init(const GrGLInterface* gl, SkGpuFenceSync* fenceSync) {
SkASSERT(!fGL.get());
fGL.reset(gl);
fFenceSync.reset(fenceSync ? fenceSync : GLFenceSync::CreateIfSupported(this));
}
-void SkGLContext::teardown() {
+void GLContext::teardown() {
if (fFenceSync) {
for (size_t i = 0; i < SK_ARRAY_COUNT(fFrameFences); i++) {
if (fFrameFences[i]) {
@@ -72,15 +74,15 @@ void SkGLContext::teardown() {
fGL.reset(nullptr);
}
-void SkGLContext::makeCurrent() const {
+void GLContext::makeCurrent() const {
this->onPlatformMakeCurrent();
}
-void SkGLContext::swapBuffers() {
+void GLContext::swapBuffers() {
this->onPlatformSwapBuffers();
}
-void SkGLContext::waitOnSyncOrSwap() {
+void GLContext::waitOnSyncOrSwap() {
if (!fFenceSync) {
// Fallback on the platform SwapBuffers method for synchronization. This may have no effect.
this->swapBuffers();
@@ -98,7 +100,7 @@ void SkGLContext::waitOnSyncOrSwap() {
fCurrentFenceIdx = (fCurrentFenceIdx + 1) % SK_ARRAY_COUNT(fFrameFences);
}
-void SkGLContext::testAbandon() {
+void GLContext::testAbandon() {
if (fGL) {
fGL->abandon();
}
@@ -107,12 +109,12 @@ void SkGLContext::testAbandon() {
}
}
-SkGLContext::GLFenceSync* SkGLContext::GLFenceSync::CreateIfSupported(const SkGLContext* ctx) {
+GLContext::GLFenceSync* GLContext::GLFenceSync::CreateIfSupported(const GLContext* ctx) {
SkAutoTDelete<GLFenceSync> ret(new GLFenceSync);
if (kGL_GrGLStandard == ctx->gl()->fStandard) {
const GrGLubyte* versionStr;
- SK_GL_RET(*ctx, versionStr, GetString(GR_GL_VERSION));
+ GR_GL_CALL_RET(ctx->gl(), versionStr, GetString(GR_GL_VERSION));
GrGLVersion version = GrGLGetVersionFromString(reinterpret_cast<const char*>(versionStr));
if (version < GR_GL_VER(3,2) && !ctx->gl()->hasExtension("GL_ARB_sync")) {
return nullptr;
@@ -142,23 +144,23 @@ SkGLContext::GLFenceSync* SkGLContext::GLFenceSync::CreateIfSupported(const SkGL
return ret.release();
}
-SkPlatformGpuFence SkGLContext::GLFenceSync::insertFence() const {
+SkPlatformGpuFence GLContext::GLFenceSync::insertFence() const {
return fGLFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
}
-bool SkGLContext::GLFenceSync::waitFence(SkPlatformGpuFence fence, bool flush) const {
+bool GLContext::GLFenceSync::waitFence(SkPlatformGpuFence fence, bool flush) const {
GLsync glsync = static_cast<GLsync>(fence);
return GL_WAIT_FAILED != fGLClientWaitSync(glsync, flush ? GL_SYNC_FLUSH_COMMANDS_BIT : 0, -1);
}
-void SkGLContext::GLFenceSync::deleteFence(SkPlatformGpuFence fence) const {
+void GLContext::GLFenceSync::deleteFence(SkPlatformGpuFence fence) const {
GLsync glsync = static_cast<GLsync>(fence);
fGLDeleteSync(glsync);
}
-GrGLint SkGLContext::createTextureRectangle(int width, int height, GrGLenum internalFormat,
- GrGLenum externalFormat, GrGLenum externalType,
- GrGLvoid* data) {
+GrGLint GLContext::createTextureRectangle(int width, int height, GrGLenum internalFormat,
+ GrGLenum externalFormat, GrGLenum externalType,
+ GrGLvoid* data) {
if (!(kGL_GrGLStandard == fGL->fStandard && GrGLGetVersion(fGL) >= GR_GL_VER(3, 1)) &&
!fGL->fExtensions.has("GL_ARB_texture_rectangle")) {
return 0;
@@ -176,10 +178,11 @@ GrGLint SkGLContext::createTextureRectangle(int width, int height, GrGLenum inte
GR_GL_CALL(fGL, TexParameteri(GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_MIN_FILTER,
GR_GL_NEAREST));
GR_GL_CALL(fGL, TexParameteri(GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_WRAP_S,
- GR_GL_CLAMP_TO_EDGE));
+ GR_GL_CLAMP_TO_EDGE));
GR_GL_CALL(fGL, TexParameteri(GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_WRAP_T,
GR_GL_CLAMP_TO_EDGE));
GR_GL_CALL(fGL, TexImage2D(GR_GL_TEXTURE_RECTANGLE, 0, internalFormat, width, height, 0,
externalFormat, externalType, data));
return id;
}
+} // namespace sk_gpu_test
diff --git a/include/gpu/gl/SkGLContext.h b/tools/gpu/gl/GLContext.h
index fe41a606ef..3f47613722 100644
--- a/include/gpu/gl/SkGLContext.h
+++ b/tools/gpu/gl/GLContext.h
@@ -5,29 +5,29 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#ifndef SkGLContext_DEFINED
-#define SkGLContext_DEFINED
+#ifndef GLContext_DEFINED
+#define GLContext_DEFINED
-#include "GrGLInterface.h"
+#include "gl/GrGLInterface.h"
#include "../private/SkGpuFenceSync.h"
+
+namespace sk_gpu_test {
/**
- * Create an offscreen opengl context with an RGBA8 / 8bit stencil FBO.
- * Provides a GrGLInterface struct of function pointers for the context.
- * This class is intended for Skia's testing needs and not for general
- * use.
+ * Create an offscreen Oppengl context. Provides a GrGLInterface struct of function pointers for
+ * the context. This class is intended for Skia's internal testing needs and not for general use.
*/
-class SK_API SkGLContext : public SkNoncopyable {
+class GLContext : public SkNoncopyable {
public:
- virtual ~SkGLContext();
+ virtual ~GLContext();
bool isValid() const { return NULL != gl(); }
- const GrGLInterface* gl() const { return fGL.get(); }
+ const GrGLInterface *gl() const { return fGL.get(); }
bool fenceSyncSupport() const { return fFenceSync != nullptr; }
- bool getMaxGpuFrameLag(int* maxFrameLag) const {
+ bool getMaxGpuFrameLag(int *maxFrameLag) const {
if (!fFenceSync) {
return false;
}
@@ -39,12 +39,13 @@ public:
/** Used for testing EGLImage integration. Take a GL_TEXTURE_2D and wraps it in an EGL Image */
virtual GrEGLImage texture2DToEGLImage(GrGLuint /*texID*/) const { return 0; }
- virtual void destroyEGLImage(GrEGLImage) const {}
+
+ virtual void destroyEGLImage(GrEGLImage) const { }
/** Used for testing GL_TEXTURE_RECTANGLE integration. */
GrGLint createTextureRectangle(int width, int height, GrGLenum internalFormat,
GrGLenum externalFormat, GrGLenum externalType,
- GrGLvoid* data);
+ GrGLvoid *data);
/**
* Used for testing EGLImage integration. Takes a EGLImage and wraps it in a
@@ -81,37 +82,42 @@ public:
* Creates a new GL context of the same type and makes the returned context current
* (if not null).
*/
- virtual SkGLContext* createNew() const { return nullptr; }
+ virtual GLContext *createNew() const { return nullptr; }
class GLFenceSync; // SkGpuFenceSync implementation that uses the OpenGL functionality.
/*
- * returns the fencesync object owned by this SkGLContext
+ * returns the fencesync object owned by this GLContext
*/
- SkGpuFenceSync* fenceSync() { return fFenceSync.get(); }
+ SkGpuFenceSync *fenceSync() { return fFenceSync.get(); }
protected:
- SkGLContext();
+ GLContext();
/*
* Methods that sublcasses must call from their constructors and destructors.
*/
- void init(const GrGLInterface*, SkGpuFenceSync* = NULL);
+ void init(const GrGLInterface *, SkGpuFenceSync * = NULL);
+
void teardown();
/*
* Operations that have a platform-dependent implementation.
*/
virtual void onPlatformMakeCurrent() const = 0;
+
virtual void onPlatformSwapBuffers() const = 0;
- virtual GrGLFuncPtr onPlatformGetProcAddress(const char*) const = 0;
+
+ virtual GrGLFuncPtr onPlatformGetProcAddress(const char *) const = 0;
private:
- enum { kMaxFrameLag = 3 };
+ enum {
+ kMaxFrameLag = 3
+ };
- SkAutoTDelete<SkGpuFenceSync> fFenceSync;
- SkPlatformGpuFence fFrameFences[kMaxFrameLag - 1];
- int fCurrentFenceIdx;
+ SkAutoTDelete <SkGpuFenceSync> fFenceSync;
+ SkPlatformGpuFence fFrameFences[kMaxFrameLag - 1];
+ int fCurrentFenceIdx;
/** Subclass provides the gl interface object if construction was
* successful. */
@@ -120,26 +126,16 @@ private:
friend class GLFenceSync; // For onPlatformGetProcAddress.
};
+
/** Creates platform-dependent GL context object. The shareContext parameter is in an optional
- * context with which to share display lists. This should be a pointer to an SkGLContext created
+ * context with which to share display lists. This should be a pointer to an GLContext created
* with SkCreatePlatformGLContext. NULL indicates that no sharing is to take place. Returns a valid
* gl context object or NULL if such can not be created.
* Note: If Skia embedder needs a custom GL context that sets up the GL interface, this function
* should be implemented by the embedder. Otherwise, the default implementation for the platform
* should be compiled in the library.
*/
-SK_API SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI,
- SkGLContext* shareContext = nullptr);
-
-/**
- * Helper macros for using the GL context through the GrGLInterface. Example:
- * SK_GL(glCtx, GenTextures(1, &texID));
- */
-#define SK_GL(ctx, X) (ctx).gl()->fFunctions.f ## X; \
- SkASSERT(0 == (ctx).gl()->fFunctions.fGetError())
-#define SK_GL_RET(ctx, RET, X) (RET) = (ctx).gl()->fFunctions.f ## X; \
- SkASSERT(0 == (ctx).gl()->fFunctions.fGetError())
-#define SK_GL_NOERRCHECK(ctx, X) (ctx).gl()->fFunctions.f ## X
-#define SK_GL_RET_NOERRCHECK(ctx, RET, X) (RET) = (ctx).gl()->fFunctions.f ## X
+GLContext* CreatePlatformGLContext(GrGLStandard forcedGpuAPI, GLContext *shareContext = nullptr);
+} // namespace sk_gpu_test
#endif
diff --git a/src/gpu/gl/angle/SkANGLEGLContext.cpp b/tools/gpu/gl/angle/GLContext_angle.cpp
index c6ea44381f..0d7dfdb389 100644
--- a/src/gpu/gl/angle/SkANGLEGLContext.cpp
+++ b/tools/gpu/gl/angle/GLContext_angle.cpp
@@ -1,3 +1,4 @@
+
/*
* Copyright 2012 Google Inc.
*
@@ -5,7 +6,7 @@
* found in the LICENSE file.
*/
-#include "gl/angle/SkANGLEGLContext.h"
+#include "GLContext_angle.h"
#include <EGL/egl.h>
#include <EGL/eglext.h>
@@ -13,32 +14,57 @@
#include "gl/GrGLDefines.h"
#include "gl/GrGLUtil.h"
+#include "gl/GrGLInterface.h"
+#include "gl/GrGLAssembleInterface.h"
+#include "../ports/SkOSLibrary.h"
+
+#include <EGL/egl.h>
+
#define EGL_PLATFORM_ANGLE_ANGLE 0x3202
#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203
#define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3207
#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208
#define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320D
-void* SkANGLEGLContext::GetD3DEGLDisplay(void* nativeDisplay, bool useGLBackend) {
+namespace {
+struct Libs {
+ void* fGLLib;
+ void* fEGLLib;
+};
+
+static GrGLFuncPtr angle_get_gl_proc(void* ctx, const char name[]) {
+ const Libs* libs = reinterpret_cast<const Libs*>(ctx);
+ GrGLFuncPtr proc = (GrGLFuncPtr) GetProcedureAddress(libs->fGLLib, name);
+ if (proc) {
+ return proc;
+ }
+ proc = (GrGLFuncPtr) GetProcedureAddress(libs->fEGLLib, name);
+ if (proc) {
+ return proc;
+ }
+ return eglGetProcAddress(name);
+}
+
+void* get_angle_egl_display(void* nativeDisplay, bool useGLBackend) {
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT;
eglGetPlatformDisplayEXT =
(PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
+ // We expect ANGLE to support this extension
if (!eglGetPlatformDisplayEXT) {
- return eglGetDisplay(static_cast<EGLNativeDisplayType>(nativeDisplay));
+ return EGL_NO_DISPLAY;
}
EGLDisplay display = EGL_NO_DISPLAY;
if (useGLBackend) {
- // Try for an ANGLE D3D11 context, fall back to D3D9.
EGLint attribs[3] = {
- EGL_PLATFORM_ANGLE_TYPE_ANGLE,
- EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE,
- EGL_NONE
+ EGL_PLATFORM_ANGLE_TYPE_ANGLE,
+ EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE,
+ EGL_NONE
};
display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, nativeDisplay, attribs);
} else {
- // Try for an ANGLE D3D11 context, fall back to D3D9, and finally GL.
+ // Try for an ANGLE D3D11 context, fall back to D3D9.
EGLint attribs[3][3] = {
{
EGL_PLATFORM_ANGLE_TYPE_ANGLE,
@@ -50,11 +76,6 @@ void* SkANGLEGLContext::GetD3DEGLDisplay(void* nativeDisplay, bool useGLBackend)
EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE,
EGL_NONE
},
- {
- EGL_PLATFORM_ANGLE_TYPE_ANGLE,
- EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE,
- EGL_NONE
- }
};
for (int i = 0; i < 3 && display == EGL_NO_DISPLAY; ++i) {
display = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE,nativeDisplay, attribs[i]);
@@ -63,7 +84,30 @@ void* SkANGLEGLContext::GetD3DEGLDisplay(void* nativeDisplay, bool useGLBackend)
return display;
}
-SkANGLEGLContext::SkANGLEGLContext(bool useGLBackend)
+class ANGLEGLContext : public sk_gpu_test::GLContext {
+public:
+ ANGLEGLContext(bool preferGLBackend);
+ ~ANGLEGLContext() override;
+
+ GrEGLImage texture2DToEGLImage(GrGLuint texID) const override;
+ void destroyEGLImage(GrEGLImage) const override;
+ GrGLuint eglImageToExternalTexture(GrEGLImage) const override;
+ sk_gpu_test::GLContext* createNew() const override;
+
+private:
+ void destroyGLContext();
+
+ void onPlatformMakeCurrent() const override;
+ void onPlatformSwapBuffers() const override;
+ GrGLFuncPtr onPlatformGetProcAddress(const char* name) const override;
+
+ void* fContext;
+ void* fDisplay;
+ void* fSurface;
+ bool fIsGLBackend;
+};
+
+ANGLEGLContext::ANGLEGLContext(bool useGLBackend)
: fContext(EGL_NO_CONTEXT)
, fDisplay(EGL_NO_DISPLAY)
, fSurface(EGL_NO_SURFACE) {
@@ -80,7 +124,7 @@ SkANGLEGLContext::SkANGLEGLContext(bool useGLBackend)
};
fIsGLBackend = useGLBackend;
- fDisplay = GetD3DEGLDisplay(EGL_DEFAULT_DISPLAY, useGLBackend);
+ fDisplay = get_angle_egl_display(EGL_DEFAULT_DISPLAY, useGLBackend);
if (EGL_NO_DISPLAY == fDisplay) {
SkDebugf("Could not create EGL display!");
return;
@@ -110,7 +154,7 @@ SkANGLEGLContext::SkANGLEGLContext(bool useGLBackend)
eglMakeCurrent(fDisplay, fSurface, fSurface, fContext);
- SkAutoTUnref<const GrGLInterface> gl(GrGLCreateANGLEInterface());
+ SkAutoTUnref<const GrGLInterface> gl(sk_gpu_test::CreateANGLEGLInterface());
if (nullptr == gl.get()) {
SkDebugf("Could not create ANGLE GL interface!\n");
this->destroyGLContext();
@@ -125,12 +169,12 @@ SkANGLEGLContext::SkANGLEGLContext(bool useGLBackend)
this->init(gl.release());
}
-SkANGLEGLContext::~SkANGLEGLContext() {
+ANGLEGLContext::~ANGLEGLContext() {
this->teardown();
this->destroyGLContext();
}
-GrEGLImage SkANGLEGLContext::texture2DToEGLImage(GrGLuint texID) const {
+GrEGLImage ANGLEGLContext::texture2DToEGLImage(GrGLuint texID) const {
if (!this->gl()->hasExtension("EGL_KHR_gl_texture_2D_image")) {
return GR_EGL_NO_IMAGE;
}
@@ -146,17 +190,16 @@ GrEGLImage SkANGLEGLContext::texture2DToEGLImage(GrGLuint texID) const {
return img;
}
-void SkANGLEGLContext::destroyEGLImage(GrEGLImage image) const {
+void ANGLEGLContext::destroyEGLImage(GrEGLImage image) const {
GR_GL_CALL(this->gl(), EGLDestroyImage(fDisplay, image));
}
-GrGLuint SkANGLEGLContext::eglImageToExternalTexture(GrEGLImage image) const {
+GrGLuint ANGLEGLContext::eglImageToExternalTexture(GrEGLImage image) const {
GrGLClearErr(this->gl());
if (!this->gl()->hasExtension("GL_OES_EGL_image_external")) {
return 0;
}
typedef GrGLvoid (*EGLImageTargetTexture2DProc)(GrGLenum, GrGLeglImage);
-
EGLImageTargetTexture2DProc glEGLImageTargetTexture2D =
(EGLImageTargetTexture2DProc)eglGetProcAddress("glEGLImageTargetTexture2DOES");
if (!glEGLImageTargetTexture2D) {
@@ -180,12 +223,12 @@ GrGLuint SkANGLEGLContext::eglImageToExternalTexture(GrEGLImage image) const {
return texID;
}
-SkGLContext* SkANGLEGLContext::createNew() const {
+sk_gpu_test::GLContext* ANGLEGLContext::createNew() const {
#ifdef SK_BUILD_FOR_WIN
- SkGLContext* ctx = fIsGLBackend ? SkANGLEGLContext::CreateOpenGL()
- : SkANGLEGLContext::CreateDirectX();
+ sk_gpu_test::GLContext* ctx = fIsGLBackend ? sk_gpu_test::CreateANGLEOpenGLGLContext()
+ : sk_gpu_test::CreateANGLEDirect3DGLContext();
#else
- SkGLContext* ctx = SkANGLEGLContext::CreateOpenGL();
+ sk_gpu_test::GLContext* ctx = sk_gpu_test::CreateANGLEOpenGLGLContext();
#endif
if (ctx) {
ctx->makeCurrent();
@@ -193,7 +236,7 @@ SkGLContext* SkANGLEGLContext::createNew() const {
return ctx;
}
-void SkANGLEGLContext::destroyGLContext() {
+void ANGLEGLContext::destroyGLContext() {
if (fDisplay) {
eglMakeCurrent(fDisplay, 0, 0, 0);
@@ -212,18 +255,66 @@ void SkANGLEGLContext::destroyGLContext() {
}
}
-void SkANGLEGLContext::onPlatformMakeCurrent() const {
+void ANGLEGLContext::onPlatformMakeCurrent() const {
if (!eglMakeCurrent(fDisplay, fSurface, fSurface, fContext)) {
SkDebugf("Could not set the context.\n");
}
}
-void SkANGLEGLContext::onPlatformSwapBuffers() const {
+void ANGLEGLContext::onPlatformSwapBuffers() const {
if (!eglSwapBuffers(fDisplay, fSurface)) {
SkDebugf("Could not complete eglSwapBuffers.\n");
}
}
-GrGLFuncPtr SkANGLEGLContext::onPlatformGetProcAddress(const char* name) const {
+GrGLFuncPtr ANGLEGLContext::onPlatformGetProcAddress(const char* name) const {
return eglGetProcAddress(name);
}
+} // anonymous namespace
+
+namespace sk_gpu_test {
+const GrGLInterface* CreateANGLEGLInterface() {
+ static Libs gLibs = { nullptr, nullptr };
+
+ if (nullptr == gLibs.fGLLib) {
+ // We load the ANGLE library and never let it go
+#if defined _WIN32
+ gLibs.fGLLib = DynamicLoadLibrary("libGLESv2.dll");
+ gLibs.fEGLLib = DynamicLoadLibrary("libEGL.dll");
+#elif defined SK_BUILD_FOR_MAC
+ gLibs.fGLLib = DynamicLoadLibrary("libGLESv2.dylib");
+ gLibs.fEGLLib = DynamicLoadLibrary("libEGL.dylib");
+#else
+ gLibs.fGLLib = DynamicLoadLibrary("libGLESv2.so");
+ gLibs.fEGLLib = DynamicLoadLibrary("libEGL.so");
+#endif
+ }
+
+ if (nullptr == gLibs.fGLLib || nullptr == gLibs.fEGLLib) {
+ // We can't setup the interface correctly w/o the so
+ return nullptr;
+ }
+
+ return GrGLAssembleGLESInterface(&gLibs, angle_get_gl_proc);
+}
+
+#ifdef SK_BUILD_FOR_WIN
+GLContext* CreateANGLEDirect3DGLContext() {
+ SkANGLEGLContext* ctx = new SkANGLEGLContext(false);
+ if (!ctx->isValid()) {
+ delete ctx;
+ return NULL;
+ }
+ return ctx;
+ }
+#endif
+
+GLContext* CreateANGLEOpenGLGLContext() {
+ ANGLEGLContext* ctx = new ANGLEGLContext(true);
+ if (!ctx->isValid()) {
+ delete ctx;
+ return NULL;
+ }
+ return ctx;
+}
+} // namespace sk_gpu_test
diff --git a/tools/gpu/gl/angle/GLContext_angle.h b/tools/gpu/gl/angle/GLContext_angle.h
new file mode 100644
index 0000000000..519ea6b5a3
--- /dev/null
+++ b/tools/gpu/gl/angle/GLContext_angle.h
@@ -0,0 +1,30 @@
+
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef GLContext_angle_DEFINED
+#define GLContext_angle_DEFINED
+
+#include "gl/GLContext.h"
+
+namespace sk_gpu_test {
+
+/**
+ * Creates a GrGLInterface for the currently ANGLE GL context currently bound in ANGLE's EGL
+ * implementation.
+ */
+const GrGLInterface* CreateANGLEGLInterface();
+
+#ifdef SK_BUILD_FOR_WIN
+/** Creates a GLContext backed by ANGLE's Direct3D backend. */
+GLContext* CreateANGLEDirect3DGLContext();
+#endif
+
+/** Creates a GLContext backed by ANGLE's OpenGL backend. */
+GLContext* CreateANGLEOpenGLGLContext();
+
+} // namespace sk_gpu_test
+#endif
diff --git a/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp b/tools/gpu/gl/command_buffer/GLContext_command_buffer.cpp
index 516c155fcc..b878cb4aa9 100644
--- a/src/gpu/gl/command_buffer/SkCommandBufferGLContext.cpp
+++ b/tools/gpu/gl/command_buffer/GLContext_command_buffer.cpp
@@ -1,13 +1,15 @@
+
/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+
#include "SkOnce.h"
#include "gl/GrGLInterface.h"
#include "gl/GrGLAssembleInterface.h"
-#include "gl/command_buffer/SkCommandBufferGLContext.h"
+#include "gl/command_buffer/GLContext_command_buffer.h"
#include "../ports/SkOSEnvironment.h"
#include "../ports/SkOSLibrary.h"
@@ -82,6 +84,7 @@ static GetProcAddressProc gfGetProcAddress = nullptr;
static void* gLibrary = nullptr;
static bool gfFunctionsLoadedSuccessfully = false;
+namespace {
static void load_command_buffer_functions() {
if (!gLibrary) {
#if defined _WIN32
@@ -124,22 +127,24 @@ static GrGLFuncPtr command_buffer_get_gl_proc(void* ctx, const char name[]) {
}
SK_DECLARE_STATIC_ONCE(loadCommandBufferOnce);
-void LoadCommandBufferOnce() {
+static void load_command_buffer_once() {
SkOnce(&loadCommandBufferOnce, load_command_buffer_functions);
}
-const GrGLInterface* GrGLCreateCommandBufferInterface() {
- LoadCommandBufferOnce();
+static const GrGLInterface* create_command_buffer_interface() {
+ load_command_buffer_once();
if (!gfFunctionsLoadedSuccessfully) {
return nullptr;
}
return GrGLAssembleGLESInterface(gLibrary, command_buffer_get_gl_proc);
}
-SkCommandBufferGLContext::SkCommandBufferGLContext()
- : fContext(EGL_NO_CONTEXT)
- , fDisplay(EGL_NO_DISPLAY)
- , fSurface(EGL_NO_SURFACE) {
+} // anonymous namespace
+
+namespace sk_gpu_test {
+
+CommandBufferGLContext::CommandBufferGLContext()
+ : fContext(EGL_NO_CONTEXT), fDisplay(EGL_NO_DISPLAY), fSurface(EGL_NO_SURFACE) {
static const EGLint configAttribs[] = {
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
@@ -160,18 +165,18 @@ SkCommandBufferGLContext::SkCommandBufferGLContext()
initializeGLContext(nullptr, configAttribs, surfaceAttribs);
}
-SkCommandBufferGLContext::SkCommandBufferGLContext(void* nativeWindow, int msaaSampleCount) {
- static const EGLint surfaceAttribs[] = { EGL_NONE };
+CommandBufferGLContext::CommandBufferGLContext(void *nativeWindow, int msaaSampleCount) {
+ static const EGLint surfaceAttribs[] = {EGL_NONE};
EGLint configAttribs[] = {
- EGL_RED_SIZE, 8,
- EGL_GREEN_SIZE, 8,
- EGL_BLUE_SIZE, 8,
- EGL_ALPHA_SIZE, 8,
- EGL_DEPTH_SIZE, 8,
- EGL_STENCIL_SIZE, 8,
+ EGL_RED_SIZE, 8,
+ EGL_GREEN_SIZE, 8,
+ EGL_BLUE_SIZE, 8,
+ EGL_ALPHA_SIZE, 8,
+ EGL_DEPTH_SIZE, 8,
+ EGL_STENCIL_SIZE, 8,
EGL_SAMPLE_BUFFERS, 1,
- EGL_SAMPLES, msaaSampleCount,
+ EGL_SAMPLES, msaaSampleCount,
EGL_NONE
};
if (msaaSampleCount == 0) {
@@ -181,9 +186,9 @@ SkCommandBufferGLContext::SkCommandBufferGLContext(void* nativeWindow, int msaaS
initializeGLContext(nativeWindow, configAttribs, surfaceAttribs);
}
-void SkCommandBufferGLContext::initializeGLContext(void* nativeWindow, const int* configAttribs,
- const int* surfaceAttribs) {
- LoadCommandBufferOnce();
+void CommandBufferGLContext::initializeGLContext(void *nativeWindow, const int *configAttribs,
+ const int *surfaceAttribs) {
+ load_command_buffer_once();
if (!gfFunctionsLoadedSuccessfully) {
SkDebugf("Command Buffer: Could not load EGL functions.\n");
return;
@@ -206,7 +211,7 @@ void SkCommandBufferGLContext::initializeGLContext(void* nativeWindow, const int
}
EGLint numConfigs;
- if (!gfChooseConfig(fDisplay, configAttribs, static_cast<EGLConfig*>(&fConfig), 1,
+ if (!gfChooseConfig(fDisplay, configAttribs, static_cast<EGLConfig *>(&fConfig), 1,
&numConfigs) || numConfigs != 1) {
SkDebugf("Command Buffer: Could not choose EGL config.\n");
this->destroyGLContext();
@@ -216,7 +221,7 @@ void SkCommandBufferGLContext::initializeGLContext(void* nativeWindow, const int
if (nativeWindow) {
fSurface = gfCreateWindowSurface(fDisplay,
static_cast<EGLConfig>(fConfig),
- (EGLNativeWindowType)nativeWindow,
+ (EGLNativeWindowType) nativeWindow,
surfaceAttribs);
} else {
fSurface = gfCreatePbufferSurface(fDisplay,
@@ -246,7 +251,7 @@ void SkCommandBufferGLContext::initializeGLContext(void* nativeWindow, const int
return;
}
- SkAutoTUnref<const GrGLInterface> gl(GrGLCreateCommandBufferInterface());
+ SkAutoTUnref<const GrGLInterface> gl(create_command_buffer_interface());
if (nullptr == gl.get()) {
SkDebugf("Command Buffer: Could not create CommandBuffer GL interface.\n");
this->destroyGLContext();
@@ -261,12 +266,12 @@ void SkCommandBufferGLContext::initializeGLContext(void* nativeWindow, const int
this->init(gl.release());
}
-SkCommandBufferGLContext::~SkCommandBufferGLContext() {
+CommandBufferGLContext::~CommandBufferGLContext() {
this->teardown();
this->destroyGLContext();
}
-void SkCommandBufferGLContext::destroyGLContext() {
+void CommandBufferGLContext::destroyGLContext() {
if (!gfFunctionsLoadedSuccessfully) {
return;
}
@@ -288,7 +293,7 @@ void SkCommandBufferGLContext::destroyGLContext() {
}
}
-void SkCommandBufferGLContext::onPlatformMakeCurrent() const {
+void CommandBufferGLContext::onPlatformMakeCurrent() const {
if (!gfFunctionsLoadedSuccessfully) {
return;
}
@@ -297,7 +302,7 @@ void SkCommandBufferGLContext::onPlatformMakeCurrent() const {
}
}
-void SkCommandBufferGLContext::onPlatformSwapBuffers() const {
+void CommandBufferGLContext::onPlatformSwapBuffers() const {
if (!gfFunctionsLoadedSuccessfully) {
return;
}
@@ -306,14 +311,14 @@ void SkCommandBufferGLContext::onPlatformSwapBuffers() const {
}
}
-GrGLFuncPtr SkCommandBufferGLContext::onPlatformGetProcAddress(const char* name) const {
+GrGLFuncPtr CommandBufferGLContext::onPlatformGetProcAddress(const char *name) const {
if (!gfFunctionsLoadedSuccessfully) {
return nullptr;
}
return gfGetProcAddress(name);
}
-void SkCommandBufferGLContext::presentCommandBuffer() {
+void CommandBufferGLContext::presentCommandBuffer() {
if (this->gl()) {
this->gl()->fFunctions.fFlush();
}
@@ -321,18 +326,20 @@ void SkCommandBufferGLContext::presentCommandBuffer() {
this->onPlatformSwapBuffers();
}
-bool SkCommandBufferGLContext::makeCurrent() {
+bool CommandBufferGLContext::makeCurrent() {
return gfMakeCurrent(fDisplay, fSurface, fSurface, fContext) != EGL_FALSE;
}
-int SkCommandBufferGLContext::getStencilBits() {
+int CommandBufferGLContext::getStencilBits() {
EGLint result = 0;
gfGetConfigAttrib(fDisplay, static_cast<EGLConfig>(fConfig), EGL_STENCIL_SIZE, &result);
return result;
}
-int SkCommandBufferGLContext::getSampleCount() {
+int CommandBufferGLContext::getSampleCount() {
EGLint result = 0;
gfGetConfigAttrib(fDisplay, static_cast<EGLConfig>(fConfig), EGL_SAMPLES, &result);
return result;
}
+
+} // namespace sk_gpu_test
diff --git a/tools/gpu/gl/command_buffer/GLContext_command_buffer.h b/tools/gpu/gl/command_buffer/GLContext_command_buffer.h
new file mode 100644
index 0000000000..73f02e2c78
--- /dev/null
+++ b/tools/gpu/gl/command_buffer/GLContext_command_buffer.h
@@ -0,0 +1,68 @@
+
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GLContext_command_buffer_DEFINED
+#define GLContext_command_buffer_DEFINED
+
+#include "gl/GLContext.h"
+
+namespace sk_gpu_test {
+class CommandBufferGLContext : public GLContext {
+public:
+ ~CommandBufferGLContext() override;
+
+ static CommandBufferGLContext *Create() {
+ CommandBufferGLContext *ctx = new CommandBufferGLContext;
+ if (!ctx->isValid()) {
+ delete ctx;
+ return nullptr;
+ }
+ return ctx;
+ }
+
+ static CommandBufferGLContext *Create(void *nativeWindow, int msaaSampleCount) {
+ CommandBufferGLContext *ctx = new CommandBufferGLContext(nativeWindow, msaaSampleCount);
+ if (!ctx->isValid()) {
+ delete ctx;
+ return nullptr;
+ }
+ return ctx;
+ }
+
+ void presentCommandBuffer();
+
+ bool makeCurrent();
+
+ int getStencilBits();
+
+ int getSampleCount();
+
+private:
+ CommandBufferGLContext();
+
+ CommandBufferGLContext(void *nativeWindow, int msaaSampleCount);
+
+ void initializeGLContext(void *nativeWindow, const int *configAttribs,
+ const int *surfaceAttribs);
+
+ void destroyGLContext();
+
+ void onPlatformMakeCurrent() const override;
+
+ void onPlatformSwapBuffers() const override;
+
+ GrGLFuncPtr onPlatformGetProcAddress(const char *name) const override;
+
+ void *fContext;
+ void *fDisplay;
+ void *fSurface;
+ void *fConfig;
+};
+} // namespace sk_gpu_test
+
+#endif
diff --git a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp b/tools/gpu/gl/debug/DebugGLContext.cpp
index 02b5cf704d..f4cbbea680 100644
--- a/src/gpu/gl/debug/GrGLCreateDebugInterface.cpp
+++ b/tools/gpu/gl/debug/DebugGLContext.cpp
@@ -1,3 +1,4 @@
+
/*
* Copyright 2012 Google Inc.
*
@@ -5,8 +6,7 @@
* found in the LICENSE file.
*/
-
-#include "gl/GrGLInterface.h"
+#include "DebugGLContext.h"
#include "GrBufferObj.h"
#include "GrFrameBufferObj.h"
@@ -217,254 +217,254 @@ public:
}
}
- GrGLvoid useProgram(GrGLuint programID) override {
+ GrGLvoid useProgram(GrGLuint programID) override {
- // A programID of 0 is legal
- GrProgramObj *program = FIND(programID, GrProgramObj, kProgram_ObjTypes);
+ // A programID of 0 is legal
+ GrProgramObj *program = FIND(programID, GrProgramObj, kProgram_ObjTypes);
- this->useProgram(program);
- }
+ this->useProgram(program);
+ }
- GrGLvoid bindFramebuffer(GrGLenum target, GrGLuint frameBufferID) override {
+ GrGLvoid bindFramebuffer(GrGLenum target, GrGLuint frameBufferID) override {
- GrAlwaysAssert(GR_GL_FRAMEBUFFER == target ||
- GR_GL_READ_FRAMEBUFFER == target ||
- GR_GL_DRAW_FRAMEBUFFER);
+ GrAlwaysAssert(GR_GL_FRAMEBUFFER == target ||
+ GR_GL_READ_FRAMEBUFFER == target ||
+ GR_GL_DRAW_FRAMEBUFFER);
- // a frameBufferID of 0 is acceptable - it binds to the default
- // frame buffer
- GrFrameBufferObj *frameBuffer = FIND(frameBufferID, GrFrameBufferObj,
- kFrameBuffer_ObjTypes);
+ // a frameBufferID of 0 is acceptable - it binds to the default
+ // frame buffer
+ GrFrameBufferObj *frameBuffer = FIND(frameBufferID, GrFrameBufferObj,
+ kFrameBuffer_ObjTypes);
- this->setFrameBuffer(frameBuffer);
- }
+ this->setFrameBuffer(frameBuffer);
+ }
- GrGLvoid bindRenderbuffer(GrGLenum target, GrGLuint renderBufferID) override {
+ GrGLvoid bindRenderbuffer(GrGLenum target, GrGLuint renderBufferID) override {
- GrAlwaysAssert(GR_GL_RENDERBUFFER == target);
+ GrAlwaysAssert(GR_GL_RENDERBUFFER == target);
- // a renderBufferID of 0 is acceptable - it unbinds the bound render buffer
- GrRenderBufferObj *renderBuffer = FIND(renderBufferID, GrRenderBufferObj,
- kRenderBuffer_ObjTypes);
+ // a renderBufferID of 0 is acceptable - it unbinds the bound render buffer
+ GrRenderBufferObj *renderBuffer = FIND(renderBufferID, GrRenderBufferObj,
+ kRenderBuffer_ObjTypes);
- this->setRenderBuffer(renderBuffer);
- }
+ this->setRenderBuffer(renderBuffer);
+ }
- GrGLvoid deleteTextures(GrGLsizei n, const GrGLuint* textures) override {
- // first potentially unbind the texture
- for (unsigned int i = 0; i < kDefaultMaxTextureUnits; ++i) {
- GrTextureUnitObj *pTU = this->getTextureUnit(i);
+ GrGLvoid deleteTextures(GrGLsizei n, const GrGLuint* textures) override {
+ // first potentially unbind the texture
+ for (unsigned int i = 0; i < kDefaultMaxTextureUnits; ++i) {
+ GrTextureUnitObj *pTU = this->getTextureUnit(i);
- if (pTU->getTexture()) {
- for (int j = 0; j < n; ++j) {
+ if (pTU->getTexture()) {
+ for (int j = 0; j < n; ++j) {
- if (textures[j] == pTU->getTexture()->getID()) {
- // this ID is the current texture - revert the binding to 0
- pTU->setTexture(nullptr);
- }
- }
- }
- }
+ if (textures[j] == pTU->getTexture()->getID()) {
+ // this ID is the current texture - revert the binding to 0
+ pTU->setTexture(nullptr);
+ }
+ }
+ }
+ }
- // TODO: fuse the following block with DeleteRenderBuffers?
- // Open GL will remove a deleted render buffer from the active
- // frame buffer but not from any other frame buffer
- if (this->getFrameBuffer()) {
+ // TODO: fuse the following block with DeleteRenderBuffers?
+ // Open GL will remove a deleted render buffer from the active
+ // frame buffer but not from any other frame buffer
+ if (this->getFrameBuffer()) {
- GrFrameBufferObj *frameBuffer = this->getFrameBuffer();
+ GrFrameBufferObj *frameBuffer = this->getFrameBuffer();
- for (int i = 0; i < n; ++i) {
+ for (int i = 0; i < n; ++i) {
- if (frameBuffer->getColor() &&
- textures[i] == frameBuffer->getColor()->getID()) {
- frameBuffer->setColor(nullptr);
- }
- if (frameBuffer->getDepth() &&
- textures[i] == frameBuffer->getDepth()->getID()) {
- frameBuffer->setDepth(nullptr);
- }
- if (frameBuffer->getStencil() &&
- textures[i] == frameBuffer->getStencil()->getID()) {
- frameBuffer->setStencil(nullptr);
- }
- }
- }
+ if (frameBuffer->getColor() &&
+ textures[i] == frameBuffer->getColor()->getID()) {
+ frameBuffer->setColor(nullptr);
+ }
+ if (frameBuffer->getDepth() &&
+ textures[i] == frameBuffer->getDepth()->getID()) {
+ frameBuffer->setDepth(nullptr);
+ }
+ if (frameBuffer->getStencil() &&
+ textures[i] == frameBuffer->getStencil()->getID()) {
+ frameBuffer->setStencil(nullptr);
+ }
+ }
+ }
- // then actually "delete" the buffers
- for (int i = 0; i < n; ++i) {
- GrTextureObj *buffer = FIND(textures[i], GrTextureObj, kTexture_ObjTypes);
- GrAlwaysAssert(buffer);
+ // then actually "delete" the buffers
+ for (int i = 0; i < n; ++i) {
+ GrTextureObj *buffer = FIND(textures[i], GrTextureObj, kTexture_ObjTypes);
+ GrAlwaysAssert(buffer);
- // OpenGL gives no guarantees if a texture is deleted while attached to
- // something other than the currently bound frame buffer
- GrAlwaysAssert(!buffer->getBound());
+ // OpenGL gives no guarantees if a texture is deleted while attached to
+ // something other than the currently bound frame buffer
+ GrAlwaysAssert(!buffer->getBound());
- GrAlwaysAssert(!buffer->getDeleted());
- buffer->deleteAction();
- }
+ GrAlwaysAssert(!buffer->getDeleted());
+ buffer->deleteAction();
+ }
- }
+ }
- GrGLvoid deleteFramebuffers(GrGLsizei n, const GrGLuint *frameBuffers) override {
+ GrGLvoid deleteFramebuffers(GrGLsizei n, const GrGLuint *frameBuffers) override {
- // first potentially unbind the buffers
- if (this->getFrameBuffer()) {
- for (int i = 0; i < n; ++i) {
+ // first potentially unbind the buffers
+ if (this->getFrameBuffer()) {
+ for (int i = 0; i < n; ++i) {
- if (frameBuffers[i] ==
- this->getFrameBuffer()->getID()) {
- // this ID is the current frame buffer - rebind to the default
- this->setFrameBuffer(nullptr);
- }
- }
- }
-
- // then actually "delete" the buffers
- for (int i = 0; i < n; ++i) {
- GrFrameBufferObj *buffer = FIND(frameBuffers[i], GrFrameBufferObj,
- kFrameBuffer_ObjTypes);
- GrAlwaysAssert(buffer);
-
- GrAlwaysAssert(!buffer->getDeleted());
- buffer->deleteAction();
- }
- }
-
- GrGLvoid deleteRenderbuffers(GrGLsizei n,const GrGLuint *renderBuffers) override {
-
- // first potentially unbind the buffers
- if (this->getRenderBuffer()) {
- for (int i = 0; i < n; ++i) {
-
- if (renderBuffers[i] ==
- this->getRenderBuffer()->getID()) {
- // this ID is the current render buffer - make no
- // render buffer be bound
- this->setRenderBuffer(nullptr);
- }
- }
- }
-
- // TODO: fuse the following block with DeleteTextures?
- // Open GL will remove a deleted render buffer from the active frame
- // buffer but not from any other frame buffer
- if (this->getFrameBuffer()) {
-
- GrFrameBufferObj *frameBuffer = this->getFrameBuffer();
-
- for (int i = 0; i < n; ++i) {
-
- if (frameBuffer->getColor() &&
- renderBuffers[i] == frameBuffer->getColor()->getID()) {
- frameBuffer->setColor(nullptr);
- }
- if (frameBuffer->getDepth() &&
- renderBuffers[i] == frameBuffer->getDepth()->getID()) {
- frameBuffer->setDepth(nullptr);
- }
- if (frameBuffer->getStencil() &&
- renderBuffers[i] == frameBuffer->getStencil()->getID()) {
- frameBuffer->setStencil(nullptr);
- }
- }
- }
-
- // then actually "delete" the buffers
- for (int i = 0; i < n; ++i) {
- GrRenderBufferObj *buffer = FIND(renderBuffers[i], GrRenderBufferObj,
- kRenderBuffer_ObjTypes);
- GrAlwaysAssert(buffer);
-
- // OpenGL gives no guarantees if a render buffer is deleted
- // while attached to something other than the currently
- // bound frame buffer
- GrAlwaysAssert(!buffer->getColorBound());
- GrAlwaysAssert(!buffer->getDepthBound());
- // However, at GrContext destroy time we release all GrRsources and so stencil buffers
- // may get deleted before FBOs that refer to them.
- //GrAlwaysAssert(!buffer->getStencilBound());
-
- GrAlwaysAssert(!buffer->getDeleted());
- buffer->deleteAction();
- }
- }
-
- GrGLvoid framebufferRenderbuffer(GrGLenum target,
- GrGLenum attachment,
- GrGLenum renderbuffertarget,
- GrGLuint renderBufferID) override {
-
- GrAlwaysAssert(GR_GL_FRAMEBUFFER == target);
- GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment ||
- GR_GL_DEPTH_ATTACHMENT == attachment ||
- GR_GL_STENCIL_ATTACHMENT == attachment);
- GrAlwaysAssert(GR_GL_RENDERBUFFER == renderbuffertarget);
-
- GrFrameBufferObj *framebuffer = this->getFrameBuffer();
- // A render buffer cannot be attached to the default framebuffer
- GrAlwaysAssert(framebuffer);
-
- // a renderBufferID of 0 is acceptable - it unbinds the current
- // render buffer
- GrRenderBufferObj *renderbuffer = FIND(renderBufferID, GrRenderBufferObj,
- kRenderBuffer_ObjTypes);
-
- switch (attachment) {
- case GR_GL_COLOR_ATTACHMENT0:
- framebuffer->setColor(renderbuffer);
- break;
- case GR_GL_DEPTH_ATTACHMENT:
- framebuffer->setDepth(renderbuffer);
- break;
- case GR_GL_STENCIL_ATTACHMENT:
- framebuffer->setStencil(renderbuffer);
- break;
- default:
- GrAlwaysAssert(false);
- break;
- };
-
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- GrGLvoid framebufferTexture2D(GrGLenum target, GrGLenum attachment, GrGLenum textarget,
- GrGLuint textureID, GrGLint level) override {
-
- GrAlwaysAssert(GR_GL_FRAMEBUFFER == target);
- GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment ||
- GR_GL_DEPTH_ATTACHMENT == attachment ||
- GR_GL_STENCIL_ATTACHMENT == attachment);
- GrAlwaysAssert(GR_GL_TEXTURE_2D == textarget);
-
- GrFrameBufferObj *framebuffer = this->getFrameBuffer();
- // A texture cannot be attached to the default framebuffer
- GrAlwaysAssert(framebuffer);
-
- // A textureID of 0 is allowed - it unbinds the currently bound texture
- GrTextureObj *texture = FIND(textureID, GrTextureObj, kTexture_ObjTypes);
- if (texture) {
- // The texture shouldn't be bound to a texture unit - this
- // could lead to a feedback loop
- GrAlwaysAssert(!texture->getBound());
- }
-
- GrAlwaysAssert(0 == level);
-
- switch (attachment) {
- case GR_GL_COLOR_ATTACHMENT0:
- framebuffer->setColor(texture);
- break;
- case GR_GL_DEPTH_ATTACHMENT:
- framebuffer->setDepth(texture);
- break;
- case GR_GL_STENCIL_ATTACHMENT:
- framebuffer->setStencil(texture);
- break;
- default:
- GrAlwaysAssert(false);
- break;
- };
- }
+ if (frameBuffers[i] ==
+ this->getFrameBuffer()->getID()) {
+ // this ID is the current frame buffer - rebind to the default
+ this->setFrameBuffer(nullptr);
+ }
+ }
+ }
+
+ // then actually "delete" the buffers
+ for (int i = 0; i < n; ++i) {
+ GrFrameBufferObj *buffer = FIND(frameBuffers[i], GrFrameBufferObj,
+ kFrameBuffer_ObjTypes);
+ GrAlwaysAssert(buffer);
+
+ GrAlwaysAssert(!buffer->getDeleted());
+ buffer->deleteAction();
+ }
+ }
+
+ GrGLvoid deleteRenderbuffers(GrGLsizei n,const GrGLuint *renderBuffers) override {
+
+ // first potentially unbind the buffers
+ if (this->getRenderBuffer()) {
+ for (int i = 0; i < n; ++i) {
+
+ if (renderBuffers[i] ==
+ this->getRenderBuffer()->getID()) {
+ // this ID is the current render buffer - make no
+ // render buffer be bound
+ this->setRenderBuffer(nullptr);
+ }
+ }
+ }
+
+ // TODO: fuse the following block with DeleteTextures?
+ // Open GL will remove a deleted render buffer from the active frame
+ // buffer but not from any other frame buffer
+ if (this->getFrameBuffer()) {
+
+ GrFrameBufferObj *frameBuffer = this->getFrameBuffer();
+
+ for (int i = 0; i < n; ++i) {
+
+ if (frameBuffer->getColor() &&
+ renderBuffers[i] == frameBuffer->getColor()->getID()) {
+ frameBuffer->setColor(nullptr);
+ }
+ if (frameBuffer->getDepth() &&
+ renderBuffers[i] == frameBuffer->getDepth()->getID()) {
+ frameBuffer->setDepth(nullptr);
+ }
+ if (frameBuffer->getStencil() &&
+ renderBuffers[i] == frameBuffer->getStencil()->getID()) {
+ frameBuffer->setStencil(nullptr);
+ }
+ }
+ }
+
+ // then actually "delete" the buffers
+ for (int i = 0; i < n; ++i) {
+ GrRenderBufferObj *buffer = FIND(renderBuffers[i], GrRenderBufferObj,
+ kRenderBuffer_ObjTypes);
+ GrAlwaysAssert(buffer);
+
+ // OpenGL gives no guarantees if a render buffer is deleted
+ // while attached to something other than the currently
+ // bound frame buffer
+ GrAlwaysAssert(!buffer->getColorBound());
+ GrAlwaysAssert(!buffer->getDepthBound());
+ // However, at GrContext destroy time we release all GrRsources and so stencil buffers
+ // may get deleted before FBOs that refer to them.
+ //GrAlwaysAssert(!buffer->getStencilBound());
+
+ GrAlwaysAssert(!buffer->getDeleted());
+ buffer->deleteAction();
+ }
+ }
+
+ GrGLvoid framebufferRenderbuffer(GrGLenum target,
+ GrGLenum attachment,
+ GrGLenum renderbuffertarget,
+ GrGLuint renderBufferID) override {
+
+ GrAlwaysAssert(GR_GL_FRAMEBUFFER == target);
+ GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment ||
+ GR_GL_DEPTH_ATTACHMENT == attachment ||
+ GR_GL_STENCIL_ATTACHMENT == attachment);
+ GrAlwaysAssert(GR_GL_RENDERBUFFER == renderbuffertarget);
+
+ GrFrameBufferObj *framebuffer = this->getFrameBuffer();
+ // A render buffer cannot be attached to the default framebuffer
+ GrAlwaysAssert(framebuffer);
+
+ // a renderBufferID of 0 is acceptable - it unbinds the current
+ // render buffer
+ GrRenderBufferObj *renderbuffer = FIND(renderBufferID, GrRenderBufferObj,
+ kRenderBuffer_ObjTypes);
+
+ switch (attachment) {
+ case GR_GL_COLOR_ATTACHMENT0:
+ framebuffer->setColor(renderbuffer);
+ break;
+ case GR_GL_DEPTH_ATTACHMENT:
+ framebuffer->setDepth(renderbuffer);
+ break;
+ case GR_GL_STENCIL_ATTACHMENT:
+ framebuffer->setStencil(renderbuffer);
+ break;
+ default:
+ GrAlwaysAssert(false);
+ break;
+ };
+
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////
+ GrGLvoid framebufferTexture2D(GrGLenum target, GrGLenum attachment, GrGLenum textarget,
+ GrGLuint textureID, GrGLint level) override {
+
+ GrAlwaysAssert(GR_GL_FRAMEBUFFER == target);
+ GrAlwaysAssert(GR_GL_COLOR_ATTACHMENT0 == attachment ||
+ GR_GL_DEPTH_ATTACHMENT == attachment ||
+ GR_GL_STENCIL_ATTACHMENT == attachment);
+ GrAlwaysAssert(GR_GL_TEXTURE_2D == textarget);
+
+ GrFrameBufferObj *framebuffer = this->getFrameBuffer();
+ // A texture cannot be attached to the default framebuffer
+ GrAlwaysAssert(framebuffer);
+
+ // A textureID of 0 is allowed - it unbinds the currently bound texture
+ GrTextureObj *texture = FIND(textureID, GrTextureObj, kTexture_ObjTypes);
+ if (texture) {
+ // The texture shouldn't be bound to a texture unit - this
+ // could lead to a feedback loop
+ GrAlwaysAssert(!texture->getBound());
+ }
+
+ GrAlwaysAssert(0 == level);
+
+ switch (attachment) {
+ case GR_GL_COLOR_ATTACHMENT0:
+ framebuffer->setColor(texture);
+ break;
+ case GR_GL_DEPTH_ATTACHMENT:
+ framebuffer->setDepth(texture);
+ break;
+ case GR_GL_STENCIL_ATTACHMENT:
+ framebuffer->setStencil(texture);
+ break;
+ default:
+ GrAlwaysAssert(false);
+ break;
+ };
+ }
GrGLuint createProgram() override {
@@ -1229,8 +1229,28 @@ const char* DebugInterface::kExtensions[] = {
nullptr, // signifies the end of the array.
};
-} // anonymous namespace
+class DebugGLContext : public sk_gpu_test::GLContext {
+public:
+ DebugGLContext() {
+ this->init(new DebugInterface());
+ }
-////////////////////////////////////////////////////////////////////////////////
+ ~DebugGLContext() override { this->teardown(); }
-const GrGLInterface* GrGLCreateDebugInterface() { return new DebugInterface; }
+private:
+ void onPlatformMakeCurrent() const override {}
+ void onPlatformSwapBuffers() const override {}
+ GrGLFuncPtr onPlatformGetProcAddress(const char*) const override { return nullptr; }
+};
+} // anonymous namespace
+
+namespace sk_gpu_test {
+GLContext* CreateDebugGLContext() {
+ GLContext* ctx = new DebugGLContext();
+ if (ctx->isValid()) {
+ return ctx;
+ }
+ delete ctx;
+ return nullptr;
+}
+}
diff --git a/tools/gpu/gl/debug/DebugGLContext.h b/tools/gpu/gl/debug/DebugGLContext.h
new file mode 100644
index 0000000000..0ac505b632
--- /dev/null
+++ b/tools/gpu/gl/debug/DebugGLContext.h
@@ -0,0 +1,17 @@
+
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef DebugGLContext_DEFINED
+#define DebugGLContext_DEFINED
+
+#include "gl/GLContext.h"
+
+namespace sk_gpu_test {
+GLContext* CreateDebugGLContext();
+} // namespace sk_gpu_test
+
+#endif
diff --git a/src/gpu/gl/debug/GrBufferObj.cpp b/tools/gpu/gl/debug/GrBufferObj.cpp
index ee0993d6da..37d4438ef6 100644
--- a/src/gpu/gl/debug/GrBufferObj.cpp
+++ b/tools/gpu/gl/debug/GrBufferObj.cpp
@@ -1,3 +1,4 @@
+
/*
* Copyright 2012 Google Inc.
*
diff --git a/src/gpu/gl/debug/GrBufferObj.h b/tools/gpu/gl/debug/GrBufferObj.h
index 5b5015be96..96aef6ed0a 100644
--- a/src/gpu/gl/debug/GrBufferObj.h
+++ b/tools/gpu/gl/debug/GrBufferObj.h
@@ -1,3 +1,4 @@
+
/*
* Copyright 2012 Google Inc.
*
@@ -9,7 +10,7 @@
#define GrBufferObj_DEFINED
#include "GrFakeRefObj.h"
-#include "../GrGLDefines.h"
+#include "gl/GrGLDefines.h"
////////////////////////////////////////////////////////////////////////////////
class GrBufferObj : public GrFakeRefObj {
diff --git a/src/gpu/gl/debug/GrFBBindableObj.h b/tools/gpu/gl/debug/GrFBBindableObj.h
index 2d490ef08b..e2b43a6a1b 100644
--- a/src/gpu/gl/debug/GrFBBindableObj.h
+++ b/tools/gpu/gl/debug/GrFBBindableObj.h
@@ -1,3 +1,4 @@
+
/*
* Copyright 2012 Google Inc.
*
diff --git a/src/gpu/gl/debug/GrFakeRefObj.h b/tools/gpu/gl/debug/GrFakeRefObj.h
index 30580516fa..30580516fa 100644
--- a/src/gpu/gl/debug/GrFakeRefObj.h
+++ b/tools/gpu/gl/debug/GrFakeRefObj.h
diff --git a/src/gpu/gl/debug/GrFrameBufferObj.cpp b/tools/gpu/gl/debug/GrFrameBufferObj.cpp
index a8acc3de23..7dc12acafb 100644
--- a/src/gpu/gl/debug/GrFrameBufferObj.cpp
+++ b/tools/gpu/gl/debug/GrFrameBufferObj.cpp
@@ -1,3 +1,4 @@
+
/*
* Copyright 2012 Google Inc.
*
diff --git a/src/gpu/gl/debug/GrFrameBufferObj.h b/tools/gpu/gl/debug/GrFrameBufferObj.h
index 40e123e49f..42a0effe07 100644
--- a/src/gpu/gl/debug/GrFrameBufferObj.h
+++ b/tools/gpu/gl/debug/GrFrameBufferObj.h
@@ -1,3 +1,4 @@
+
/*
* Copyright 2012 Google Inc.
*
diff --git a/src/gpu/gl/debug/GrProgramObj.cpp b/tools/gpu/gl/debug/GrProgramObj.cpp
index d45bd1c113..d6cc36bd74 100644
--- a/src/gpu/gl/debug/GrProgramObj.cpp
+++ b/tools/gpu/gl/debug/GrProgramObj.cpp
@@ -1,3 +1,4 @@
+
/*
* Copyright 2012 Google Inc.
*
diff --git a/src/gpu/gl/debug/GrProgramObj.h b/tools/gpu/gl/debug/GrProgramObj.h
index 6e5ec65d9d..a25341a215 100644
--- a/src/gpu/gl/debug/GrProgramObj.h
+++ b/tools/gpu/gl/debug/GrProgramObj.h
@@ -1,3 +1,4 @@
+
/*
* Copyright 2012 Google Inc.
*
diff --git a/src/gpu/gl/debug/GrRenderBufferObj.h b/tools/gpu/gl/debug/GrRenderBufferObj.h
index dae08f5c78..8231ef58df 100644
--- a/src/gpu/gl/debug/GrRenderBufferObj.h
+++ b/tools/gpu/gl/debug/GrRenderBufferObj.h
@@ -1,3 +1,4 @@
+
/*
* Copyright 2012 Google Inc.
*
diff --git a/src/gpu/gl/debug/GrShaderObj.cpp b/tools/gpu/gl/debug/GrShaderObj.cpp
index 67cca3ed72..8d3caa1e3f 100644
--- a/src/gpu/gl/debug/GrShaderObj.cpp
+++ b/tools/gpu/gl/debug/GrShaderObj.cpp
@@ -1,3 +1,4 @@
+
/*
* Copyright 2012 Google Inc.
*
diff --git a/src/gpu/gl/debug/GrShaderObj.h b/tools/gpu/gl/debug/GrShaderObj.h
index 871494ac8d..327bd7f084 100644
--- a/src/gpu/gl/debug/GrShaderObj.h
+++ b/tools/gpu/gl/debug/GrShaderObj.h
@@ -1,3 +1,4 @@
+
/*
* Copyright 2012 Google Inc.
*
@@ -9,7 +10,7 @@
#define GrShaderObj_DEFINED
#include "GrFakeRefObj.h"
-#include "../GrGLDefines.h"
+#include "gl/GrGLDefines.h"
////////////////////////////////////////////////////////////////////////////////
class GrShaderObj : public GrFakeRefObj {
diff --git a/src/gpu/gl/debug/GrTextureObj.cpp b/tools/gpu/gl/debug/GrTextureObj.cpp
index 62cb399245..86063fbc99 100644
--- a/src/gpu/gl/debug/GrTextureObj.cpp
+++ b/tools/gpu/gl/debug/GrTextureObj.cpp
@@ -1,3 +1,4 @@
+
/*
* Copyright 2012 Google Inc.
*
diff --git a/src/gpu/gl/debug/GrTextureObj.h b/tools/gpu/gl/debug/GrTextureObj.h
index bc649f3b38..fcf851db86 100644
--- a/src/gpu/gl/debug/GrTextureObj.h
+++ b/tools/gpu/gl/debug/GrTextureObj.h
@@ -1,3 +1,4 @@
+
/*
* Copyright 2012 Google Inc.
*
diff --git a/src/gpu/gl/debug/GrTextureUnitObj.cpp b/tools/gpu/gl/debug/GrTextureUnitObj.cpp
index 8de0b092cd..316dcecd93 100644
--- a/src/gpu/gl/debug/GrTextureUnitObj.cpp
+++ b/tools/gpu/gl/debug/GrTextureUnitObj.cpp
@@ -1,3 +1,4 @@
+
/*
* Copyright 2012 Google Inc.
*
diff --git a/src/gpu/gl/debug/GrTextureUnitObj.h b/tools/gpu/gl/debug/GrTextureUnitObj.h
index 5c7a03980b..5c7a03980b 100644
--- a/src/gpu/gl/debug/GrTextureUnitObj.h
+++ b/tools/gpu/gl/debug/GrTextureUnitObj.h
diff --git a/src/gpu/gl/debug/GrVertexArrayObj.h b/tools/gpu/gl/debug/GrVertexArrayObj.h
index 989c610924..989c610924 100644
--- a/src/gpu/gl/debug/GrVertexArrayObj.h
+++ b/tools/gpu/gl/debug/GrVertexArrayObj.h
diff --git a/src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp b/tools/gpu/gl/egl/CreatePlatformGLContext_egl.cpp
index 1644254c09..ac2e7ca7cf 100644
--- a/src/gpu/gl/egl/SkCreatePlatformGLContext_egl.cpp
+++ b/tools/gpu/gl/egl/CreatePlatformGLContext_egl.cpp
@@ -1,10 +1,11 @@
+
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "gl/SkGLContext.h"
+#include "gl/GLContext.h"
#include <GLES2/gl2.h>
@@ -34,7 +35,7 @@ private:
typedef SkGpuFenceSync INHERITED;
};
-class EGLGLContext : public SkGLContext {
+class EGLGLContext : public sk_gpu_test::GLContext {
public:
EGLGLContext(GrGLStandard forcedGpuAPI);
~EGLGLContext() override;
@@ -42,7 +43,7 @@ public:
GrEGLImage texture2DToEGLImage(GrGLuint texID) const override;
void destroyEGLImage(GrEGLImage) const override;
GrGLuint eglImageToExternalTexture(GrEGLImage) const override;
- SkGLContext* createNew() const override;
+ sk_gpu_test::GLContext* createNew() const override;
private:
void destroyGLContext();
@@ -253,8 +254,8 @@ GrGLuint EGLGLContext::eglImageToExternalTexture(GrEGLImage image) const {
return texID;
}
-SkGLContext* EGLGLContext::createNew() const {
- SkGLContext* ctx = SkCreatePlatformGLContext(this->gl()->fStandard);
+sk_gpu_test::GLContext* EGLGLContext::createNew() const {
+ sk_gpu_test::GLContext* ctx = new EGLGLContext(this->gl()->fStandard);
if (ctx) {
ctx->makeCurrent();
}
@@ -317,17 +318,20 @@ void SkEGLFenceSync::deleteFence(SkPlatformGpuFence platformFence) const {
eglDestroySyncKHR(fDisplay, eglsync);
}
-} // anonymous namespace
+} // anonymous namespace
-SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* shareContext) {
+namespace sk_gpu_test {
+GLContext *CreatePlatformGLContext(GrGLStandard forcedGpuAPI, GLContext *shareContext) {
SkASSERT(!shareContext);
if (shareContext) {
return nullptr;
}
- EGLGLContext* ctx = new EGLGLContext(forcedGpuAPI);
+ EGLGLContext *ctx = new EGLGLContext(forcedGpuAPI);
if (!ctx->isValid()) {
delete ctx;
return nullptr;
}
return ctx;
}
+} // namespace sk_gpu_test
+
diff --git a/src/gpu/gl/glx/SkCreatePlatformGLContext_glx.cpp b/tools/gpu/gl/glx/CreatePlatformGLContext_glx.cpp
index d0bd1de428..b2168e3c5a 100644
--- a/src/gpu/gl/glx/SkCreatePlatformGLContext_glx.cpp
+++ b/tools/gpu/gl/glx/CreatePlatformGLContext_glx.cpp
@@ -1,10 +1,11 @@
+
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "gl/SkGLContext.h"
+#include "gl/GLContext.h"
#include <X11/Xlib.h>
#include <GL/glx.h>
@@ -43,7 +44,7 @@ static int ctxErrorHandler(Display *dpy, XErrorEvent *ev) {
return 0;
}
-class GLXGLContext : public SkGLContext {
+class GLXGLContext : public sk_gpu_test::GLContext {
public:
GLXGLContext(GrGLStandard forcedGpuAPI, GLXGLContext* shareList);
~GLXGLContext() override;
@@ -330,10 +331,11 @@ GrGLFuncPtr GLXGLContext::onPlatformGetProcAddress(const char* procName) const {
return glXGetProcAddress(reinterpret_cast<const GLubyte*>(procName));
}
-} // anonymous namespace
+} // anonymous namespace
-SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* shareContext) {
- GLXGLContext* glxShareContext = reinterpret_cast<GLXGLContext*>(shareContext);
+namespace sk_gpu_test {
+GLContext *CreatePlatformGLContext(GrGLStandard forcedGpuAPI, GLContext *shareContext) {
+ GLXGLContext *glxShareContext = reinterpret_cast<GLXGLContext *>(shareContext);
GLXGLContext *ctx = new GLXGLContext(forcedGpuAPI, glxShareContext);
if (!ctx->isValid()) {
delete ctx;
@@ -341,3 +343,4 @@ SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* s
}
return ctx;
}
+} // namespace sk_gpu_test
diff --git a/src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm b/tools/gpu/gl/iOS/CreatePlatformGLContext_iOS.mm
index 54dc59af03..d6507f280f 100644
--- a/src/gpu/gl/iOS/SkCreatePlatformGLContext_iOS.mm
+++ b/tools/gpu/gl/iOS/CreatePlatformGLContext_iOS.mm
@@ -6,7 +6,7 @@
* found in the LICENSE file.
*/
-#include "gl/SkGLContext.h"
+#include "GLContext.h"
#import <OpenGLES/EAGL.h>
#include <dlfcn.h>
@@ -14,7 +14,7 @@
namespace {
-class IOSGLContext : public SkGLContext {
+class IOSGLContext : public sk_gpu_test::GLContext {
public:
IOSGLContext();
~IOSGLContext() override;
@@ -87,9 +87,10 @@ GrGLFuncPtr IOSGLContext::onPlatformGetProcAddress(const char* procName) const {
return reinterpret_cast<GrGLFuncPtr>(dlsym(fGLLibrary, procName));
}
-} // anonymous namespace
+} // anonymous namespace
-SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* shareContext) {
+namespace sk_gpu_test {
+GLContext *CreatePlatformGLContext(GrGLStandard forcedGpuAPI, GLContext *shareContext) {
SkASSERT(!shareContext);
if (shareContext) {
return NULL;
@@ -97,10 +98,11 @@ SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* s
if (kGL_GrGLStandard == forcedGpuAPI) {
return NULL;
}
- IOSGLContext* ctx = new IOSGLContext;
+ IOSGLContext *ctx = new IOSGLContext;
if (!ctx->isValid()) {
delete ctx;
return NULL;
}
return ctx;
}
+}
diff --git a/src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp b/tools/gpu/gl/mac/CreatePlatformGLContext_mac.cpp
index 0ca62ad1cc..7da99d7eb5 100644
--- a/src/gpu/gl/mac/SkCreatePlatformGLContext_mac.cpp
+++ b/tools/gpu/gl/mac/CreatePlatformGLContext_mac.cpp
@@ -1,3 +1,4 @@
+
/*
* Copyright 2011 Google Inc.
*
@@ -5,16 +6,15 @@
* found in the LICENSE file.
*/
#include "SkTypes.h"
-#if defined(SK_BUILD_FOR_MAC)
-#include "gl/SkGLContext.h"
+#include "gl/GLContext.h"
#include "AvailabilityMacros.h"
#include <OpenGL/OpenGL.h>
#include <dlfcn.h>
namespace {
-class MacGLContext : public SkGLContext {
+class MacGLContext : public sk_gpu_test::GLContext {
public:
MacGLContext();
~MacGLContext() override;
@@ -106,9 +106,10 @@ GrGLFuncPtr MacGLContext::onPlatformGetProcAddress(const char* procName) const {
return reinterpret_cast<GrGLFuncPtr>(dlsym(fGLLibrary, procName));
}
-} // anonymous namespace
+} // anonymous namespace
-SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* shareContext) {
+namespace sk_gpu_test {
+GLContext* CreatePlatformGLContext(GrGLStandard forcedGpuAPI, GLContext* shareContext) {
SkASSERT(!shareContext);
if (shareContext) {
return nullptr;
@@ -124,5 +125,4 @@ SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* s
}
return ctx;
}
-
-#endif//defined(SK_BUILD_FOR_MAC)
+} // namespace sk_gpu_test
diff --git a/src/gpu/gl/mesa/SkMesaGLContext.cpp b/tools/gpu/gl/mesa/GLContext_mesa.cpp
index eeccbd64ae..e6cc7c7f4b 100644
--- a/src/gpu/gl/mesa/SkMesaGLContext.cpp
+++ b/tools/gpu/gl/mesa/GLContext_mesa.cpp
@@ -1,3 +1,4 @@
+
/*
* Copyright 2011 Google Inc.
*
@@ -7,14 +8,52 @@
#include <GL/osmesa.h>
-#include "gl/mesa/SkMesaGLContext.h"
+#include "gl/mesa/GLContext_mesa.h"
#include "gl/GrGLDefines.h"
+#include "gl/GrGLAssembleInterface.h"
+#include "gl/GrGLUtil.h"
+#include "osmesa_wrapper.h"
+
+namespace {
+
+static GrGLFuncPtr osmesa_get(void* ctx, const char name[]) {
+ SkASSERT(nullptr == ctx);
+ SkASSERT(OSMesaGetCurrentContext());
+ return OSMesaGetProcAddress(name);
+}
+
+static const GrGLInterface* create_mesa_interface() {
+ if (nullptr == OSMesaGetCurrentContext()) {
+ return nullptr;
+ }
+ return GrGLAssembleInterface(nullptr, osmesa_get);
+}
+
static const GrGLint gBOGUS_SIZE = 16;
-SkMesaGLContext::SkMesaGLContext()
- : fContext(static_cast<Context>(0))
- , fImage(nullptr) {
+class MesaGLContext : public sk_gpu_test::GLContext {
+private:
+ typedef intptr_t Context;
+
+public:
+ MesaGLContext();
+ ~MesaGLContext() override;
+
+private:
+ void destroyGLContext();
+
+ void onPlatformMakeCurrent() const override;
+
+ void onPlatformSwapBuffers() const override;
+
+ GrGLFuncPtr onPlatformGetProcAddress(const char *) const override;
+
+ Context fContext;
+ GrGLubyte *fImage;
+};
+
+MesaGLContext::MesaGLContext() : fContext(static_cast<Context>(0)), fImage(nullptr) {
GR_STATIC_ASSERT(sizeof(Context) == sizeof(OSMesaContext));
/* Create an RGBA-mode context */
@@ -22,7 +61,7 @@ SkMesaGLContext::SkMesaGLContext()
/* specify Z, stencil, accum sizes */
fContext = (Context)OSMesaCreateContextExt(OSMESA_BGRA, 0, 0, 0, nullptr);
#else
- fContext = (Context)OSMesaCreateContext(OSMESA_BGRA, nullptr);
+ fContext = (Context) OSMesaCreateContext(OSMESA_BGRA, nullptr);
#endif
if (!fContext) {
SkDebugf("OSMesaCreateContext failed!\n");
@@ -39,7 +78,7 @@ SkMesaGLContext::SkMesaGLContext()
}
// Bind the buffer to the context and make it current
- if (!OSMesaMakeCurrent((OSMesaContext)fContext,
+ if (!OSMesaMakeCurrent((OSMesaContext) fContext,
fImage,
GR_GL_UNSIGNED_BYTE,
gBOGUS_SIZE,
@@ -49,7 +88,7 @@ SkMesaGLContext::SkMesaGLContext()
return;
}
- SkAutoTUnref<const GrGLInterface> gl(GrGLCreateMesaInterface());
+ SkAutoTUnref<const GrGLInterface> gl(create_mesa_interface());
if (nullptr == gl.get()) {
SkDebugf("Could not create GL interface!\n");
this->destroyGLContext();
@@ -65,36 +104,48 @@ SkMesaGLContext::SkMesaGLContext()
this->init(gl.release());
}
-SkMesaGLContext::~SkMesaGLContext() {
+MesaGLContext::~MesaGLContext() {
this->teardown();
this->destroyGLContext();
}
-void SkMesaGLContext::destroyGLContext() {
+void MesaGLContext::destroyGLContext() {
if (fImage) {
sk_free(fImage);
fImage = nullptr;
}
if (fContext) {
- OSMesaDestroyContext((OSMesaContext)fContext);
+ OSMesaDestroyContext((OSMesaContext) fContext);
fContext = static_cast<Context>(0);
}
}
-
-void SkMesaGLContext::onPlatformMakeCurrent() const {
+void MesaGLContext::onPlatformMakeCurrent() const {
if (fContext) {
- if (!OSMesaMakeCurrent((OSMesaContext)fContext, fImage,
+ if (!OSMesaMakeCurrent((OSMesaContext) fContext, fImage,
GR_GL_UNSIGNED_BYTE, gBOGUS_SIZE, gBOGUS_SIZE)) {
SkDebugf("Could not make MESA context current.");
}
}
}
-void SkMesaGLContext::onPlatformSwapBuffers() const { }
+void MesaGLContext::onPlatformSwapBuffers() const { }
-GrGLFuncPtr SkMesaGLContext::onPlatformGetProcAddress(const char* procName) const {
+GrGLFuncPtr MesaGLContext::onPlatformGetProcAddress(const char *procName) const {
return OSMesaGetProcAddress(procName);
}
+} // anonymous namespace
+
+
+namespace sk_gpu_test {
+GLContext *CreateMesaGLContext() {
+ MesaGLContext *ctx = new MesaGLContext;
+ if (!ctx->isValid()) {
+ delete ctx;
+ return nullptr;
+ }
+ return ctx;
+}
+} // sk_gpu_test
diff --git a/tools/gpu/gl/mesa/GLContext_mesa.h b/tools/gpu/gl/mesa/GLContext_mesa.h
new file mode 100644
index 0000000000..0d6ee4dc10
--- /dev/null
+++ b/tools/gpu/gl/mesa/GLContext_mesa.h
@@ -0,0 +1,17 @@
+
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef GLContext_mesa_DEFINED
+#define GLContext_mesa_DEFINED
+
+#include "gl/GLContext.h"
+
+namespace sk_gpu_test {
+GLContext* CreateMesaGLContext();
+} // namespace sk_gpu_test
+
+#endif
diff --git a/tools/gpu/gl/mesa/osmesa_wrapper.h b/tools/gpu/gl/mesa/osmesa_wrapper.h
new file mode 100644
index 0000000000..70de99376d
--- /dev/null
+++ b/tools/gpu/gl/mesa/osmesa_wrapper.h
@@ -0,0 +1,16 @@
+
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+// Older versions of XQuartz have a bug where a header included by osmesa.h
+// defines GL_GLEXT_PROTOTYPES. This will cause a redefinition warning if
+// the file that includes osmesa.h already defined it. XCode 3 uses a version
+// of gcc (4.2.1) that does not support the diagnostic pragma to disable a
+// warning (added in 4.2.4). So we use the system_header pragma to shut GCC
+// up about warnings in osmesa.h
+#pragma GCC system_header
+#include <GL/osmesa.h>
diff --git a/tools/gpu/gl/null/NullGLContext.cpp b/tools/gpu/gl/null/NullGLContext.cpp
new file mode 100644
index 0000000000..4781c90e4f
--- /dev/null
+++ b/tools/gpu/gl/null/NullGLContext.cpp
@@ -0,0 +1,630 @@
+
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "NullGLContext.h"
+#include "gl/GrGLTestInterface.h"
+#include "gl/GrGLDefines.h"
+#include "gl/GrGLInterface.h"
+#include "gl/GrGLTypes.h"
+#include "SkMutex.h"
+#include "SkTDArray.h"
+
+namespace {
+
+class BufferObj {
+public:
+ BufferObj(GrGLuint id) : fID(id), fDataPtr(nullptr), fSize(0), fMapped(false) {}
+ ~BufferObj() { delete[] fDataPtr; }
+
+ void allocate(GrGLsizeiptr size, const GrGLchar* dataPtr) {
+ if (fDataPtr) {
+ SkASSERT(0 != fSize);
+ delete[] fDataPtr;
+ }
+
+ fSize = size;
+ fDataPtr = new char[size];
+ }
+
+ GrGLuint id() const { return fID; }
+ GrGLchar* dataPtr() { return fDataPtr; }
+ GrGLsizeiptr size() const { return fSize; }
+
+ void setMapped(bool mapped) { fMapped = mapped; }
+ bool mapped() const { return fMapped; }
+
+private:
+ GrGLuint fID;
+ GrGLchar* fDataPtr;
+ GrGLsizeiptr fSize; // size in bytes
+ bool fMapped;
+};
+
+// This class maintains a sparsely populated array of buffer pointers.
+class BufferManager {
+public:
+ BufferManager() : fFreeListHead(kFreeListEnd) {}
+
+ ~BufferManager() {
+ // nullptr out the entries that are really free list links rather than ptrs before deleting.
+ intptr_t curr = fFreeListHead;
+ while (kFreeListEnd != curr) {
+ intptr_t next = reinterpret_cast<intptr_t>(fBuffers[SkToS32(curr)]);
+ fBuffers[SkToS32(curr)] = nullptr;
+ curr = next;
+ }
+
+ fBuffers.deleteAll();
+ }
+
+ BufferObj* lookUp(GrGLuint id) {
+ BufferObj* buffer = fBuffers[id];
+ SkASSERT(buffer && buffer->id() == id);
+ return buffer;
+ }
+
+ BufferObj* create() {
+ GrGLuint id;
+ BufferObj* buffer;
+
+ if (kFreeListEnd == fFreeListHead) {
+ // no free slots - create a new one
+ id = fBuffers.count();
+ buffer = new BufferObj(id);
+ *fBuffers.append() = buffer;
+ } else {
+ // grab the head of the free list and advance the head to the next free slot.
+ id = static_cast<GrGLuint>(fFreeListHead);
+ fFreeListHead = reinterpret_cast<intptr_t>(fBuffers[id]);
+
+ buffer = new BufferObj(id);
+ fBuffers[id] = buffer;
+ }
+
+ return buffer;
+ }
+
+ void free(BufferObj* buffer) {
+ SkASSERT(fBuffers.count() > 0);
+
+ GrGLuint id = buffer->id();
+ delete buffer;
+
+ fBuffers[id] = reinterpret_cast<BufferObj*>(fFreeListHead);
+ fFreeListHead = id;
+ }
+
+private:
+ static const intptr_t kFreeListEnd = -1;
+ // Index of the first entry of fBuffers in the free list. Free slots in fBuffers are indices to
+ // the next free slot. The last free slot has a value of kFreeListEnd.
+ intptr_t fFreeListHead;
+ SkTDArray<BufferObj*> fBuffers;
+};
+
+/** Null interface implementation */
+class NullInterface : public GrGLTestInterface {
+public:
+ NullInterface()
+ : fCurrArrayBuffer(0)
+ , fCurrElementArrayBuffer(0)
+ , fCurrPixelPackBuffer(0)
+ , fCurrPixelUnpackBuffer(0)
+ , fCurrShaderID(0)
+ , fCurrGenericID(0)
+ , fCurrUniformLocation(0) {
+ this->init(kGL_GrGLStandard);
+ }
+
+ GrGLenum checkFramebufferStatus(GrGLenum target) override {
+ return GR_GL_FRAMEBUFFER_COMPLETE;
+ }
+
+ GrGLvoid genBuffers(GrGLsizei n, GrGLuint* ids) override {
+ for (int i = 0; i < n; ++i) {
+ BufferObj* buffer = fBufferManager.create();
+ ids[i] = buffer->id();
+ }
+ }
+
+ GrGLvoid bufferData(GrGLenum target, GrGLsizeiptr size, const GrGLvoid* data,
+ GrGLenum usage) override {
+ GrGLuint id = 0;
+
+ switch (target) {
+ case GR_GL_ARRAY_BUFFER:
+ id = fCurrArrayBuffer;
+ break;
+ case GR_GL_ELEMENT_ARRAY_BUFFER:
+ id = fCurrElementArrayBuffer;
+ break;
+ case GR_GL_PIXEL_PACK_BUFFER:
+ id = fCurrPixelPackBuffer;
+ break;
+ case GR_GL_PIXEL_UNPACK_BUFFER:
+ id = fCurrPixelUnpackBuffer;
+ break;
+ default:
+ SkFAIL("Unexpected target to nullGLBufferData");
+ break;
+ }
+
+ if (id > 0) {
+ BufferObj* buffer = fBufferManager.lookUp(id);
+ buffer->allocate(size, (const GrGLchar*) data);
+ }
+ }
+
+ GrGLuint createProgram() override {
+ return ++fCurrProgramID;
+ }
+
+ GrGLuint createShader(GrGLenum type) override {
+ return ++fCurrShaderID;
+ }
+
+ GrGLvoid bindBuffer(GrGLenum target, GrGLuint buffer) override {
+ switch (target) {
+ case GR_GL_ARRAY_BUFFER:
+ fCurrArrayBuffer = buffer;
+ break;
+ case GR_GL_ELEMENT_ARRAY_BUFFER:
+ fCurrElementArrayBuffer = buffer;
+ break;
+ case GR_GL_PIXEL_PACK_BUFFER:
+ fCurrPixelPackBuffer = buffer;
+ break;
+ case GR_GL_PIXEL_UNPACK_BUFFER:
+ fCurrPixelUnpackBuffer = buffer;
+ break;
+ }
+ }
+
+ // deleting a bound buffer has the side effect of binding 0
+ GrGLvoid deleteBuffers(GrGLsizei n, const GrGLuint* ids) override {
+ for (int i = 0; i < n; ++i) {
+ if (ids[i] == fCurrArrayBuffer) {
+ fCurrArrayBuffer = 0;
+ }
+ if (ids[i] == fCurrElementArrayBuffer) {
+ fCurrElementArrayBuffer = 0;
+ }
+ if (ids[i] == fCurrPixelPackBuffer) {
+ fCurrPixelPackBuffer = 0;
+ }
+ if (ids[i] == fCurrPixelUnpackBuffer) {
+ fCurrPixelUnpackBuffer = 0;
+ }
+
+ BufferObj* buffer = fBufferManager.lookUp(ids[i]);
+ fBufferManager.free(buffer);
+ }
+ }
+
+ GrGLvoid genFramebuffers(GrGLsizei n, GrGLuint *framebuffers) override {
+ this->genGenericIds(n, framebuffers);
+ }
+
+ GrGLvoid genQueries(GrGLsizei n, GrGLuint *ids) override { this->genGenericIds(n, ids); }
+
+ GrGLvoid genRenderbuffers(GrGLsizei n, GrGLuint *renderbuffers) override {
+ this->genGenericIds(n, renderbuffers);
+ }
+
+ GrGLvoid genTextures(GrGLsizei n, GrGLuint *textures) override {
+ this->genGenericIds(n, textures);
+ }
+
+ GrGLvoid genVertexArrays(GrGLsizei n, GrGLuint *arrays) override {
+ this->genGenericIds(n, arrays);
+ }
+
+ GrGLenum getError() override { return GR_GL_NO_ERROR; }
+
+ GrGLvoid getIntegerv(GrGLenum pname, GrGLint* params) override {
+ // TODO: remove from Ganesh the #defines for gets we don't use.
+ // We would like to minimize gets overall due to performance issues
+ switch (pname) {
+ case GR_GL_CONTEXT_PROFILE_MASK:
+ *params = GR_GL_CONTEXT_COMPATIBILITY_PROFILE_BIT;
+ break;
+ case GR_GL_STENCIL_BITS:
+ *params = 8;
+ break;
+ case GR_GL_SAMPLES:
+ *params = 1;
+ break;
+ case GR_GL_FRAMEBUFFER_BINDING:
+ *params = 0;
+ break;
+ case GR_GL_VIEWPORT:
+ params[0] = 0;
+ params[1] = 0;
+ params[2] = 800;
+ params[3] = 600;
+ break;
+ case GR_GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
+ case GR_GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS:
+ case GR_GL_MAX_TEXTURE_IMAGE_UNITS:
+ case GR_GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
+ *params = 8;
+ break;
+ case GR_GL_MAX_TEXTURE_COORDS:
+ *params = 8;
+ break;
+ case GR_GL_MAX_VERTEX_UNIFORM_VECTORS:
+ *params = kDefaultMaxVertexUniformVectors;
+ break;
+ case GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS:
+ *params = kDefaultMaxFragmentUniformVectors;
+ break;
+ case GR_GL_MAX_FRAGMENT_UNIFORM_COMPONENTS:
+ *params = 16 * 4;
+ break;
+ case GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS:
+ *params = 0;
+ break;
+ case GR_GL_COMPRESSED_TEXTURE_FORMATS:
+ break;
+ case GR_GL_MAX_TEXTURE_SIZE:
+ *params = 8192;
+ break;
+ case GR_GL_MAX_RENDERBUFFER_SIZE:
+ *params = 8192;
+ break;
+ case GR_GL_MAX_SAMPLES:
+ *params = 32;
+ break;
+ case GR_GL_MAX_VERTEX_ATTRIBS:
+ *params = kDefaultMaxVertexAttribs;
+ break;
+ case GR_GL_MAX_VARYING_VECTORS:
+ *params = kDefaultMaxVaryingVectors;
+ break;
+ case GR_GL_NUM_EXTENSIONS: {
+ GrGLint i = 0;
+ while (kExtensions[i++]);
+ *params = i;
+ break;
+ }
+ default:
+ SkFAIL("Unexpected pname to GetIntegerv");
+ }
+ }
+
+ GrGLvoid getProgramiv(GrGLuint program, GrGLenum pname, GrGLint* params) override {
+ this->getShaderOrProgramiv(program, pname, params);
+ }
+
+ GrGLvoid getProgramInfoLog(GrGLuint program, GrGLsizei bufsize, GrGLsizei* length,
+ char* infolog) override {
+ this->getInfoLog(program, bufsize, length, infolog);
+ }
+
+ GrGLvoid getMultisamplefv(GrGLenum pname, GrGLuint index, GrGLfloat* val) override {
+ val[0] = val[1] = 0.5f;
+ }
+
+ GrGLvoid getQueryiv(GrGLenum GLtarget, GrGLenum pname, GrGLint *params) override {
+ switch (pname) {
+ case GR_GL_CURRENT_QUERY:
+ *params = 0;
+ break;
+ case GR_GL_QUERY_COUNTER_BITS:
+ *params = 32;
+ break;
+ default:
+ SkFAIL("Unexpected pname passed GetQueryiv.");
+ }
+ }
+
+ GrGLvoid getQueryObjecti64v(GrGLuint id, GrGLenum pname, GrGLint64 *params) override {
+ this->queryResult(id, pname, params);
+ }
+
+ GrGLvoid getQueryObjectiv(GrGLuint id, GrGLenum pname, GrGLint *params) override {
+ this->queryResult(id, pname, params);
+ }
+
+ GrGLvoid getQueryObjectui64v(GrGLuint id, GrGLenum pname, GrGLuint64 *params) override {
+ this->queryResult(id, pname, params);
+ }
+
+ GrGLvoid getQueryObjectuiv(GrGLuint id, GrGLenum pname, GrGLuint *params) override {
+ this->queryResult(id, pname, params);
+ }
+
+ GrGLvoid getShaderiv(GrGLuint shader, GrGLenum pname, GrGLint* params) override {
+ this->getShaderOrProgramiv(shader, pname, params);
+ }
+
+ GrGLvoid getShaderInfoLog(GrGLuint shader, GrGLsizei bufsize, GrGLsizei* length,
+ char* infolog) override {
+ this->getInfoLog(shader, bufsize, length, infolog);
+ }
+
+ const GrGLubyte* getString(GrGLenum name) override {
+ switch (name) {
+ case GR_GL_EXTENSIONS:
+ return CombinedExtensionString();
+ case GR_GL_VERSION:
+ return (const GrGLubyte*)"4.0 Null GL";
+ case GR_GL_SHADING_LANGUAGE_VERSION:
+ return (const GrGLubyte*)"4.20.8 Null GLSL";
+ case GR_GL_VENDOR:
+ return (const GrGLubyte*)"Null Vendor";
+ case GR_GL_RENDERER:
+ return (const GrGLubyte*)"The Null (Non-)Renderer";
+ default:
+ SkFAIL("Unexpected name passed to GetString");
+ return nullptr;
+ }
+ }
+
+ const GrGLubyte* getStringi(GrGLenum name, GrGLuint i) override {
+ switch (name) {
+ case GR_GL_EXTENSIONS: {
+ GrGLint count;
+ this->getIntegerv(GR_GL_NUM_EXTENSIONS, &count);
+ if ((GrGLint)i <= count) {
+ return (const GrGLubyte*) kExtensions[i];
+ } else {
+ return nullptr;
+ }
+ }
+ default:
+ SkFAIL("Unexpected name passed to GetStringi");
+ return nullptr;
+ }
+ }
+
+ GrGLint getUniformLocation(GrGLuint program, const char* name) override {
+ return ++fCurrUniformLocation;
+ }
+
+ GrGLvoid* mapBufferRange(GrGLenum target, GrGLintptr offset, GrGLsizeiptr length,
+ GrGLbitfield access) override {
+ GrGLuint id = 0;
+ switch (target) {
+ case GR_GL_ARRAY_BUFFER:
+ id = fCurrArrayBuffer;
+ break;
+ case GR_GL_ELEMENT_ARRAY_BUFFER:
+ id = fCurrElementArrayBuffer;
+ break;
+ case GR_GL_PIXEL_PACK_BUFFER:
+ id = fCurrPixelPackBuffer;
+ break;
+ case GR_GL_PIXEL_UNPACK_BUFFER:
+ id = fCurrPixelUnpackBuffer;
+ break;
+ }
+
+ if (id > 0) {
+ // We just ignore the offset and length here.
+ BufferObj* buffer = fBufferManager.lookUp(id);
+ SkASSERT(!buffer->mapped());
+ buffer->setMapped(true);
+ return buffer->dataPtr();
+ }
+ return nullptr;
+ }
+
+ GrGLvoid* mapBuffer(GrGLenum target, GrGLenum access) override {
+ GrGLuint id = 0;
+ switch (target) {
+ case GR_GL_ARRAY_BUFFER:
+ id = fCurrArrayBuffer;
+ break;
+ case GR_GL_ELEMENT_ARRAY_BUFFER:
+ id = fCurrElementArrayBuffer;
+ break;
+ case GR_GL_PIXEL_PACK_BUFFER:
+ id = fCurrPixelPackBuffer;
+ break;
+ case GR_GL_PIXEL_UNPACK_BUFFER:
+ id = fCurrPixelUnpackBuffer;
+ break;
+ }
+
+ if (id > 0) {
+ BufferObj* buffer = fBufferManager.lookUp(id);
+ SkASSERT(!buffer->mapped());
+ buffer->setMapped(true);
+ return buffer->dataPtr();
+ }
+
+ SkASSERT(false);
+ return nullptr; // no buffer bound to target
+ }
+
+ GrGLboolean unmapBuffer(GrGLenum target) override {
+ GrGLuint id = 0;
+ switch (target) {
+ case GR_GL_ARRAY_BUFFER:
+ id = fCurrArrayBuffer;
+ break;
+ case GR_GL_ELEMENT_ARRAY_BUFFER:
+ id = fCurrElementArrayBuffer;
+ break;
+ case GR_GL_PIXEL_PACK_BUFFER:
+ id = fCurrPixelPackBuffer;
+ break;
+ case GR_GL_PIXEL_UNPACK_BUFFER:
+ id = fCurrPixelUnpackBuffer;
+ break;
+ }
+ if (id > 0) {
+ BufferObj* buffer = fBufferManager.lookUp(id);
+ SkASSERT(buffer->mapped());
+ buffer->setMapped(false);
+ return GR_GL_TRUE;
+ }
+
+ GrAlwaysAssert(false);
+ return GR_GL_FALSE; // GR_GL_INVALID_OPERATION;
+ }
+
+ GrGLvoid getBufferParameteriv(GrGLenum target, GrGLenum pname, GrGLint* params) override {
+ switch (pname) {
+ case GR_GL_BUFFER_MAPPED: {
+ *params = GR_GL_FALSE;
+ GrGLuint id = 0;
+ switch (target) {
+ case GR_GL_ARRAY_BUFFER:
+ id = fCurrArrayBuffer;
+ break;
+ case GR_GL_ELEMENT_ARRAY_BUFFER:
+ id = fCurrElementArrayBuffer;
+ break;
+ case GR_GL_PIXEL_PACK_BUFFER:
+ id = fCurrPixelPackBuffer;
+ break;
+ case GR_GL_PIXEL_UNPACK_BUFFER:
+ id = fCurrPixelUnpackBuffer;
+ break;
+ }
+ if (id > 0) {
+ BufferObj* buffer = fBufferManager.lookUp(id);
+ if (buffer->mapped()) {
+ *params = GR_GL_TRUE;
+ }
+ }
+ break; }
+ default:
+ SkFAIL("Unexpected pname to GetBufferParamateriv");
+ break;
+ }
+ };
+
+private:
+ BufferManager fBufferManager;
+ GrGLuint fCurrArrayBuffer;
+ GrGLuint fCurrElementArrayBuffer;
+ GrGLuint fCurrPixelPackBuffer;
+ GrGLuint fCurrPixelUnpackBuffer;
+ GrGLuint fCurrProgramID;
+ GrGLuint fCurrShaderID;
+ GrGLuint fCurrGenericID;
+ GrGLuint fCurrUniformLocation;
+
+ // the OpenGLES 2.0 spec says this must be >= 128
+ static const GrGLint kDefaultMaxVertexUniformVectors = 128;
+
+ // the OpenGLES 2.0 spec says this must be >=16
+ static const GrGLint kDefaultMaxFragmentUniformVectors = 16;
+
+ // the OpenGLES 2.0 spec says this must be >= 8
+ static const GrGLint kDefaultMaxVertexAttribs = 8;
+
+ // the OpenGLES 2.0 spec says this must be >= 8
+ static const GrGLint kDefaultMaxVaryingVectors = 8;
+
+ static const char* kExtensions[];
+
+ static const GrGLubyte* CombinedExtensionString() {
+ static SkString gExtString;
+ static SkMutex gMutex;
+ gMutex.acquire();
+ if (0 == gExtString.size()) {
+ int i = 0;
+ while (kExtensions[i]) {
+ if (i > 0) {
+ gExtString.append(" ");
+ }
+ gExtString.append(kExtensions[i]);
+ ++i;
+ }
+ }
+ gMutex.release();
+ return (const GrGLubyte*) gExtString.c_str();
+ }
+
+ GrGLvoid genGenericIds(GrGLsizei n, GrGLuint* ids) {
+ for (int i = 0; i < n; ++i) {
+ ids[i] = ++fCurrGenericID;
+ }
+ }
+
+ GrGLvoid getInfoLog(GrGLuint object, GrGLsizei bufsize, GrGLsizei* length,
+ char* infolog) {
+ if (length) {
+ *length = 0;
+ }
+ if (bufsize > 0) {
+ *infolog = 0;
+ }
+ }
+
+ GrGLvoid getShaderOrProgramiv(GrGLuint object, GrGLenum pname, GrGLint* params) {
+ switch (pname) {
+ case GR_GL_LINK_STATUS: // fallthru
+ case GR_GL_COMPILE_STATUS:
+ *params = GR_GL_TRUE;
+ break;
+ case GR_GL_INFO_LOG_LENGTH:
+ *params = 0;
+ break;
+ // we don't expect any other pnames
+ default:
+ SkFAIL("Unexpected pname to GetProgramiv");
+ break;
+ }
+ }
+
+ template <typename T>
+ void queryResult(GrGLenum GLtarget, GrGLenum pname, T *params) {
+ switch (pname) {
+ case GR_GL_QUERY_RESULT_AVAILABLE:
+ *params = GR_GL_TRUE;
+ break;
+ case GR_GL_QUERY_RESULT:
+ *params = 0;
+ break;
+ default:
+ SkFAIL("Unexpected pname passed to GetQueryObject.");
+ break;
+ }
+ }
+
+ typedef GrGLTestInterface INHERITED;
+};
+
+const char* NullInterface::kExtensions[] = {
+ "GL_ARB_framebuffer_object",
+ "GL_ARB_blend_func_extended",
+ "GL_ARB_timer_query",
+ "GL_ARB_draw_buffers",
+ "GL_ARB_occlusion_query",
+ "GL_EXT_stencil_wrap",
+ nullptr, // signifies the end of the array.
+};
+
+class NullGLContext : public sk_gpu_test::GLContext {
+public:
+ NullGLContext() { this->init(new NullInterface); }
+ ~NullGLContext() override { this->teardown(); }
+
+private:
+ void onPlatformMakeCurrent() const override {};
+ void onPlatformSwapBuffers() const override {}
+ GrGLFuncPtr onPlatformGetProcAddress(const char*) const override { return nullptr; }
+};
+} // anonymous namespace
+
+namespace sk_gpu_test {
+GLContext* CreateNullGLContext() {
+ GLContext* ctx = new NullGLContext();
+ if (ctx->isValid()) {
+ return ctx;
+ }
+ delete ctx;
+ return nullptr;
+}
+} // namespace sk_gpu_test
+
diff --git a/tools/gpu/gl/null/NullGLContext.h b/tools/gpu/gl/null/NullGLContext.h
new file mode 100644
index 0000000000..16fb9fd1df
--- /dev/null
+++ b/tools/gpu/gl/null/NullGLContext.h
@@ -0,0 +1,17 @@
+
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef NullGLContext_DEFINED
+#define NullGLContext_DEFINED
+
+#include "gl/GLContext.h"
+
+namespace sk_gpu_test {
+GLContext* CreateNullGLContext();
+} // namespace sk_gpu_test
+
+#endif
diff --git a/src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp b/tools/gpu/gl/win/CreatePlatformGLContext_win.cpp
index e99aa15eb7..efee28b74b 100644
--- a/src/gpu/gl/win/SkCreatePlatformGLContext_win.cpp
+++ b/tools/gpu/gl/win/CreatePlatformGLContext_win.cpp
@@ -1,3 +1,4 @@
+
/*
* Copyright 2011 Google Inc.
*
@@ -5,7 +6,7 @@
* found in the LICENSE file.
*/
-#include "gl/SkGLContext.h"
+#include "gl/GLContext.h"
#include <windows.h>
#include <GL/GL.h>
@@ -16,7 +17,7 @@
namespace {
-class WinGLContext : public SkGLContext {
+class WinGLContext : public sk_gpu_test::GLContext {
public:
WinGLContext(GrGLStandard forcedGpuAPI);
~WinGLContext() override;
@@ -186,15 +187,18 @@ GrGLFuncPtr WinGLContext::onPlatformGetProcAddress(const char* name) const {
} // anonymous namespace
-SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* shareContext) {
+namespace sk_gpu_test {
+GLContext* CreatePlatformGLContext(GrGLStandard forcedGpuAPI, GLContext *shareContext) {
SkASSERT(!shareContext);
if (shareContext) {
return nullptr;
}
- WinGLContext* ctx = new WinGLContext(forcedGpuAPI);
+ WinGLContext *ctx = new WinGLContext(forcedGpuAPI);
if (!ctx->isValid()) {
delete ctx;
return nullptr;
}
return ctx;
}
+} // namespace sk_gpu_test
+
diff --git a/tools/kilobench/kilobench.cpp b/tools/kilobench/kilobench.cpp
index c0422d81eb..81238353e2 100644
--- a/tools/kilobench/kilobench.cpp
+++ b/tools/kilobench/kilobench.cpp
@@ -20,6 +20,7 @@
#include "Timer.h"
#include "VisualSKPBench.h"
#include "gl/GrGLDefines.h"
+#include "gl/GrGLUtil.h"
#include "../private/SkMutex.h"
#include "../private/SkSemaphore.h"
#include "../private/SkGpuFenceSync.h"
@@ -29,6 +30,8 @@
#include <sys/types.h>
#include <sys/wait.h>
+using namespace sk_gpu_test;
+
/*
* This is an experimental GPU only benchmarking program. The initial implementation will only
* support SKPs.
@@ -144,14 +147,14 @@ struct GPUTarget {
void setup() {
fGL->makeCurrent();
// Make sure we're done with whatever came before.
- SK_GL(*fGL, Finish());
+ GR_GL_CALL(fGL->gl(), Finish());
}
SkCanvas* beginTiming(SkCanvas* canvas) { return canvas; }
void endTiming(bool usePlatformSwapBuffers) {
if (fGL) {
- SK_GL(*fGL, Flush());
+ GR_GL_CALL(fGL->gl(), Flush());
if (usePlatformSwapBuffers) {
fGL->swapBuffers();
} else {
@@ -160,7 +163,7 @@ struct GPUTarget {
}
}
void finish() {
- SK_GL(*fGL, Finish());
+ GR_GL_CALL(fGL->gl(), Finish());
}
bool needsFrameTiming(int* maxFrameLag) const {
@@ -215,10 +218,10 @@ struct GPUTarget {
return true;
}
- SkGLContext* gl() { return fGL; }
+ GLContext* gl() { return fGL; }
private:
- SkGLContext* fGL;
+ GLContext* fGL;
SkAutoTDelete<SkSurface> fSurface;
};
@@ -279,7 +282,7 @@ static int clamp_loops(int loops) {
static double now_ms() { return SkTime::GetNSecs() * 1e-6; }
struct TimingThread {
- TimingThread(SkGLContext* mainContext)
+ TimingThread(GLContext* mainContext)
: fFenceSync(mainContext->fenceSync())
, fMainContext(mainContext)
, fDone(false) {}
@@ -305,8 +308,8 @@ struct TimingThread {
void timingLoop() {
// Create a context which shares display lists with the main thread
- SkAutoTDelete<SkGLContext> glContext(SkCreatePlatformGLContext(kNone_GrGLStandard,
- fMainContext));
+ SkAutoTDelete<GLContext> glContext(CreatePlatformGLContext(kNone_GrGLStandard,
+ fMainContext));
glContext->makeCurrent();
// Basic timing methodology is:
@@ -402,7 +405,7 @@ private:
SyncQueue fFrameEndSyncs;
SkTArray<double> fTimings;
SkMutex fDoneMutex;
- SkGLContext* fMainContext;
+ GLContext* fMainContext;
bool fDone;
};
diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp
index 1d946abaa0..d9e1bdaa33 100644
--- a/tools/skiaserve/Request.cpp
+++ b/tools/skiaserve/Request.cpp
@@ -10,6 +10,8 @@
#include "SkPictureRecorder.h"
#include "SkPixelSerializer.h"
+using namespace sk_gpu_test;
+
static int kDefaultWidth = 1920;
static int kDefaultHeight = 1080;
@@ -63,8 +65,8 @@ SkData* Request::writeCanvasToPng(SkCanvas* canvas) {
SkCanvas* Request::getCanvas() {
#if SK_SUPPORT_GPU
GrContextFactory* factory = fContextFactory;
- SkGLContext* gl = factory->getContextInfo(GrContextFactory::kNative_GLContextType,
- GrContextFactory::kNone_GLContextOptions).fGLContext;
+ GLContext* gl = factory->getContextInfo(GrContextFactory::kNative_GLContextType,
+ GrContextFactory::kNone_GLContextOptions).fGLContext;
gl->makeCurrent();
#endif
SkASSERT(fDebugCanvas);
diff --git a/tools/skiaserve/Request.h b/tools/skiaserve/Request.h
index e3bc373841..d19c2ba801 100644
--- a/tools/skiaserve/Request.h
+++ b/tools/skiaserve/Request.h
@@ -19,7 +19,9 @@
#include "UrlDataManager.h"
+namespace sk_gpu_test {
class GrContextFactory;
+}
struct MHD_Connection;
struct MHD_PostProcessor;
@@ -69,7 +71,7 @@ private:
GrContext* getContext();
sk_sp<SkPicture> fPicture;
- GrContextFactory* fContextFactory;
+ sk_gpu_test::GrContextFactory* fContextFactory;
SkAutoTUnref<SkSurface> fSurface;
bool fGPUEnabled;
};