1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_GL_CONTEXT_VIRTUAL_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_GL_CONTEXT_VIRTUAL_H_
9 #include "base/callback_forward.h"
10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "gpu/gpu_export.h"
14 #include "ui/gl/gl_context.h"
18 class GPUTimingClient
;
28 // Encapsulates a virtual OpenGL context.
29 class GPU_EXPORT GLContextVirtual
: public gfx::GLContext
{
32 gfx::GLShareGroup
* share_group
,
33 gfx::GLContext
* shared_context
,
34 base::WeakPtr
<gles2::GLES2Decoder
> decoder
);
36 // Implement GLContext.
37 bool Initialize(gfx::GLSurface
* compatible_surface
,
38 gfx::GpuPreference gpu_preference
) override
;
39 bool MakeCurrent(gfx::GLSurface
* surface
) override
;
40 void ReleaseCurrent(gfx::GLSurface
* surface
) override
;
41 bool IsCurrent(gfx::GLSurface
* surface
) override
;
42 void* GetHandle() override
;
43 scoped_refptr
<gfx::GPUTimingClient
> CreateGPUTimingClient() override
;
44 void OnSetSwapInterval(int interval
) override
;
45 std::string
GetExtensions() override
;
46 bool GetTotalGpuMemory(size_t* bytes
) override
;
47 void SetSafeToForceGpuSwitch() override
;
48 bool WasAllocatedUsingRobustnessExtension() override
;
49 void SetUnbindFboOnMakeCurrent() override
;
50 base::Closure
GetStateWasDirtiedExternallyCallback() override
;
51 void RestoreStateIfDirtiedExternally() override
;
54 ~GLContextVirtual() override
;
59 scoped_refptr
<gfx::GLContext
> shared_context_
;
60 base::WeakPtr
<gles2::GLES2Decoder
> decoder_
;
62 DISALLOW_COPY_AND_ASSIGN(GLContextVirtual
);
67 #endif // GPU_COMMAND_BUFFER_SERVICE_GL_CONTEXT_VIRTUAL_H_