Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.cc

Issue 1844843002: android: Remove in-process video path (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove commented out code + rebase again Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h"
6
7 #include <GLES2/gl2.h>
8 #include <utility>
9 #ifndef GL_GLEXT_PROTOTYPES
10 #define GL_GLEXT_PROTOTYPES 1
11 #endif
12 #include <GLES2/gl2ext.h>
13 #include <GLES2/gl2extchromium.h>
14 #include <stddef.h>
15
16 #include <string>
17
18 #include "base/atomicops.h"
19 #include "base/bind.h"
20 #include "base/bind_helpers.h"
21 #include "base/callback.h"
22 #include "base/logging.h"
23 #include "gpu/command_buffer/client/gles2_implementation.h"
24 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
25 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h"
26 #include "ui/gfx/geometry/size.h"
27 #include "ui/gl/gl_implementation.h"
28
29 using gpu::gles2::GLES2Implementation;
30 using gpu::GLInProcessContext;
31
32 namespace gpu_blink {
33
34 // static
35 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
36 WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
37 const gpu::gles2::ContextCreationAttribHelper& attributes) {
38 bool is_offscreen = true;
39 return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl(
40 scoped_ptr<::gpu::GLInProcessContext>(), attributes, is_offscreen,
41 gfx::kNullAcceleratedWidget));
42 }
43
44 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
45 WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext(
46 scoped_ptr<::gpu::GLInProcessContext> context,
47 const gpu::gles2::ContextCreationAttribHelper& attributes) {
48 bool is_offscreen = true; // Not used.
49 gfx::AcceleratedWidget window = gfx::kNullAcceleratedWidget; // Not used.
50 return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl(
51 std::move(context), attributes, is_offscreen, window));
52 }
53
54 WebGraphicsContext3DInProcessCommandBufferImpl::
55 WebGraphicsContext3DInProcessCommandBufferImpl(
56 scoped_ptr<::gpu::GLInProcessContext> context,
57 const gpu::gles2::ContextCreationAttribHelper& attributes,
58 bool is_offscreen,
59 gfx::AcceleratedWidget window)
60 : attributes_(attributes),
61 is_offscreen_(is_offscreen),
62 window_(window),
63 context_(std::move(context)) {}
64
65 WebGraphicsContext3DInProcessCommandBufferImpl::
66 ~WebGraphicsContext3DInProcessCommandBufferImpl() {
67 if (real_gl_)
68 real_gl_->SetLostContextCallback(base::Closure());
69 }
70
71 size_t WebGraphicsContext3DInProcessCommandBufferImpl::GetMappedMemoryLimit() {
72 return context_->GetMappedMemoryLimit();
73 }
74
75 bool WebGraphicsContext3DInProcessCommandBufferImpl::MaybeInitializeGL() {
76 if (initialized_)
77 return true;
78
79 if (initialize_failed_)
80 return false;
81
82 if (!context_) {
83 // TODO(kbr): More work will be needed in this implementation to
84 // properly support GPU switching. Like in the out-of-process
85 // command buffer implementation, all previously created contexts
86 // will need to be lost either when the first context requesting the
87 // discrete GPU is created, or the last one is destroyed.
88 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
89 context_.reset(GLInProcessContext::Create(
90 NULL, /* service */
91 NULL, /* surface */
92 is_offscreen_, window_, gfx::Size(1, 1), NULL, /* share_context */
93 attributes_, gpu_preference,
94 ::gpu::GLInProcessContextSharedMemoryLimits(), nullptr, nullptr));
95 }
96
97 if (!context_) {
98 initialize_failed_ = true;
99 return false;
100 }
101
102 real_gl_ = context_->GetImplementation();
103 SetGLInterface(real_gl_);
104
105 real_gl_->TraceBeginCHROMIUM("WebGraphicsContext3D",
106 "InProcessContext");
107
108 initialized_ = true;
109 return true;
110 }
111
112 bool
113 WebGraphicsContext3DInProcessCommandBufferImpl::InitializeOnCurrentThread() {
114 if (!MaybeInitializeGL())
115 return false;
116 return context_ &&
117 context_->GetImplementation()->GetGraphicsResetStatusKHR() ==
118 GL_NO_ERROR;
119 }
120
121 void WebGraphicsContext3DInProcessCommandBufferImpl::SetLock(base::Lock* lock) {
122 context_->SetLock(lock);
123 }
124
125 ::gpu::ContextSupport*
126 WebGraphicsContext3DInProcessCommandBufferImpl::GetContextSupport() {
127 return real_gl_;
128 }
129
130 } // namespace gpu_blink
OLDNEW
« no previous file with comments | « gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h ('k') | gpu/command_buffer/client/gl_in_process_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698