Revert of Move SkGLContext and some GrGLInterface implementations to skgputest module (patchset #13 id:240001 of https://codereview.chromium.org/1815823002/ )
Reason for revert: red bots Original issue's description: > 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 > > Committed: https://skia.googlesource.com/skia/+/fe3456cb006110d045b26ff3f8681b893a757b58 TBR=jvanverth@google.com,bsalomon@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1845473004
This commit is contained in:
parent
fe3456cb00
commit
6f70d43719
@ -56,9 +56,6 @@
|
||||
#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
|
||||
|
||||
@ -158,21 +155,21 @@ bool Target::capturePixels(SkBitmap* bmp) {
|
||||
#if SK_SUPPORT_GPU
|
||||
struct GPUTarget : public Target {
|
||||
explicit GPUTarget(const Config& c) : Target(c), gl(nullptr) { }
|
||||
GLContext* gl;
|
||||
SkGLContext* gl;
|
||||
|
||||
void setup() override {
|
||||
this->gl->makeCurrent();
|
||||
// Make sure we're done with whatever came before.
|
||||
GR_GL_CALL(this->gl->gl(), Finish());
|
||||
SK_GL(*this->gl, Finish());
|
||||
}
|
||||
void endTiming() override {
|
||||
if (this->gl) {
|
||||
GR_GL_CALL(this->gl->gl(), Flush());
|
||||
SK_GL(*this->gl, Flush());
|
||||
this->gl->waitOnSyncOrSwap();
|
||||
}
|
||||
}
|
||||
void fence() override {
|
||||
GR_GL_CALL(this->gl->gl(), Finish());
|
||||
SK_GL(*this->gl, Finish());
|
||||
}
|
||||
|
||||
bool needsFrameTiming(int* maxFrameLag) const override {
|
||||
@ -203,16 +200,16 @@ struct GPUTarget : public Target {
|
||||
}
|
||||
void fillOptions(ResultsWriter* log) override {
|
||||
const GrGLubyte* version;
|
||||
GR_GL_CALL_RET(this->gl->gl(), version, GetString(GR_GL_VERSION));
|
||||
SK_GL_RET(*this->gl, version, GetString(GR_GL_VERSION));
|
||||
log->configOption("GL_VERSION", (const char*)(version));
|
||||
|
||||
GR_GL_CALL_RET(this->gl->gl(), version, GetString(GR_GL_RENDERER));
|
||||
SK_GL_RET(*this->gl, version, GetString(GR_GL_RENDERER));
|
||||
log->configOption("GL_RENDERER", (const char*) version);
|
||||
|
||||
GR_GL_CALL_RET(this->gl->gl(), version, GetString(GR_GL_VENDOR));
|
||||
SK_GL_RET(*this->gl, version, GetString(GR_GL_VENDOR));
|
||||
log->configOption("GL_VENDOR", (const char*) version);
|
||||
|
||||
GR_GL_CALL_RET(this->gl->gl(), version, GetString(GR_GL_SHADING_LANGUAGE_VERSION));
|
||||
SK_GL_RET(*this->gl, version, GetString(GR_GL_SHADING_LANGUAGE_VERSION));
|
||||
log->configOption("GL_SHADING_LANGUAGE_VERSION", (const char*) version);
|
||||
}
|
||||
};
|
||||
|
@ -29,8 +29,8 @@ struct Config {
|
||||
SkColorProfileType profile;
|
||||
int samples;
|
||||
#if SK_SUPPORT_GPU
|
||||
sk_gpu_test::GrContextFactory::GLContextType ctxType;
|
||||
sk_gpu_test::GrContextFactory::GLContextOptions ctxOptions;
|
||||
GrContextFactory::GLContextType ctxType;
|
||||
GrContextFactory::GLContextOptions ctxOptions;
|
||||
bool useDFText;
|
||||
#else
|
||||
int bogusInt;
|
||||
|
@ -90,6 +90,7 @@ 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/*
|
||||
@ -120,6 +121,8 @@ 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)
|
||||
|
@ -70,8 +70,6 @@ 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;
|
||||
|
||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||
|
||||
@ -1413,7 +1411,7 @@ int dm_main() {
|
||||
namespace skiatest {
|
||||
namespace {
|
||||
typedef void(*TestWithGrContext)(skiatest::Reporter*, GrContext*);
|
||||
typedef void(*TestWithGrContextAndGLContext)(skiatest::Reporter*, GrContext*, GLContext*);
|
||||
typedef void(*TestWithGrContextAndGLContext)(skiatest::Reporter*, GrContext*, SkGLContext*);
|
||||
#if SK_SUPPORT_GPU
|
||||
template<typename T>
|
||||
void call_test(T test, skiatest::Reporter* reporter, const GrContextFactory::ContextInfo& context);
|
||||
|
@ -28,13 +28,12 @@ namespace DM {
|
||||
|
||||
static const bool kGPUDisabled = false;
|
||||
|
||||
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) {
|
||||
static inline sk_sp<SkSurface> NewGpuSurface(GrContextFactory* grFactory,
|
||||
GrContextFactory::GLContextType type,
|
||||
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,
|
||||
@ -60,7 +59,6 @@ public:
|
||||
void dumpGpuStats(SkString*) const {}
|
||||
};
|
||||
|
||||
namespace sk_gpu_test {
|
||||
class GrContextFactory {
|
||||
public:
|
||||
GrContextFactory() {};
|
||||
@ -85,15 +83,14 @@ public:
|
||||
|
||||
void abandonContexts() {}
|
||||
};
|
||||
} // namespace sk_gpu_test
|
||||
|
||||
namespace DM {
|
||||
|
||||
static const bool kGPUDisabled = true;
|
||||
|
||||
static inline SkSurface* NewGpuSurface(sk_gpu_test::GrContextFactory*,
|
||||
sk_gpu_test::GrContextFactory::GLContextType,
|
||||
sk_gpu_test::GrContextFactory::GLContextOptions,
|
||||
static inline SkSurface* NewGpuSurface(GrContextFactory*,
|
||||
GrContextFactory::GLContextType,
|
||||
GrContextFactory::GLContextOptions,
|
||||
SkImageInfo,
|
||||
int,
|
||||
bool) {
|
||||
|
@ -45,8 +45,6 @@ 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) {}
|
||||
|
@ -232,8 +232,7 @@ public:
|
||||
|
||||
class GPUSink : public Sink {
|
||||
public:
|
||||
GPUSink(sk_gpu_test::GrContextFactory::GLContextType,
|
||||
sk_gpu_test::GrContextFactory::GLContextOptions,
|
||||
GPUSink(GrContextFactory::GLContextType, GrContextFactory::GLContextOptions,
|
||||
int samples, bool diText, SkColorType colorType, SkColorProfileType profileType,
|
||||
bool threaded);
|
||||
|
||||
@ -242,13 +241,13 @@ public:
|
||||
const char* fileExtension() const override { return "png"; }
|
||||
SinkFlags flags() const override { return SinkFlags{ SinkFlags::kGPU, SinkFlags::kDirect }; }
|
||||
private:
|
||||
sk_gpu_test::GrContextFactory::GLContextType fContextType;
|
||||
sk_gpu_test::GrContextFactory::GLContextOptions fContextOptions;
|
||||
int fSampleCount;
|
||||
bool fUseDIText;
|
||||
SkColorType fColorType;
|
||||
SkColorProfileType fProfileType;
|
||||
bool fThreaded;
|
||||
GrContextFactory::GLContextType fContextType;
|
||||
GrContextFactory::GLContextOptions fContextOptions;
|
||||
int fSampleCount;
|
||||
bool fUseDIText;
|
||||
SkColorType fColorType;
|
||||
SkColorProfileType fProfileType;
|
||||
bool fThreaded;
|
||||
};
|
||||
|
||||
class PDFSink : public Sink {
|
||||
|
@ -433,7 +433,7 @@ DEF_SIMPLE_GM(new_texture_image, canvas, 225, 60) {
|
||||
GrContext* context = nullptr;
|
||||
#if SK_SUPPORT_GPU
|
||||
context = canvas->getGrContext();
|
||||
sk_gpu_test::GrContextFactory factory;
|
||||
GrContextFactory factory;
|
||||
#endif
|
||||
if (!context) {
|
||||
skiagm::GM::DrawGpuOnlyMessage(canvas);
|
||||
|
@ -153,7 +153,6 @@
|
||||
'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',
|
||||
|
@ -24,14 +24,7 @@
|
||||
'include_dirs': [
|
||||
'../tools/flags',
|
||||
],
|
||||
},
|
||||
'conditions': [
|
||||
['skia_gpu', {
|
||||
'dependencies': [
|
||||
'gputest.gyp:skgputest',
|
||||
],
|
||||
}],
|
||||
],
|
||||
}
|
||||
},
|
||||
{
|
||||
'target_name': 'flags_common',
|
||||
|
56
gyp/gpu.gyp
56
gyp/gpu.gyp
@ -102,6 +102,11 @@
|
||||
'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).
|
||||
],
|
||||
@ -146,6 +151,23 @@
|
||||
],
|
||||
},
|
||||
}],
|
||||
[ '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': [
|
||||
@ -157,12 +179,46 @@
|
||||
'../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',
|
||||
|
59
gyp/gpu.gypi
59
gyp/gpu.gypi
@ -318,7 +318,6 @@
|
||||
'<(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',
|
||||
@ -409,6 +408,8 @@
|
||||
'<(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',
|
||||
@ -421,6 +422,8 @@
|
||||
'<(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',
|
||||
@ -498,6 +501,60 @@
|
||||
'<(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',
|
||||
],
|
||||
},
|
||||
}
|
||||
|
@ -9,85 +9,28 @@
|
||||
'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/utils',
|
||||
'../tools/gpu',
|
||||
'../../src/gpu',
|
||||
],
|
||||
'all_dependent_settings': {
|
||||
'direct_dependent_settings': {
|
||||
'include_dirs': [
|
||||
'../tools/gpu',
|
||||
'../src/gpu',
|
||||
'../../src/gpu',
|
||||
],
|
||||
},
|
||||
'dependencies': [
|
||||
'gpu.gyp:skgpu',
|
||||
],
|
||||
'sources': [
|
||||
'<!@(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)$'], ],
|
||||
}],
|
||||
'<(skia_src_path)/gpu/GrContextFactory.cpp',
|
||||
'<(skia_src_path)/gpu/GrContextFactory.h',
|
||||
'<(skia_src_path)/gpu/GrTest.cpp',
|
||||
'<(skia_src_path)/gpu/GrTest.h',
|
||||
],
|
||||
},
|
||||
],
|
||||
|
@ -17,7 +17,6 @@
|
||||
'../gm',
|
||||
'../include/private',
|
||||
'../src/core',
|
||||
'../src/gpu',
|
||||
'../tools/VisualBench',
|
||||
],
|
||||
'sources': [
|
||||
@ -27,7 +26,6 @@
|
||||
],
|
||||
'dependencies': [
|
||||
'flags.gyp:flags',
|
||||
'gpu.gyp:skgpu',
|
||||
'gputest.gyp:skgputest',
|
||||
'jsoncpp.gyp:jsoncpp',
|
||||
'skia_lib.gyp:skia_lib',
|
||||
|
@ -37,6 +37,15 @@
|
||||
'-llog',
|
||||
],
|
||||
}],
|
||||
[ 'skia_gpu == 1', {
|
||||
'include_dirs': [
|
||||
'../src/gpu',
|
||||
],
|
||||
'sources': [
|
||||
'../src/gpu/GrContextFactory.cpp',
|
||||
'../src/gpu/GrContextFactory.h',
|
||||
]
|
||||
}],
|
||||
],
|
||||
},
|
||||
],
|
||||
|
@ -14,7 +14,6 @@
|
||||
'type': 'executable',
|
||||
'include_dirs': [
|
||||
'../src/core',
|
||||
'../src/gpu',
|
||||
'../src/ports',
|
||||
'../tools/debugger',
|
||||
'../tools/json',
|
||||
|
@ -20,7 +20,6 @@
|
||||
'../include/private',
|
||||
'../src/core',
|
||||
'../src/effects',
|
||||
'../src/gpu',
|
||||
'../src/images',
|
||||
'../src/image',
|
||||
'../src/pdf',
|
||||
|
@ -43,18 +43,39 @@ const GrGLInterface* GrGLDefaultInterface();
|
||||
*/
|
||||
SK_API const GrGLInterface* GrGLCreateNativeInterface();
|
||||
|
||||
#if GR_GL_PER_GL_FUNC_CALLBACK
|
||||
typedef void (*GrGLInterfaceCallbackProc)(const GrGLInterface*);
|
||||
typedef intptr_t GrGLInterfaceCallbackData;
|
||||
#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();
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Creates a null GrGLInterface that doesn't draw anything. Used for measuring
|
||||
* CPU overhead. TODO: We would like to move this to tools/gpu/gl/null but currently
|
||||
* Chromium is using it in its unit tests.
|
||||
* CPU overhead.
|
||||
*/
|
||||
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*);
|
||||
|
@ -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 GLContext_DEFINED
|
||||
#define GLContext_DEFINED
|
||||
#ifndef SkGLContext_DEFINED
|
||||
#define SkGLContext_DEFINED
|
||||
|
||||
#include "gl/GrGLInterface.h"
|
||||
#include "GrGLInterface.h"
|
||||
#include "../private/SkGpuFenceSync.h"
|
||||
|
||||
|
||||
namespace sk_gpu_test {
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
class GLContext : public SkNoncopyable {
|
||||
class SK_API SkGLContext : public SkNoncopyable {
|
||||
public:
|
||||
virtual ~GLContext();
|
||||
virtual ~SkGLContext();
|
||||
|
||||
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,13 +39,12 @@ 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
|
||||
@ -82,42 +81,37 @@ public:
|
||||
* Creates a new GL context of the same type and makes the returned context current
|
||||
* (if not null).
|
||||
*/
|
||||
virtual GLContext *createNew() const { return nullptr; }
|
||||
virtual SkGLContext* createNew() const { return nullptr; }
|
||||
|
||||
class GLFenceSync; // SkGpuFenceSync implementation that uses the OpenGL functionality.
|
||||
|
||||
/*
|
||||
* returns the fencesync object owned by this GLContext
|
||||
* returns the fencesync object owned by this SkGLContext
|
||||
*/
|
||||
SkGpuFenceSync *fenceSync() { return fFenceSync.get(); }
|
||||
SkGpuFenceSync* fenceSync() { return fFenceSync.get(); }
|
||||
|
||||
protected:
|
||||
GLContext();
|
||||
SkGLContext();
|
||||
|
||||
/*
|
||||
* 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. */
|
||||
@ -126,16 +120,26 @@ 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 GLContext created
|
||||
* context with which to share display lists. This should be a pointer to an SkGLContext 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.
|
||||
*/
|
||||
GLContext* CreatePlatformGLContext(GrGLStandard forcedGpuAPI, GLContext *shareContext = nullptr);
|
||||
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
|
||||
|
||||
} // namespace sk_gpu_test
|
||||
#endif
|
26
include/gpu/gl/SkNullGLContext.h
Normal file
26
include/gpu/gl/SkNullGLContext.h
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
/*
|
||||
* 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
|
61
include/gpu/gl/angle/SkANGLEGLContext.h
Normal file
61
include/gpu/gl/angle/SkANGLEGLContext.h
Normal file
@ -0,0 +1,61 @@
|
||||
|
||||
/*
|
||||
* 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
|
63
include/gpu/gl/command_buffer/SkCommandBufferGLContext.h
Normal file
63
include/gpu/gl/command_buffer/SkCommandBufferGLContext.h
Normal file
@ -0,0 +1,63 @@
|
||||
|
||||
/*
|
||||
* 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
|
@ -33,14 +33,11 @@
|
||||
#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"
|
||||
# if SK_ANGLE
|
||||
# include "gl/angle/GLContext_angle.h"
|
||||
# endif
|
||||
#include "gl/GrGLInterface.h"
|
||||
#include "gl/GrGLUtil.h"
|
||||
#include "GrRenderTarget.h"
|
||||
#include "GrContext.h"
|
||||
#include "SkGpuDevice.h"
|
||||
#else
|
||||
class GrContext;
|
||||
#endif
|
||||
@ -236,7 +233,7 @@ public:
|
||||
break;
|
||||
#if SK_ANGLE
|
||||
case kANGLE_DeviceType:
|
||||
glInterface.reset(sk_gpu_test::CreateANGLEGLInterface());
|
||||
glInterface.reset(GrGLCreateANGLEInterface());
|
||||
break;
|
||||
#endif // SK_ANGLE
|
||||
#if SK_COMMAND_BUFFER
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
*
|
||||
@ -7,23 +6,25 @@
|
||||
*/
|
||||
|
||||
#include "GrContextFactory.h"
|
||||
#include "gl/GLContext.h"
|
||||
|
||||
#if SK_ANGLE
|
||||
#include "gl/angle/GLContext_angle.h"
|
||||
#include "gl/angle/SkANGLEGLContext.h"
|
||||
#endif
|
||||
#if SK_COMMAND_BUFFER
|
||||
#include "gl/command_buffer/GLContext_command_buffer.h"
|
||||
#include "gl/command_buffer/SkCommandBufferGLContext.h"
|
||||
#endif
|
||||
#include "gl/debug/DebugGLContext.h"
|
||||
#include "gl/debug/SkDebugGLContext.h"
|
||||
#if SK_MESA
|
||||
#include "gl/mesa/GLContext_mesa.h"
|
||||
#include "gl/mesa/SkMesaGLContext.h"
|
||||
#endif
|
||||
#include "gl/null/NullGLContext.h"
|
||||
#if SK_VULKAN
|
||||
#include "vk/GrVkBackendContext.h"
|
||||
#endif
|
||||
#include "gl/SkGLContext.h"
|
||||
#include "gl/SkNullGLContext.h"
|
||||
#include "gl/GrGLGpu.h"
|
||||
#include "GrCaps.h"
|
||||
|
||||
namespace sk_gpu_test {
|
||||
GrContextFactory::GrContextFactory() { }
|
||||
|
||||
GrContextFactory::GrContextFactory(const GrContextOptions& opts)
|
||||
@ -73,43 +74,43 @@ GrContextFactory::ContextInfo GrContextFactory::getContextInfo(GLContextType typ
|
||||
return ContextInfo(context.fGrContext, context.fGLContext);
|
||||
}
|
||||
}
|
||||
SkAutoTDelete<GLContext> glCtx;
|
||||
SkAutoTDelete<SkGLContext> glCtx;
|
||||
SkAutoTUnref<GrContext> grCtx;
|
||||
switch (type) {
|
||||
case kNative_GLContextType:
|
||||
glCtx.reset(CreatePlatformGLContext(kNone_GrGLStandard));
|
||||
glCtx.reset(SkCreatePlatformGLContext(kNone_GrGLStandard));
|
||||
break;
|
||||
case kGL_GLContextType:
|
||||
glCtx.reset(CreatePlatformGLContext(kGL_GrGLStandard));
|
||||
glCtx.reset(SkCreatePlatformGLContext(kGL_GrGLStandard));
|
||||
break;
|
||||
case kGLES_GLContextType:
|
||||
glCtx.reset(CreatePlatformGLContext(kGLES_GrGLStandard));
|
||||
glCtx.reset(SkCreatePlatformGLContext(kGLES_GrGLStandard));
|
||||
break;
|
||||
#if SK_ANGLE
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
case kANGLE_GLContextType:
|
||||
glCtx.reset(CreateANGLEDirect3DGLContext());
|
||||
glCtx.reset(SkANGLEGLContext::CreateDirectX());
|
||||
break;
|
||||
#endif
|
||||
case kANGLE_GL_GLContextType:
|
||||
glCtx.reset(CreateANGLEOpenGLGLContext());
|
||||
glCtx.reset(SkANGLEGLContext::CreateOpenGL());
|
||||
break;
|
||||
#endif
|
||||
#if SK_COMMAND_BUFFER
|
||||
case kCommandBuffer_GLContextType:
|
||||
glCtx.reset(CommandBufferGLContext::Create());
|
||||
glCtx.reset(SkCommandBufferGLContext::Create());
|
||||
break;
|
||||
#endif
|
||||
#if SK_MESA
|
||||
case kMESA_GLContextType:
|
||||
glCtx.reset(CreateMesaGLContext());
|
||||
glCtx.reset(SkMesaGLContext::Create());
|
||||
break;
|
||||
#endif
|
||||
case kNull_GLContextType:
|
||||
glCtx.reset(CreateNullGLContext());
|
||||
glCtx.reset(SkNullGLContext::Create());
|
||||
break;
|
||||
case kDebug_GLContextType:
|
||||
glCtx.reset(CreateDebugGLContext());
|
||||
glCtx.reset(SkDebugGLContext::Create());
|
||||
break;
|
||||
}
|
||||
if (nullptr == glCtx.get()) {
|
||||
@ -128,14 +129,15 @@ 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()) {
|
||||
@ -154,4 +156,3 @@ GrContextFactory::ContextInfo GrContextFactory::getContextInfo(GLContextType typ
|
||||
context.fOptions = options;
|
||||
return ContextInfo(context.fGrContext, context.fGLContext);
|
||||
}
|
||||
} // namespace sk_gpu_test
|
@ -11,10 +11,9 @@
|
||||
#include "GrContext.h"
|
||||
#include "GrContextOptions.h"
|
||||
|
||||
#include "gl/GLContext.h"
|
||||
#include "gl/SkGLContext.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
|
||||
@ -110,11 +109,11 @@ public:
|
||||
struct ContextInfo {
|
||||
ContextInfo()
|
||||
: fGrContext(nullptr), fGLContext(nullptr) { }
|
||||
ContextInfo(GrContext* grContext, GLContext* glContext)
|
||||
ContextInfo(GrContext* grContext, SkGLContext* glContext)
|
||||
: fGrContext(grContext), fGLContext(glContext) { }
|
||||
GrContext* fGrContext;
|
||||
GLContext* fGLContext; //! Valid until the factory destroys it via abandonContexts() or
|
||||
//! destroyContexts().
|
||||
SkGLContext* fGLContext; //! Valid until the factory destroys it via abandonContexts() or
|
||||
//! destroyContexts().
|
||||
};
|
||||
|
||||
/**
|
||||
@ -133,13 +132,13 @@ public:
|
||||
|
||||
private:
|
||||
struct Context {
|
||||
GLContextType fType;
|
||||
GLContextOptions fOptions;
|
||||
GLContext* fGLContext;
|
||||
GrContext* fGrContext;
|
||||
GLContextType fType;
|
||||
GLContextOptions fOptions;
|
||||
SkGLContext* fGLContext;
|
||||
GrContext* fGrContext;
|
||||
};
|
||||
SkTArray<Context, true> fContexts;
|
||||
const GrContextOptions fGlobalOptions;
|
||||
};
|
||||
} // namespace sk_gpu_test
|
||||
|
||||
#endif
|
@ -11,10 +11,6 @@
|
||||
#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) {}
|
||||
|
@ -1,18 +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.
|
||||
*/
|
||||
#include "GLContext.h"
|
||||
#include "gl/GrGLUtil.h"
|
||||
#include "gl/SkGLContext.h"
|
||||
#include "GrGLUtil.h"
|
||||
#include "SkGpuFenceSync.h"
|
||||
|
||||
namespace sk_gpu_test {
|
||||
class GLContext::GLFenceSync : public SkGpuFenceSync {
|
||||
class SkGLContext::GLFenceSync : public SkGpuFenceSync {
|
||||
public:
|
||||
static GLFenceSync* CreateIfSupported(const GLContext*);
|
||||
static GLFenceSync* CreateIfSupported(const SkGLContext*);
|
||||
|
||||
SkPlatformGpuFence SK_WARN_UNUSED_RESULT insertFence() const override;
|
||||
bool waitFence(SkPlatformGpuFence fence, bool flush) const override;
|
||||
@ -38,12 +36,12 @@ private:
|
||||
typedef SkGpuFenceSync INHERITED;
|
||||
};
|
||||
|
||||
GLContext::GLContext()
|
||||
SkGLContext::SkGLContext()
|
||||
: fCurrentFenceIdx(0) {
|
||||
memset(fFrameFences, 0, sizeof(fFrameFences));
|
||||
}
|
||||
|
||||
GLContext::~GLContext() {
|
||||
SkGLContext::~SkGLContext() {
|
||||
// Subclass should call teardown.
|
||||
#ifdef SK_DEBUG
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(fFrameFences); i++) {
|
||||
@ -54,13 +52,13 @@ GLContext::~GLContext() {
|
||||
SkASSERT(nullptr == fFenceSync.get());
|
||||
}
|
||||
|
||||
void GLContext::init(const GrGLInterface* gl, SkGpuFenceSync* fenceSync) {
|
||||
void SkGLContext::init(const GrGLInterface* gl, SkGpuFenceSync* fenceSync) {
|
||||
SkASSERT(!fGL.get());
|
||||
fGL.reset(gl);
|
||||
fFenceSync.reset(fenceSync ? fenceSync : GLFenceSync::CreateIfSupported(this));
|
||||
}
|
||||
|
||||
void GLContext::teardown() {
|
||||
void SkGLContext::teardown() {
|
||||
if (fFenceSync) {
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(fFrameFences); i++) {
|
||||
if (fFrameFences[i]) {
|
||||
@ -74,15 +72,15 @@ void GLContext::teardown() {
|
||||
fGL.reset(nullptr);
|
||||
}
|
||||
|
||||
void GLContext::makeCurrent() const {
|
||||
void SkGLContext::makeCurrent() const {
|
||||
this->onPlatformMakeCurrent();
|
||||
}
|
||||
|
||||
void GLContext::swapBuffers() {
|
||||
void SkGLContext::swapBuffers() {
|
||||
this->onPlatformSwapBuffers();
|
||||
}
|
||||
|
||||
void GLContext::waitOnSyncOrSwap() {
|
||||
void SkGLContext::waitOnSyncOrSwap() {
|
||||
if (!fFenceSync) {
|
||||
// Fallback on the platform SwapBuffers method for synchronization. This may have no effect.
|
||||
this->swapBuffers();
|
||||
@ -100,7 +98,7 @@ void GLContext::waitOnSyncOrSwap() {
|
||||
fCurrentFenceIdx = (fCurrentFenceIdx + 1) % SK_ARRAY_COUNT(fFrameFences);
|
||||
}
|
||||
|
||||
void GLContext::testAbandon() {
|
||||
void SkGLContext::testAbandon() {
|
||||
if (fGL) {
|
||||
fGL->abandon();
|
||||
}
|
||||
@ -109,12 +107,12 @@ void GLContext::testAbandon() {
|
||||
}
|
||||
}
|
||||
|
||||
GLContext::GLFenceSync* GLContext::GLFenceSync::CreateIfSupported(const GLContext* ctx) {
|
||||
SkGLContext::GLFenceSync* SkGLContext::GLFenceSync::CreateIfSupported(const SkGLContext* ctx) {
|
||||
SkAutoTDelete<GLFenceSync> ret(new GLFenceSync);
|
||||
|
||||
if (kGL_GrGLStandard == ctx->gl()->fStandard) {
|
||||
const GrGLubyte* versionStr;
|
||||
GR_GL_CALL_RET(ctx->gl(), versionStr, GetString(GR_GL_VERSION));
|
||||
SK_GL_RET(*ctx, 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;
|
||||
@ -144,23 +142,23 @@ GLContext::GLFenceSync* GLContext::GLFenceSync::CreateIfSupported(const GLContex
|
||||
return ret.release();
|
||||
}
|
||||
|
||||
SkPlatformGpuFence GLContext::GLFenceSync::insertFence() const {
|
||||
SkPlatformGpuFence SkGLContext::GLFenceSync::insertFence() const {
|
||||
return fGLFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
}
|
||||
|
||||
bool GLContext::GLFenceSync::waitFence(SkPlatformGpuFence fence, bool flush) const {
|
||||
bool SkGLContext::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 GLContext::GLFenceSync::deleteFence(SkPlatformGpuFence fence) const {
|
||||
void SkGLContext::GLFenceSync::deleteFence(SkPlatformGpuFence fence) const {
|
||||
GLsync glsync = static_cast<GLsync>(fence);
|
||||
fGLDeleteSync(glsync);
|
||||
}
|
||||
|
||||
GrGLint GLContext::createTextureRectangle(int width, int height, GrGLenum internalFormat,
|
||||
GrGLenum externalFormat, GrGLenum externalType,
|
||||
GrGLvoid* data) {
|
||||
GrGLint SkGLContext::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;
|
||||
@ -178,11 +176,10 @@ GrGLint GLContext::createTextureRectangle(int width, int height, GrGLenum intern
|
||||
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
|
26
src/gpu/gl/SkNullGLContext.cpp
Normal file
26
src/gpu/gl/SkNullGLContext.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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();
|
||||
}
|
57
src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp
Normal file
57
src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
@ -6,7 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "GLContext_angle.h"
|
||||
#include "gl/angle/SkANGLEGLContext.h"
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
@ -14,57 +13,32 @@
|
||||
#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
|
||||
|
||||
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) {
|
||||
void* SkANGLEGLContext::GetD3DEGLDisplay(void* nativeDisplay, bool useGLBackend) {
|
||||
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT;
|
||||
eglGetPlatformDisplayEXT =
|
||||
(PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
|
||||
|
||||
// We expect ANGLE to support this extension
|
||||
if (!eglGetPlatformDisplayEXT) {
|
||||
return EGL_NO_DISPLAY;
|
||||
return eglGetDisplay(static_cast<EGLNativeDisplayType>(nativeDisplay));
|
||||
}
|
||||
|
||||
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.
|
||||
// Try for an ANGLE D3D11 context, fall back to D3D9, and finally GL.
|
||||
EGLint attribs[3][3] = {
|
||||
{
|
||||
EGL_PLATFORM_ANGLE_TYPE_ANGLE,
|
||||
@ -76,6 +50,11 @@ void* get_angle_egl_display(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]);
|
||||
@ -84,30 +63,7 @@ void* get_angle_egl_display(void* nativeDisplay, bool useGLBackend) {
|
||||
return display;
|
||||
}
|
||||
|
||||
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)
|
||||
SkANGLEGLContext::SkANGLEGLContext(bool useGLBackend)
|
||||
: fContext(EGL_NO_CONTEXT)
|
||||
, fDisplay(EGL_NO_DISPLAY)
|
||||
, fSurface(EGL_NO_SURFACE) {
|
||||
@ -124,7 +80,7 @@ ANGLEGLContext::ANGLEGLContext(bool useGLBackend)
|
||||
};
|
||||
|
||||
fIsGLBackend = useGLBackend;
|
||||
fDisplay = get_angle_egl_display(EGL_DEFAULT_DISPLAY, useGLBackend);
|
||||
fDisplay = GetD3DEGLDisplay(EGL_DEFAULT_DISPLAY, useGLBackend);
|
||||
if (EGL_NO_DISPLAY == fDisplay) {
|
||||
SkDebugf("Could not create EGL display!");
|
||||
return;
|
||||
@ -154,7 +110,7 @@ ANGLEGLContext::ANGLEGLContext(bool useGLBackend)
|
||||
|
||||
eglMakeCurrent(fDisplay, fSurface, fSurface, fContext);
|
||||
|
||||
SkAutoTUnref<const GrGLInterface> gl(sk_gpu_test::CreateANGLEGLInterface());
|
||||
SkAutoTUnref<const GrGLInterface> gl(GrGLCreateANGLEInterface());
|
||||
if (nullptr == gl.get()) {
|
||||
SkDebugf("Could not create ANGLE GL interface!\n");
|
||||
this->destroyGLContext();
|
||||
@ -169,12 +125,12 @@ ANGLEGLContext::ANGLEGLContext(bool useGLBackend)
|
||||
this->init(gl.release());
|
||||
}
|
||||
|
||||
ANGLEGLContext::~ANGLEGLContext() {
|
||||
SkANGLEGLContext::~SkANGLEGLContext() {
|
||||
this->teardown();
|
||||
this->destroyGLContext();
|
||||
}
|
||||
|
||||
GrEGLImage ANGLEGLContext::texture2DToEGLImage(GrGLuint texID) const {
|
||||
GrEGLImage SkANGLEGLContext::texture2DToEGLImage(GrGLuint texID) const {
|
||||
if (!this->gl()->hasExtension("EGL_KHR_gl_texture_2D_image")) {
|
||||
return GR_EGL_NO_IMAGE;
|
||||
}
|
||||
@ -190,16 +146,17 @@ GrEGLImage ANGLEGLContext::texture2DToEGLImage(GrGLuint texID) const {
|
||||
return img;
|
||||
}
|
||||
|
||||
void ANGLEGLContext::destroyEGLImage(GrEGLImage image) const {
|
||||
void SkANGLEGLContext::destroyEGLImage(GrEGLImage image) const {
|
||||
GR_GL_CALL(this->gl(), EGLDestroyImage(fDisplay, image));
|
||||
}
|
||||
|
||||
GrGLuint ANGLEGLContext::eglImageToExternalTexture(GrEGLImage image) const {
|
||||
GrGLuint SkANGLEGLContext::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) {
|
||||
@ -223,12 +180,12 @@ GrGLuint ANGLEGLContext::eglImageToExternalTexture(GrEGLImage image) const {
|
||||
return texID;
|
||||
}
|
||||
|
||||
sk_gpu_test::GLContext* ANGLEGLContext::createNew() const {
|
||||
SkGLContext* SkANGLEGLContext::createNew() const {
|
||||
#ifdef SK_BUILD_FOR_WIN
|
||||
sk_gpu_test::GLContext* ctx = fIsGLBackend ? sk_gpu_test::CreateANGLEOpenGLGLContext()
|
||||
: sk_gpu_test::CreateANGLEDirect3DGLContext();
|
||||
SkGLContext* ctx = fIsGLBackend ? SkANGLEGLContext::CreateOpenGL()
|
||||
: SkANGLEGLContext::CreateDirectX();
|
||||
#else
|
||||
sk_gpu_test::GLContext* ctx = sk_gpu_test::CreateANGLEOpenGLGLContext();
|
||||
SkGLContext* ctx = SkANGLEGLContext::CreateOpenGL();
|
||||
#endif
|
||||
if (ctx) {
|
||||
ctx->makeCurrent();
|
||||
@ -236,7 +193,7 @@ sk_gpu_test::GLContext* ANGLEGLContext::createNew() const {
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void ANGLEGLContext::destroyGLContext() {
|
||||
void SkANGLEGLContext::destroyGLContext() {
|
||||
if (fDisplay) {
|
||||
eglMakeCurrent(fDisplay, 0, 0, 0);
|
||||
|
||||
@ -255,66 +212,18 @@ void ANGLEGLContext::destroyGLContext() {
|
||||
}
|
||||
}
|
||||
|
||||
void ANGLEGLContext::onPlatformMakeCurrent() const {
|
||||
void SkANGLEGLContext::onPlatformMakeCurrent() const {
|
||||
if (!eglMakeCurrent(fDisplay, fSurface, fSurface, fContext)) {
|
||||
SkDebugf("Could not set the context.\n");
|
||||
}
|
||||
}
|
||||
|
||||
void ANGLEGLContext::onPlatformSwapBuffers() const {
|
||||
void SkANGLEGLContext::onPlatformSwapBuffers() const {
|
||||
if (!eglSwapBuffers(fDisplay, fSurface)) {
|
||||
SkDebugf("Could not complete eglSwapBuffers.\n");
|
||||
}
|
||||
}
|
||||
|
||||
GrGLFuncPtr ANGLEGLContext::onPlatformGetProcAddress(const char* name) const {
|
||||
GrGLFuncPtr SkANGLEGLContext::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
|
@ -1,15 +1,13 @@
|
||||
|
||||
/*
|
||||
* 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/GLContext_command_buffer.h"
|
||||
#include "gl/command_buffer/SkCommandBufferGLContext.h"
|
||||
#include "../ports/SkOSEnvironment.h"
|
||||
#include "../ports/SkOSLibrary.h"
|
||||
|
||||
@ -84,7 +82,6 @@ static GetProcAddressProc gfGetProcAddress = nullptr;
|
||||
static void* gLibrary = nullptr;
|
||||
static bool gfFunctionsLoadedSuccessfully = false;
|
||||
|
||||
namespace {
|
||||
static void load_command_buffer_functions() {
|
||||
if (!gLibrary) {
|
||||
#if defined _WIN32
|
||||
@ -127,24 +124,22 @@ static GrGLFuncPtr command_buffer_get_gl_proc(void* ctx, const char name[]) {
|
||||
}
|
||||
|
||||
SK_DECLARE_STATIC_ONCE(loadCommandBufferOnce);
|
||||
static void load_command_buffer_once() {
|
||||
void LoadCommandBufferOnce() {
|
||||
SkOnce(&loadCommandBufferOnce, load_command_buffer_functions);
|
||||
}
|
||||
|
||||
static const GrGLInterface* create_command_buffer_interface() {
|
||||
load_command_buffer_once();
|
||||
const GrGLInterface* GrGLCreateCommandBufferInterface() {
|
||||
LoadCommandBufferOnce();
|
||||
if (!gfFunctionsLoadedSuccessfully) {
|
||||
return nullptr;
|
||||
}
|
||||
return GrGLAssembleGLESInterface(gLibrary, command_buffer_get_gl_proc);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace sk_gpu_test {
|
||||
|
||||
CommandBufferGLContext::CommandBufferGLContext()
|
||||
: fContext(EGL_NO_CONTEXT), fDisplay(EGL_NO_DISPLAY), fSurface(EGL_NO_SURFACE) {
|
||||
SkCommandBufferGLContext::SkCommandBufferGLContext()
|
||||
: fContext(EGL_NO_CONTEXT)
|
||||
, fDisplay(EGL_NO_DISPLAY)
|
||||
, fSurface(EGL_NO_SURFACE) {
|
||||
|
||||
static const EGLint configAttribs[] = {
|
||||
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
|
||||
@ -165,18 +160,18 @@ CommandBufferGLContext::CommandBufferGLContext()
|
||||
initializeGLContext(nullptr, configAttribs, surfaceAttribs);
|
||||
}
|
||||
|
||||
CommandBufferGLContext::CommandBufferGLContext(void *nativeWindow, int msaaSampleCount) {
|
||||
static const EGLint surfaceAttribs[] = {EGL_NONE};
|
||||
SkCommandBufferGLContext::SkCommandBufferGLContext(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) {
|
||||
@ -186,9 +181,9 @@ CommandBufferGLContext::CommandBufferGLContext(void *nativeWindow, int msaaSampl
|
||||
initializeGLContext(nativeWindow, configAttribs, surfaceAttribs);
|
||||
}
|
||||
|
||||
void CommandBufferGLContext::initializeGLContext(void *nativeWindow, const int *configAttribs,
|
||||
const int *surfaceAttribs) {
|
||||
load_command_buffer_once();
|
||||
void SkCommandBufferGLContext::initializeGLContext(void* nativeWindow, const int* configAttribs,
|
||||
const int* surfaceAttribs) {
|
||||
LoadCommandBufferOnce();
|
||||
if (!gfFunctionsLoadedSuccessfully) {
|
||||
SkDebugf("Command Buffer: Could not load EGL functions.\n");
|
||||
return;
|
||||
@ -211,7 +206,7 @@ void CommandBufferGLContext::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();
|
||||
@ -221,7 +216,7 @@ void CommandBufferGLContext::initializeGLContext(void *nativeWindow, const int *
|
||||
if (nativeWindow) {
|
||||
fSurface = gfCreateWindowSurface(fDisplay,
|
||||
static_cast<EGLConfig>(fConfig),
|
||||
(EGLNativeWindowType) nativeWindow,
|
||||
(EGLNativeWindowType)nativeWindow,
|
||||
surfaceAttribs);
|
||||
} else {
|
||||
fSurface = gfCreatePbufferSurface(fDisplay,
|
||||
@ -251,7 +246,7 @@ void CommandBufferGLContext::initializeGLContext(void *nativeWindow, const int *
|
||||
return;
|
||||
}
|
||||
|
||||
SkAutoTUnref<const GrGLInterface> gl(create_command_buffer_interface());
|
||||
SkAutoTUnref<const GrGLInterface> gl(GrGLCreateCommandBufferInterface());
|
||||
if (nullptr == gl.get()) {
|
||||
SkDebugf("Command Buffer: Could not create CommandBuffer GL interface.\n");
|
||||
this->destroyGLContext();
|
||||
@ -266,12 +261,12 @@ void CommandBufferGLContext::initializeGLContext(void *nativeWindow, const int *
|
||||
this->init(gl.release());
|
||||
}
|
||||
|
||||
CommandBufferGLContext::~CommandBufferGLContext() {
|
||||
SkCommandBufferGLContext::~SkCommandBufferGLContext() {
|
||||
this->teardown();
|
||||
this->destroyGLContext();
|
||||
}
|
||||
|
||||
void CommandBufferGLContext::destroyGLContext() {
|
||||
void SkCommandBufferGLContext::destroyGLContext() {
|
||||
if (!gfFunctionsLoadedSuccessfully) {
|
||||
return;
|
||||
}
|
||||
@ -293,7 +288,7 @@ void CommandBufferGLContext::destroyGLContext() {
|
||||
}
|
||||
}
|
||||
|
||||
void CommandBufferGLContext::onPlatformMakeCurrent() const {
|
||||
void SkCommandBufferGLContext::onPlatformMakeCurrent() const {
|
||||
if (!gfFunctionsLoadedSuccessfully) {
|
||||
return;
|
||||
}
|
||||
@ -302,7 +297,7 @@ void CommandBufferGLContext::onPlatformMakeCurrent() const {
|
||||
}
|
||||
}
|
||||
|
||||
void CommandBufferGLContext::onPlatformSwapBuffers() const {
|
||||
void SkCommandBufferGLContext::onPlatformSwapBuffers() const {
|
||||
if (!gfFunctionsLoadedSuccessfully) {
|
||||
return;
|
||||
}
|
||||
@ -311,14 +306,14 @@ void CommandBufferGLContext::onPlatformSwapBuffers() const {
|
||||
}
|
||||
}
|
||||
|
||||
GrGLFuncPtr CommandBufferGLContext::onPlatformGetProcAddress(const char *name) const {
|
||||
GrGLFuncPtr SkCommandBufferGLContext::onPlatformGetProcAddress(const char* name) const {
|
||||
if (!gfFunctionsLoadedSuccessfully) {
|
||||
return nullptr;
|
||||
}
|
||||
return gfGetProcAddress(name);
|
||||
}
|
||||
|
||||
void CommandBufferGLContext::presentCommandBuffer() {
|
||||
void SkCommandBufferGLContext::presentCommandBuffer() {
|
||||
if (this->gl()) {
|
||||
this->gl()->fFunctions.fFlush();
|
||||
}
|
||||
@ -326,20 +321,18 @@ void CommandBufferGLContext::presentCommandBuffer() {
|
||||
this->onPlatformSwapBuffers();
|
||||
}
|
||||
|
||||
bool CommandBufferGLContext::makeCurrent() {
|
||||
bool SkCommandBufferGLContext::makeCurrent() {
|
||||
return gfMakeCurrent(fDisplay, fSurface, fSurface, fContext) != EGL_FALSE;
|
||||
}
|
||||
|
||||
int CommandBufferGLContext::getStencilBits() {
|
||||
int SkCommandBufferGLContext::getStencilBits() {
|
||||
EGLint result = 0;
|
||||
gfGetConfigAttrib(fDisplay, static_cast<EGLConfig>(fConfig), EGL_STENCIL_SIZE, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
int CommandBufferGLContext::getSampleCount() {
|
||||
int SkCommandBufferGLContext::getSampleCount() {
|
||||
EGLint result = 0;
|
||||
gfGetConfigAttrib(fDisplay, static_cast<EGLConfig>(fConfig), EGL_SAMPLES, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace sk_gpu_test
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
@ -10,7 +9,7 @@
|
||||
#define GrBufferObj_DEFINED
|
||||
|
||||
#include "GrFakeRefObj.h"
|
||||
#include "gl/GrGLDefines.h"
|
||||
#include "../GrGLDefines.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
class GrBufferObj : public GrFakeRefObj {
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
@ -6,7 +5,8 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "DebugGLContext.h"
|
||||
|
||||
#include "gl/GrGLInterface.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,
|
||||
// a frameBufferID of 0 is acceptable - it binds to the default
|
||||
// frame buffer
|
||||
GrFrameBufferObj *frameBuffer = FIND(frameBufferID, GrFrameBufferObj,
|
||||
kFrameBuffer_ObjTypes);
|
||||
|
||||
this->setFrameBuffer(frameBuffer);
|
||||
}
|
||||
|
||||
GrGLvoid bindRenderbuffer(GrGLenum target, GrGLuint renderBufferID) override {
|
||||
|
||||
GrAlwaysAssert(GR_GL_RENDERBUFFER == target);
|
||||
|
||||
// a renderBufferID of 0 is acceptable - it unbinds the bound render buffer
|
||||
GrRenderBufferObj *renderBuffer = FIND(renderBufferID, GrRenderBufferObj,
|
||||
kRenderBuffer_ObjTypes);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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());
|
||||
|
||||
GrAlwaysAssert(!buffer->getDeleted());
|
||||
buffer->deleteAction();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GrGLvoid deleteFramebuffers(GrGLsizei n, const GrGLuint *frameBuffers) override {
|
||||
|
||||
// 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);
|
||||
|
||||
this->setFrameBuffer(frameBuffer);
|
||||
}
|
||||
GrAlwaysAssert(!buffer->getDeleted());
|
||||
buffer->deleteAction();
|
||||
}
|
||||
}
|
||||
|
||||
GrGLvoid bindRenderbuffer(GrGLenum target, GrGLuint renderBufferID) override {
|
||||
GrGLvoid deleteRenderbuffers(GrGLsizei n,const GrGLuint *renderBuffers) override {
|
||||
|
||||
GrAlwaysAssert(GR_GL_RENDERBUFFER == target);
|
||||
// first potentially unbind the buffers
|
||||
if (this->getRenderBuffer()) {
|
||||
for (int i = 0; i < n; ++i) {
|
||||
|
||||
// a renderBufferID of 0 is acceptable - it unbinds the bound render buffer
|
||||
GrRenderBufferObj *renderBuffer = FIND(renderBufferID, GrRenderBufferObj,
|
||||
kRenderBuffer_ObjTypes);
|
||||
if (renderBuffers[i] ==
|
||||
this->getRenderBuffer()->getID()) {
|
||||
// this ID is the current render buffer - make no
|
||||
// render buffer be bound
|
||||
this->setRenderBuffer(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->setRenderBuffer(renderBuffer);
|
||||
}
|
||||
// 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()) {
|
||||
|
||||
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);
|
||||
GrFrameBufferObj *frameBuffer = this->getFrameBuffer();
|
||||
|
||||
if (pTU->getTexture()) {
|
||||
for (int j = 0; j < n; ++j) {
|
||||
for (int i = 0; i < n; ++i) {
|
||||
|
||||
if (textures[j] == pTU->getTexture()->getID()) {
|
||||
// this ID is the current texture - revert the binding to 0
|
||||
pTU->setTexture(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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()) {
|
||||
// then actually "delete" the buffers
|
||||
for (int i = 0; i < n; ++i) {
|
||||
GrRenderBufferObj *buffer = FIND(renderBuffers[i], GrRenderBufferObj,
|
||||
kRenderBuffer_ObjTypes);
|
||||
GrAlwaysAssert(buffer);
|
||||
|
||||
GrFrameBufferObj *frameBuffer = this->getFrameBuffer();
|
||||
// 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());
|
||||
|
||||
for (int i = 0; i < n; ++i) {
|
||||
GrAlwaysAssert(!buffer->getDeleted());
|
||||
buffer->deleteAction();
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
GrGLvoid framebufferRenderbuffer(GrGLenum target,
|
||||
GrGLenum attachment,
|
||||
GrGLenum renderbuffertarget,
|
||||
GrGLuint renderBufferID) override {
|
||||
|
||||
// then actually "delete" the buffers
|
||||
for (int i = 0; i < n; ++i) {
|
||||
GrTextureObj *buffer = FIND(textures[i], GrTextureObj, kTexture_ObjTypes);
|
||||
GrAlwaysAssert(buffer);
|
||||
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);
|
||||
|
||||
// OpenGL gives no guarantees if a texture is deleted while attached to
|
||||
// something other than the currently bound frame buffer
|
||||
GrAlwaysAssert(!buffer->getBound());
|
||||
GrFrameBufferObj *framebuffer = this->getFrameBuffer();
|
||||
// A render buffer cannot be attached to the default framebuffer
|
||||
GrAlwaysAssert(framebuffer);
|
||||
|
||||
GrAlwaysAssert(!buffer->getDeleted());
|
||||
buffer->deleteAction();
|
||||
}
|
||||
// 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 deleteFramebuffers(GrGLsizei n, const GrGLuint *frameBuffers) override {
|
||||
}
|
||||
|
||||
// first potentially unbind the buffers
|
||||
if (this->getFrameBuffer()) {
|
||||
for (int i = 0; i < n; ++i) {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
GrGLvoid framebufferTexture2D(GrGLenum target, GrGLenum attachment, GrGLenum textarget,
|
||||
GrGLuint textureID, GrGLint level) override {
|
||||
|
||||
if (frameBuffers[i] ==
|
||||
this->getFrameBuffer()->getID()) {
|
||||
// this ID is the current frame buffer - rebind to the default
|
||||
this->setFrameBuffer(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
||||
// then actually "delete" the buffers
|
||||
for (int i = 0; i < n; ++i) {
|
||||
GrFrameBufferObj *buffer = FIND(frameBuffers[i], GrFrameBufferObj,
|
||||
kFrameBuffer_ObjTypes);
|
||||
GrAlwaysAssert(buffer);
|
||||
GrFrameBufferObj *framebuffer = this->getFrameBuffer();
|
||||
// A texture cannot be attached to the default framebuffer
|
||||
GrAlwaysAssert(framebuffer);
|
||||
|
||||
GrAlwaysAssert(!buffer->getDeleted());
|
||||
buffer->deleteAction();
|
||||
}
|
||||
}
|
||||
// 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());
|
||||
}
|
||||
|
||||
GrGLvoid deleteRenderbuffers(GrGLsizei n,const GrGLuint *renderBuffers) override {
|
||||
GrAlwaysAssert(0 == level);
|
||||
|
||||
// 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;
|
||||
};
|
||||
}
|
||||
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,28 +1229,8 @@ const char* DebugInterface::kExtensions[] = {
|
||||
nullptr, // signifies the end of the array.
|
||||
};
|
||||
|
||||
class DebugGLContext : public sk_gpu_test::GLContext {
|
||||
public:
|
||||
DebugGLContext() {
|
||||
this->init(new DebugInterface());
|
||||
}
|
||||
|
||||
~DebugGLContext() 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* CreateDebugGLContext() {
|
||||
GLContext* ctx = new DebugGLContext();
|
||||
if (ctx->isValid()) {
|
||||
return ctx;
|
||||
}
|
||||
delete ctx;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const GrGLInterface* GrGLCreateDebugInterface() { return new DebugInterface; }
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
@ -10,7 +9,7 @@
|
||||
#define GrShaderObj_DEFINED
|
||||
|
||||
#include "GrFakeRefObj.h"
|
||||
#include "gl/GrGLDefines.h"
|
||||
#include "../GrGLDefines.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
class GrShaderObj : public GrFakeRefObj {
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
16
src/gpu/gl/debug/SkDebugGLContext.cpp
Normal file
16
src/gpu/gl/debug/SkDebugGLContext.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* 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();
|
||||
}
|
27
src/gpu/gl/debug/SkDebugGLContext.h
Normal file
27
src/gpu/gl/debug/SkDebugGLContext.h
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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
|
@ -1,11 +1,10 @@
|
||||
|
||||
/*
|
||||
* 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/GLContext.h"
|
||||
#include "gl/SkGLContext.h"
|
||||
|
||||
#include <GLES2/gl2.h>
|
||||
|
||||
@ -35,7 +34,7 @@ private:
|
||||
typedef SkGpuFenceSync INHERITED;
|
||||
};
|
||||
|
||||
class EGLGLContext : public sk_gpu_test::GLContext {
|
||||
class EGLGLContext : public SkGLContext {
|
||||
public:
|
||||
EGLGLContext(GrGLStandard forcedGpuAPI);
|
||||
~EGLGLContext() override;
|
||||
@ -43,7 +42,7 @@ public:
|
||||
GrEGLImage texture2DToEGLImage(GrGLuint texID) const override;
|
||||
void destroyEGLImage(GrEGLImage) const override;
|
||||
GrGLuint eglImageToExternalTexture(GrEGLImage) const override;
|
||||
sk_gpu_test::GLContext* createNew() const override;
|
||||
SkGLContext* createNew() const override;
|
||||
|
||||
private:
|
||||
void destroyGLContext();
|
||||
@ -254,8 +253,8 @@ GrGLuint EGLGLContext::eglImageToExternalTexture(GrEGLImage image) const {
|
||||
return texID;
|
||||
}
|
||||
|
||||
sk_gpu_test::GLContext* EGLGLContext::createNew() const {
|
||||
sk_gpu_test::GLContext* ctx = new EGLGLContext(this->gl()->fStandard);
|
||||
SkGLContext* EGLGLContext::createNew() const {
|
||||
SkGLContext* ctx = SkCreatePlatformGLContext(this->gl()->fStandard);
|
||||
if (ctx) {
|
||||
ctx->makeCurrent();
|
||||
}
|
||||
@ -318,20 +317,17 @@ void SkEGLFenceSync::deleteFence(SkPlatformGpuFence platformFence) const {
|
||||
eglDestroySyncKHR(fDisplay, eglsync);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // anonymous namespace
|
||||
|
||||
namespace sk_gpu_test {
|
||||
GLContext *CreatePlatformGLContext(GrGLStandard forcedGpuAPI, GLContext *shareContext) {
|
||||
SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* 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
|
||||
|
@ -1,11 +1,10 @@
|
||||
|
||||
/*
|
||||
* 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/GLContext.h"
|
||||
#include "gl/SkGLContext.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <GL/glx.h>
|
||||
@ -44,7 +43,7 @@ static int ctxErrorHandler(Display *dpy, XErrorEvent *ev) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
class GLXGLContext : public sk_gpu_test::GLContext {
|
||||
class GLXGLContext : public SkGLContext {
|
||||
public:
|
||||
GLXGLContext(GrGLStandard forcedGpuAPI, GLXGLContext* shareList);
|
||||
~GLXGLContext() override;
|
||||
@ -331,11 +330,10 @@ GrGLFuncPtr GLXGLContext::onPlatformGetProcAddress(const char* procName) const {
|
||||
return glXGetProcAddress(reinterpret_cast<const GLubyte*>(procName));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // anonymous namespace
|
||||
|
||||
namespace sk_gpu_test {
|
||||
GLContext *CreatePlatformGLContext(GrGLStandard forcedGpuAPI, GLContext *shareContext) {
|
||||
GLXGLContext *glxShareContext = reinterpret_cast<GLXGLContext *>(shareContext);
|
||||
SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* shareContext) {
|
||||
GLXGLContext* glxShareContext = reinterpret_cast<GLXGLContext*>(shareContext);
|
||||
GLXGLContext *ctx = new GLXGLContext(forcedGpuAPI, glxShareContext);
|
||||
if (!ctx->isValid()) {
|
||||
delete ctx;
|
||||
@ -343,4 +341,3 @@ GLContext *CreatePlatformGLContext(GrGLStandard forcedGpuAPI, GLContext *shareCo
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
} // namespace sk_gpu_test
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "GLContext.h"
|
||||
#include "gl/SkGLContext.h"
|
||||
#import <OpenGLES/EAGL.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
class IOSGLContext : public sk_gpu_test::GLContext {
|
||||
class IOSGLContext : public SkGLContext {
|
||||
public:
|
||||
IOSGLContext();
|
||||
~IOSGLContext() override;
|
||||
@ -87,10 +87,9 @@ GrGLFuncPtr IOSGLContext::onPlatformGetProcAddress(const char* procName) const {
|
||||
return reinterpret_cast<GrGLFuncPtr>(dlsym(fGLLibrary, procName));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // anonymous namespace
|
||||
|
||||
namespace sk_gpu_test {
|
||||
GLContext *CreatePlatformGLContext(GrGLStandard forcedGpuAPI, GLContext *shareContext) {
|
||||
SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* shareContext) {
|
||||
SkASSERT(!shareContext);
|
||||
if (shareContext) {
|
||||
return NULL;
|
||||
@ -98,11 +97,10 @@ GLContext *CreatePlatformGLContext(GrGLStandard forcedGpuAPI, GLContext *shareCo
|
||||
if (kGL_GrGLStandard == forcedGpuAPI) {
|
||||
return NULL;
|
||||
}
|
||||
IOSGLContext *ctx = new IOSGLContext;
|
||||
IOSGLContext* ctx = new IOSGLContext;
|
||||
if (!ctx->isValid()) {
|
||||
delete ctx;
|
||||
return NULL;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
@ -6,15 +5,16 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "SkTypes.h"
|
||||
#if defined(SK_BUILD_FOR_MAC)
|
||||
|
||||
#include "gl/GLContext.h"
|
||||
#include "gl/SkGLContext.h"
|
||||
#include "AvailabilityMacros.h"
|
||||
|
||||
#include <OpenGL/OpenGL.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
namespace {
|
||||
class MacGLContext : public sk_gpu_test::GLContext {
|
||||
class MacGLContext : public SkGLContext {
|
||||
public:
|
||||
MacGLContext();
|
||||
~MacGLContext() override;
|
||||
@ -106,10 +106,9 @@ GrGLFuncPtr MacGLContext::onPlatformGetProcAddress(const char* procName) const {
|
||||
return reinterpret_cast<GrGLFuncPtr>(dlsym(fGLLibrary, procName));
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // anonymous namespace
|
||||
|
||||
namespace sk_gpu_test {
|
||||
GLContext* CreatePlatformGLContext(GrGLStandard forcedGpuAPI, GLContext* shareContext) {
|
||||
SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* shareContext) {
|
||||
SkASSERT(!shareContext);
|
||||
if (shareContext) {
|
||||
return nullptr;
|
||||
@ -125,4 +124,5 @@ GLContext* CreatePlatformGLContext(GrGLStandard forcedGpuAPI, GLContext* shareCo
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
} // namespace sk_gpu_test
|
||||
|
||||
#endif//defined(SK_BUILD_FOR_MAC)
|
24
src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp
Normal file
24
src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
@ -8,52 +7,14 @@
|
||||
|
||||
#include <GL/osmesa.h>
|
||||
|
||||
#include "gl/mesa/GLContext_mesa.h"
|
||||
#include "gl/mesa/SkMesaGLContext.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;
|
||||
|
||||
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) {
|
||||
SkMesaGLContext::SkMesaGLContext()
|
||||
: fContext(static_cast<Context>(0))
|
||||
, fImage(nullptr) {
|
||||
GR_STATIC_ASSERT(sizeof(Context) == sizeof(OSMesaContext));
|
||||
|
||||
/* Create an RGBA-mode context */
|
||||
@ -61,7 +22,7 @@ MesaGLContext::MesaGLContext() : fContext(static_cast<Context>(0)), fImage(nullp
|
||||
/* 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");
|
||||
@ -78,7 +39,7 @@ MesaGLContext::MesaGLContext() : fContext(static_cast<Context>(0)), fImage(nullp
|
||||
}
|
||||
|
||||
// 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,
|
||||
@ -88,7 +49,7 @@ MesaGLContext::MesaGLContext() : fContext(static_cast<Context>(0)), fImage(nullp
|
||||
return;
|
||||
}
|
||||
|
||||
SkAutoTUnref<const GrGLInterface> gl(create_mesa_interface());
|
||||
SkAutoTUnref<const GrGLInterface> gl(GrGLCreateMesaInterface());
|
||||
if (nullptr == gl.get()) {
|
||||
SkDebugf("Could not create GL interface!\n");
|
||||
this->destroyGLContext();
|
||||
@ -104,48 +65,36 @@ MesaGLContext::MesaGLContext() : fContext(static_cast<Context>(0)), fImage(nullp
|
||||
this->init(gl.release());
|
||||
}
|
||||
|
||||
MesaGLContext::~MesaGLContext() {
|
||||
SkMesaGLContext::~SkMesaGLContext() {
|
||||
this->teardown();
|
||||
this->destroyGLContext();
|
||||
}
|
||||
|
||||
void MesaGLContext::destroyGLContext() {
|
||||
void SkMesaGLContext::destroyGLContext() {
|
||||
if (fImage) {
|
||||
sk_free(fImage);
|
||||
fImage = nullptr;
|
||||
}
|
||||
|
||||
if (fContext) {
|
||||
OSMesaDestroyContext((OSMesaContext) fContext);
|
||||
OSMesaDestroyContext((OSMesaContext)fContext);
|
||||
fContext = static_cast<Context>(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MesaGLContext::onPlatformMakeCurrent() const {
|
||||
|
||||
void SkMesaGLContext::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 MesaGLContext::onPlatformSwapBuffers() const { }
|
||||
void SkMesaGLContext::onPlatformSwapBuffers() const { }
|
||||
|
||||
GrGLFuncPtr MesaGLContext::onPlatformGetProcAddress(const char *procName) const {
|
||||
GrGLFuncPtr SkMesaGLContext::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
|
44
src/gpu/gl/mesa/SkMesaGLContext.h
Normal file
44
src/gpu/gl/mesa/SkMesaGLContext.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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
|
12
src/gpu/gl/nacl/SkCreatePlatformGLContext_nacl.cpp
Normal file
12
src/gpu/gl/nacl/SkCreatePlatformGLContext_nacl.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2011 Google Inc.
|
||||
*
|
||||
@ -6,7 +5,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "gl/GLContext.h"
|
||||
#include "gl/SkGLContext.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <GL/GL.h>
|
||||
@ -17,7 +16,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
class WinGLContext : public sk_gpu_test::GLContext {
|
||||
class WinGLContext : public SkGLContext {
|
||||
public:
|
||||
WinGLContext(GrGLStandard forcedGpuAPI);
|
||||
~WinGLContext() override;
|
||||
@ -187,18 +186,15 @@ GrGLFuncPtr WinGLContext::onPlatformGetProcAddress(const char* name) const {
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace sk_gpu_test {
|
||||
GLContext* CreatePlatformGLContext(GrGLStandard forcedGpuAPI, GLContext *shareContext) {
|
||||
SkGLContext* SkCreatePlatformGLContext(GrGLStandard forcedGpuAPI, SkGLContext* 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
|
||||
|
@ -395,36 +395,6 @@ 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,
|
||||
@ -448,7 +418,7 @@ bool create_ANGLE(EGLNativeWindowType hWnd,
|
||||
EGL_NONE, EGL_NONE
|
||||
};
|
||||
|
||||
EGLDisplay display = get_angle_egl_display(GetDC(hWnd), false);
|
||||
EGLDisplay display = SkANGLEGLContext::GetD3DEGLDisplay(GetDC(hWnd), false);
|
||||
|
||||
if (EGL_NO_DISPLAY == display) {
|
||||
SkDebugf("Could not create ANGLE egl display!\n");
|
||||
|
@ -11,11 +11,9 @@
|
||||
#include "GrContextFactory.h"
|
||||
#include "gl/GrGLGpu.h"
|
||||
#include "gl/GrGLUtil.h"
|
||||
#include "gl/GLContext.h"
|
||||
#include "gl/SkGLContext.h"
|
||||
|
||||
using sk_gpu_test::GLContext;
|
||||
|
||||
static void cleanup(GLContext* glctx0, GrGLuint texID0, GLContext* glctx1, GrContext* grctx1,
|
||||
static void cleanup(SkGLContext* glctx0, GrGLuint texID0, SkGLContext* glctx1, GrContext* grctx1,
|
||||
const GrGLTextureInfo* grbackendtex1, GrEGLImage image1) {
|
||||
if (glctx1) {
|
||||
glctx1->makeCurrent();
|
||||
@ -93,7 +91,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(EGLImageTest, reporter, context0, glCtx0) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkAutoTDelete<GLContext> glCtx1 = glCtx0->createNew();
|
||||
SkAutoTDelete<SkGLContext> glCtx1 = glCtx0->createNew();
|
||||
if (!glCtx1) {
|
||||
return;
|
||||
}
|
||||
|
@ -455,7 +455,7 @@ DEF_GPUTEST(GLPrograms, reporter, /*factory*/) {
|
||||
// We suppress prints to avoid spew
|
||||
GrContextOptions opts;
|
||||
opts.fSuppressPrints = true;
|
||||
sk_gpu_test::GrContextFactory debugFactory(opts);
|
||||
GrContextFactory debugFactory(opts);
|
||||
skiatest::RunWithGPUTestContexts(test_glprograms_native, skiatest::kNative_GPUTestContexts,
|
||||
reporter, &debugFactory);
|
||||
skiatest::RunWithGPUTestContexts(test_glprograms_other_contexts,
|
||||
|
@ -13,8 +13,6 @@
|
||||
#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.
|
||||
|
@ -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;
|
||||
sk_gpu_test::GrContextFactory mockFactory(opts);
|
||||
GrContext* ctx = mockFactory.get(sk_gpu_test::GrContextFactory::kNull_GLContextType);
|
||||
GrContextFactory mockFactory(opts);
|
||||
GrContext* ctx = mockFactory.get(GrContextFactory::kNull_GLContextType);
|
||||
if (!ctx) {
|
||||
SkFAIL("Failed to create null context without ARB_blend_func_extended.");
|
||||
return;
|
||||
|
@ -26,8 +26,6 @@
|
||||
#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();
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "GrDrawContext.h"
|
||||
#include "gl/GrGLGpu.h"
|
||||
#include "gl/GrGLUtil.h"
|
||||
#include "gl/GLContext.h"
|
||||
#include "gl/SkGLContext.h"
|
||||
|
||||
static void test_read_pixels(skiatest::Reporter* reporter, GrContext* context,
|
||||
GrTexture* rectangleTexture, uint32_t expectedPixelValues[]) {
|
||||
|
32
tests/Test.h
32
tests/Test.h
@ -11,11 +11,9 @@
|
||||
#include "SkTRegistry.h"
|
||||
#include "SkTypes.h"
|
||||
|
||||
namespace sk_gpu_test {
|
||||
class GrContextFactory;
|
||||
class GLContext;
|
||||
} // namespace sk_gpu_test
|
||||
class GrContext;
|
||||
class SkGLContext;
|
||||
|
||||
namespace skiatest {
|
||||
|
||||
@ -43,7 +41,7 @@ public:
|
||||
#define REPORT_FAILURE(reporter, cond, message) \
|
||||
reporter->reportFailed(skiatest::Failure(__FILE__, __LINE__, cond, message))
|
||||
|
||||
typedef void (*TestProc)(skiatest::Reporter*, sk_gpu_test::GrContextFactory*);
|
||||
typedef void (*TestProc)(skiatest::Reporter*, GrContextFactory*);
|
||||
|
||||
struct Test {
|
||||
Test(const char* n, bool g, TestProc p) : name(n), needsGpu(g), proc(p) {}
|
||||
@ -85,7 +83,7 @@ enum GPUTestContexts {
|
||||
};
|
||||
template<typename T>
|
||||
void RunWithGPUTestContexts(T testFunction, GPUTestContexts contexts, Reporter* reporter,
|
||||
sk_gpu_test::GrContextFactory* factory);
|
||||
GrContextFactory* factory);
|
||||
|
||||
/** Timer provides wall-clock duration since its creation. */
|
||||
class Timer {
|
||||
@ -135,32 +133,32 @@ private:
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#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 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 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, sk_gpu_test::GLContext* a2
|
||||
#define GPUTEST_CONTEXT_ARGS2(a1, a2) GrContext* a1, SkGLContext* 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*, 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(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_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, \
|
||||
sk_gpu_test::GrContextFactory* factory) { \
|
||||
GrContextFactory* factory) { \
|
||||
skiatest::RunWithGPUTestContexts(test_##name, contexts, reporter, factory); \
|
||||
} \
|
||||
skiatest::TestRegistry name##TestRegistry( \
|
||||
|
@ -9,8 +9,6 @@
|
||||
#include "Test.h"
|
||||
#include <initializer_list>
|
||||
|
||||
using sk_gpu_test::GrContextFactory;
|
||||
|
||||
namespace {
|
||||
// The code
|
||||
// SkCommandLineFlags::StringArray FLAGS_config1 = make_string_array({"a", "b"})
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GrContext.h"
|
||||
#include "gl/GLContext.h"
|
||||
#include "gl/SkGLContext.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 GLContext* glContext to implement the test.
|
||||
// It uses the additional SkGLContext* glContext to implement the test.
|
||||
#if SK_SUPPORT_GPU
|
||||
DEF_GPUTEST_FOR_ALL_CONTEXTS(TestGpuGrContextAndGLContext, reporter, context, glContext) {
|
||||
REPORTER_ASSERT(reporter, reporter);
|
||||
|
@ -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"
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
||||
#endif
|
||||
|
||||
using namespace skiatest;
|
||||
using namespace sk_gpu_test;
|
||||
|
||||
DEFINE_bool2(extendedTest, x, false, "run extended tests for pathOps.");
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "SkSurface.h"
|
||||
#include "VisualFlags.h"
|
||||
#include "VisualModule.h"
|
||||
#include "gl/GLContext.h"
|
||||
#include "gl/SkGLContext.h"
|
||||
|
||||
class GrContext;
|
||||
struct GrGLInterface;
|
||||
|
@ -9,10 +9,6 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
using sk_gpu_test::GrContextFactory;
|
||||
#endif
|
||||
|
||||
static const char defaultConfigs[] =
|
||||
"565 8888 gpu nonrendering"
|
||||
#if SK_ANGLE
|
||||
|
@ -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 sk_gpu_test::GrContextFactory::GLContextType ContextType;
|
||||
typedef GrContextFactory::GLContextType ContextType;
|
||||
SkCommandLineConfigGpu(const SkString& tag, const SkTArray<SkString>& viaParts,
|
||||
ContextType contextType, bool useNVPR, bool useDIText, int samples,
|
||||
SkColorType colorType, SkColorProfileType profileType);
|
||||
|
@ -1,30 +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 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
|
@ -1,68 +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 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
|
@ -1,17 +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 DebugGLContext_DEFINED
|
||||
#define DebugGLContext_DEFINED
|
||||
|
||||
#include "gl/GLContext.h"
|
||||
|
||||
namespace sk_gpu_test {
|
||||
GLContext* CreateDebugGLContext();
|
||||
} // namespace sk_gpu_test
|
||||
|
||||
#endif
|
@ -1,17 +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 GLContext_mesa_DEFINED
|
||||
#define GLContext_mesa_DEFINED
|
||||
|
||||
#include "gl/GLContext.h"
|
||||
|
||||
namespace sk_gpu_test {
|
||||
GLContext* CreateMesaGLContext();
|
||||
} // namespace sk_gpu_test
|
||||
|
||||
#endif
|
@ -1,16 +0,0 @@
|
||||
|
||||
/*
|
||||
* 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>
|
@ -1,630 +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 "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
|
||||
|
@ -1,17 +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 NullGLContext_DEFINED
|
||||
#define NullGLContext_DEFINED
|
||||
|
||||
#include "gl/GLContext.h"
|
||||
|
||||
namespace sk_gpu_test {
|
||||
GLContext* CreateNullGLContext();
|
||||
} // namespace sk_gpu_test
|
||||
|
||||
#endif
|
@ -20,7 +20,6 @@
|
||||
#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"
|
||||
@ -30,8 +29,6 @@
|
||||
#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.
|
||||
@ -147,14 +144,14 @@ struct GPUTarget {
|
||||
void setup() {
|
||||
fGL->makeCurrent();
|
||||
// Make sure we're done with whatever came before.
|
||||
GR_GL_CALL(fGL->gl(), Finish());
|
||||
SK_GL(*fGL, Finish());
|
||||
}
|
||||
|
||||
SkCanvas* beginTiming(SkCanvas* canvas) { return canvas; }
|
||||
|
||||
void endTiming(bool usePlatformSwapBuffers) {
|
||||
if (fGL) {
|
||||
GR_GL_CALL(fGL->gl(), Flush());
|
||||
SK_GL(*fGL, Flush());
|
||||
if (usePlatformSwapBuffers) {
|
||||
fGL->swapBuffers();
|
||||
} else {
|
||||
@ -163,7 +160,7 @@ struct GPUTarget {
|
||||
}
|
||||
}
|
||||
void finish() {
|
||||
GR_GL_CALL(fGL->gl(), Finish());
|
||||
SK_GL(*fGL, Finish());
|
||||
}
|
||||
|
||||
bool needsFrameTiming(int* maxFrameLag) const {
|
||||
@ -218,10 +215,10 @@ struct GPUTarget {
|
||||
return true;
|
||||
}
|
||||
|
||||
GLContext* gl() { return fGL; }
|
||||
SkGLContext* gl() { return fGL; }
|
||||
|
||||
private:
|
||||
GLContext* fGL;
|
||||
SkGLContext* fGL;
|
||||
SkAutoTDelete<SkSurface> fSurface;
|
||||
};
|
||||
|
||||
@ -282,7 +279,7 @@ static int clamp_loops(int loops) {
|
||||
static double now_ms() { return SkTime::GetNSecs() * 1e-6; }
|
||||
|
||||
struct TimingThread {
|
||||
TimingThread(GLContext* mainContext)
|
||||
TimingThread(SkGLContext* mainContext)
|
||||
: fFenceSync(mainContext->fenceSync())
|
||||
, fMainContext(mainContext)
|
||||
, fDone(false) {}
|
||||
@ -308,8 +305,8 @@ struct TimingThread {
|
||||
|
||||
void timingLoop() {
|
||||
// Create a context which shares display lists with the main thread
|
||||
SkAutoTDelete<GLContext> glContext(CreatePlatformGLContext(kNone_GrGLStandard,
|
||||
fMainContext));
|
||||
SkAutoTDelete<SkGLContext> glContext(SkCreatePlatformGLContext(kNone_GrGLStandard,
|
||||
fMainContext));
|
||||
glContext->makeCurrent();
|
||||
|
||||
// Basic timing methodology is:
|
||||
@ -405,7 +402,7 @@ private:
|
||||
SyncQueue fFrameEndSyncs;
|
||||
SkTArray<double> fTimings;
|
||||
SkMutex fDoneMutex;
|
||||
GLContext* fMainContext;
|
||||
SkGLContext* fMainContext;
|
||||
bool fDone;
|
||||
};
|
||||
|
||||
|
@ -10,8 +10,6 @@
|
||||
#include "SkPictureRecorder.h"
|
||||
#include "SkPixelSerializer.h"
|
||||
|
||||
using namespace sk_gpu_test;
|
||||
|
||||
static int kDefaultWidth = 1920;
|
||||
static int kDefaultHeight = 1080;
|
||||
|
||||
@ -65,8 +63,8 @@ SkData* Request::writeCanvasToPng(SkCanvas* canvas) {
|
||||
SkCanvas* Request::getCanvas() {
|
||||
#if SK_SUPPORT_GPU
|
||||
GrContextFactory* factory = fContextFactory;
|
||||
GLContext* gl = factory->getContextInfo(GrContextFactory::kNative_GLContextType,
|
||||
GrContextFactory::kNone_GLContextOptions).fGLContext;
|
||||
SkGLContext* gl = factory->getContextInfo(GrContextFactory::kNative_GLContextType,
|
||||
GrContextFactory::kNone_GLContextOptions).fGLContext;
|
||||
gl->makeCurrent();
|
||||
#endif
|
||||
SkASSERT(fDebugCanvas);
|
||||
|
@ -19,9 +19,7 @@
|
||||
|
||||
#include "UrlDataManager.h"
|
||||
|
||||
namespace sk_gpu_test {
|
||||
class GrContextFactory;
|
||||
}
|
||||
struct MHD_Connection;
|
||||
struct MHD_PostProcessor;
|
||||
|
||||
@ -71,7 +69,7 @@ private:
|
||||
GrContext* getContext();
|
||||
|
||||
sk_sp<SkPicture> fPicture;
|
||||
sk_gpu_test::GrContextFactory* fContextFactory;
|
||||
GrContextFactory* fContextFactory;
|
||||
SkAutoTUnref<SkSurface> fSurface;
|
||||
bool fGPUEnabled;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user