1 //
2 // Copyright 2019 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // ContextCGL:
7 // Mac-specific subclass of ContextGL.
8 //
9
10 #include "libANGLE/renderer/gl/cgl/ContextCGL.h"
11
12 #include "libANGLE/Context.h"
13 #include "libANGLE/Display.h"
14 #include "libANGLE/renderer/gl/cgl/DisplayCGL.h"
15
16 namespace rx
17 {
18
ContextCGL(const gl::State & state,gl::ErrorSet * errorSet,const std::shared_ptr<RendererGL> & renderer,bool usesDiscreteGPU)19 ContextCGL::ContextCGL(const gl::State &state,
20 gl::ErrorSet *errorSet,
21 const std::shared_ptr<RendererGL> &renderer,
22 bool usesDiscreteGPU)
23 : ContextGL(state, errorSet, renderer), mUsesDiscreteGpu(usesDiscreteGPU)
24 {}
25
onDestroy(const gl::Context * context)26 void ContextCGL::onDestroy(const gl::Context *context)
27 {
28 if (mUsesDiscreteGpu)
29 {
30 egl::Display *display = context->getDisplay();
31 // TODO(kbr): if the context is created and destroyed without ever
32 // making it current, it is possible to leak retentions of the
33 // discrete GPU.
34 if (display)
35 {
36 GetImplAs<DisplayCGL>(display)->unreferenceDiscreteGPU();
37 }
38 }
39 }
40
41 } // namespace rx
42