summaryrefslogtreecommitdiff
path: root/chromium/ui/gl/init/ozone_util.h
blob: 11c04d0c7e70c5ed655bf9a3a5e56e7daf08703d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_GL_INIT_OZONE_UTIL_H_
#define UI_GL_INIT_OZONE_UTIL_H_

#include "base/macros.h"
#include "ui/gl/gl_implementation.h"
#include "ui/ozone/public/gl_ozone.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/surface_factory_ozone.h"

namespace gl {
namespace init {

inline ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() {
  return ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone();
}

// Returns true if there is an GLOzone for the specified GL implementation.
inline bool HasGLOzone(GLImplementation impl) {
  return GetSurfaceFactoryOzone() && GetSurfaceFactoryOzone()->GetGLOzone(impl);
}

// Returns true if there is an GLOzone for the set GL implementation.
inline bool HasGLOzone() {
  return HasGLOzone(GetGLImplementation());
}

// Returns the GLOzone for the specified GL implementation or null if none
// exists.
inline ui::GLOzone* GetGLOzone(GLImplementation impl) {
  return GetSurfaceFactoryOzone()->GetGLOzone(impl);
}

// Returns the GLOzone for the set GL implementation or null if none exists.
inline ui::GLOzone* GetGLOzone() {
  return GetGLOzone(GetGLImplementation());
}

}  // namespace init
}  // namespace gl

#endif  // UI_GL_INIT_OZONE_UTIL_H_