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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
// Copyright (c) 2011 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.
#include <windows.h>
#include "gpu/command_buffer/service/gpu_scheduler.h"
#include "ui/gfx/gl/gl_context.h"
#include "ui/gfx/gl/gl_share_group.h"
#include "ui/gfx/gl/gl_surface.h"
using ::base::SharedMemory;
namespace gpu {
bool GpuScheduler::Initialize(
gfx::PluginWindowHandle window,
const gfx::Size& size,
const gles2::DisallowedExtensions& disallowed_extensions,
const char* allowed_extensions,
const std::vector<int32>& attribs,
GpuScheduler* parent,
uint32 parent_texture_id,
gfx::GLShareGroup* share_group) {
// Get the parent decoder.
gles2::GLES2Decoder* parent_decoder = NULL;
if (parent) {
parent_decoder = parent->decoder_.get();
DCHECK(parent_decoder);
}
// Create either a view or pbuffer based GLSurface.
scoped_refptr<gfx::GLSurface> surface;
if (window) {
surface = gfx::GLSurface::CreateViewGLSurface(window);
} else {
surface = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1));
}
if (!surface.get()) {
LOG(ERROR) << "GpuScheduler::Initialize failed.\n";
Destroy();
return false;
}
// Create a GLContext and attach the surface.
scoped_refptr<gfx::GLContext> context(
gfx::GLContext::CreateGLContext(share_group, surface.get()));
if (!context.get()) {
LOG(ERROR) << "CreateGLContext failed.\n";
Destroy();
return false;
}
return InitializeCommon(surface,
context,
size,
disallowed_extensions,
allowed_extensions,
attribs,
parent_decoder,
parent_texture_id);
}
void GpuScheduler::Destroy() {
DestroyCommon();
}
void GpuScheduler::WillSwapBuffers() {
if (wrapped_swap_buffers_callback_.get()) {
wrapped_swap_buffers_callback_->Run();
}
}
} // namespace gpu
|