Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / gfx / gl / ForceDiscreteGPUHelperCGL.h
blob3b4cb07efa2361a0b088a948f49f5074547ddb4f
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef ForceDiscreteGPUHelperCGL_h_
7 #define ForceDiscreteGPUHelperCGL_h_
9 #include <OpenGL/OpenGL.h>
11 /** This RAII helper guarantees that we're on the discrete GPU during its lifetime.
13 * As long as any ForceDiscreteGPUHelperCGL object is alive, we're on the discrete GPU.
15 class ForceDiscreteGPUHelperCGL
17 CGLPixelFormatObj mPixelFormatObj;
19 public:
20 ForceDiscreteGPUHelperCGL()
22 // the code in this function is taken from Chromium, src/ui/gfx/gl/gl_context_cgl.cc, r122013
23 // BSD-style license, (c) The Chromium Authors
24 CGLPixelFormatAttribute attribs[1];
25 attribs[0] = static_cast<CGLPixelFormatAttribute>(0);
26 GLint num_pixel_formats = 0;
27 CGLChoosePixelFormat(attribs, &mPixelFormatObj, &num_pixel_formats);
30 ~ForceDiscreteGPUHelperCGL()
32 CGLReleasePixelFormat(mPixelFormatObj);
36 #endif // ForceDiscreteGPUHelperCGL_h_