diff options
author | Greg Daniel <egdaniel@google.com> | 2017-07-12 16:21:09 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-07-12 20:49:32 +0000 |
commit | 6b7e0e2c744f3c5aba3755e5c69c49669f791e9e (patch) | |
tree | 49d54cf59e1a4a945fd5abd6abed7219e69464f0 | |
parent | 7cbf5e3e03754694157891e290ff30109b8e7583 (diff) |
Add arc support to gpu Obj c++ code
This is mainly for getting ready to start adding lots of metal backend code.
I've also update the "gpu tools" target to require ARC with involved updating
one IOS file in there.
Bug: skia:
Change-Id: Ied22e8fe7532445cc274efb529e3450654a6614b
Reviewed-on: https://skia-review.googlesource.com/22484
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
-rw-r--r-- | BUILD.gn | 4 | ||||
-rw-r--r-- | gn/BUILD.gn | 5 | ||||
-rw-r--r-- | gn/toolchain/BUILD.gn | 2 | ||||
-rw-r--r-- | src/gpu/mtl/GrMtlGpu.mm | 4 | ||||
-rw-r--r-- | tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm | 13 |
5 files changed, 20 insertions, 8 deletions
@@ -531,10 +531,12 @@ optional("gpu") { public_defines += [ "SK_ENABLE_SPIRV_VALIDATION" ] } + cflags_objcc = [] if (skia_use_metal) { public_defines += [ "SK_METAL" ] sources += skia_metal_sources libs += [ "Metal.framework" ] + cflags_objcc += [ "-fobjc-arc" ] } } @@ -973,6 +975,8 @@ if (skia_enable_tools) { ] } + cflags_objcc = [ "-fobjc-arc" ] + if (skia_use_angle) { deps += [ "//third_party/angle2" ] sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ] diff --git a/gn/BUILD.gn b/gn/BUILD.gn index d275bd6685..71475a8110 100644 --- a/gn/BUILD.gn +++ b/gn/BUILD.gn @@ -263,6 +263,7 @@ config("warnings") { cflags = [] cflags_cc = [] cflags_objc = [] + cflags_objcc = [] if (is_win) { cflags += [ "/W3", # Turn on lots of warnings. @@ -356,6 +357,10 @@ config("warnings") { "-Wno-direct-ivar-access", "-Wno-objc-interface-ivars", ] + cflags_objcc += [ + "-Wno-direct-ivar-access", + "-Wno-objcc-interface-ivars", + ] } } } diff --git a/gn/toolchain/BUILD.gn b/gn/toolchain/BUILD.gn index a4c13a7d69..55778effe8 100644 --- a/gn/toolchain/BUILD.gn +++ b/gn/toolchain/BUILD.gn @@ -210,7 +210,7 @@ template("gcc_like_toolchain") { tool("objcxx") { depfile = "{{output}}.d" - command = "$cc_wrapper $cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} {{cflags_objc}} -c {{source}} -o {{output}}" + command = "$cc_wrapper $cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} {{cflags_objcc}} -c {{source}} -o {{output}}" depsformat = "gcc" outputs = [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", diff --git a/src/gpu/mtl/GrMtlGpu.mm b/src/gpu/mtl/GrMtlGpu.mm index c19dcdf098..7d9339cf29 100644 --- a/src/gpu/mtl/GrMtlGpu.mm +++ b/src/gpu/mtl/GrMtlGpu.mm @@ -7,6 +7,10 @@ #include "GrMtlGpu.h" +#if !__has_feature(objc_arc) +#error This file must be compiled with Arc. Use -fobjc-arc flag +#endif + GrGpu* GrMtlGpu::Create(GrBackendContext backendContext, const GrContextOptions& options, GrContext* context) { return nullptr; diff --git a/tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm b/tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm index 954e88e538..1fd50d1e1a 100644 --- a/tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm +++ b/tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm @@ -26,7 +26,7 @@ private: void onPlatformSwapBuffers() const override; GrGLFuncPtr onPlatformGetProcAddress(const char*) const override; - void* fEAGLContext; + EAGLContext* fEAGLContext; void* fGLLibrary; }; @@ -35,13 +35,13 @@ IOSGLTestContext::IOSGLTestContext(IOSGLTestContext* shareContext) , fGLLibrary(RTLD_DEFAULT) { if (shareContext) { - EAGLContext* iosShareContext = (EAGLContext*)(shareContext->fEAGLContext); + EAGLContext* iosShareContext = shareContext->fEAGLContext; fEAGLContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 sharegroup: [iosShareContext sharegroup]]; } else { fEAGLContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; } - [EAGLContext setCurrentContext:EAGLCTX]; + [EAGLContext setCurrentContext:fEAGLContext]; sk_sp<const GrGLInterface> gl(GrGLCreateNativeInterface()); if (NULL == gl.get()) { @@ -69,11 +69,10 @@ IOSGLTestContext::~IOSGLTestContext() { void IOSGLTestContext::destroyGLContext() { if (fEAGLContext) { - if ([EAGLContext currentContext] == EAGLCTX) { + if ([EAGLContext currentContext] == fEAGLContext) { [EAGLContext setCurrentContext:nil]; } - [EAGLCTX release]; - fEAGLContext = NULL; + fEAGLContext = nil; } if (RTLD_DEFAULT != fGLLibrary) { dlclose(fGLLibrary); @@ -82,7 +81,7 @@ void IOSGLTestContext::destroyGLContext() { void IOSGLTestContext::onPlatformMakeCurrent() const { - if (![EAGLContext setCurrentContext:EAGLCTX]) { + if (![EAGLContext setCurrentContext:fEAGLContext]) { SkDebugf("Could not set the context.\n"); } } |