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

Side by Side Diff: webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc

Issue 455783002: GPU context creation code duplication cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Fix even more build dependencies Created 6 years, 4 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
« no previous file with comments | « webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h" 5 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl. h"
6 6
7 #include <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #ifndef GL_GLEXT_PROTOTYPES 8 #ifndef GL_GLEXT_PROTOTYPES
9 #define GL_GLEXT_PROTOTYPES 1 9 #define GL_GLEXT_PROTOTYPES 1
10 #endif 10 #endif
11 #include <GLES2/gl2ext.h> 11 #include <GLES2/gl2ext.h>
12 #include <GLES2/gl2extchromium.h> 12 #include <GLES2/gl2extchromium.h>
13 13
14 #include <string> 14 #include <string>
15 15
16 #include "base/atomicops.h" 16 #include "base/atomicops.h"
17 #include "base/bind.h" 17 #include "base/bind.h"
18 #include "base/bind_helpers.h" 18 #include "base/bind_helpers.h"
19 #include "base/callback.h" 19 #include "base/callback.h"
20 #include "base/lazy_instance.h" 20 #include "base/lazy_instance.h"
21 #include "base/logging.h" 21 #include "base/logging.h"
22 #include "gpu/command_buffer/client/gles2_implementation.h" 22 #include "gpu/command_buffer/client/gles2_implementation.h"
23 #include "gpu/command_buffer/client/gles2_lib.h" 23 #include "gpu/command_buffer/client/gles2_lib.h"
24 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
24 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h" 25 #include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h"
25 #include "ui/gfx/size.h" 26 #include "ui/gfx/size.h"
26 #include "ui/gl/gl_implementation.h" 27 #include "ui/gl/gl_implementation.h"
27 28
28 using gpu::gles2::GLES2Implementation; 29 using gpu::gles2::GLES2Implementation;
29 using gpu::GLInProcessContext; 30 using gpu::GLInProcessContext;
30 31
31 namespace webkit { 32 namespace webkit {
32 namespace gpu { 33 namespace gpu {
33 34
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 window_(window), 111 window_(window),
111 context_(context.Pass()) { 112 context_(context.Pass()) {
112 ConvertAttributes(attributes, &attribs_); 113 ConvertAttributes(attributes, &attribs_);
113 attribs_.lose_context_when_out_of_memory = lose_context_when_out_of_memory; 114 attribs_.lose_context_when_out_of_memory = lose_context_when_out_of_memory;
114 } 115 }
115 116
116 WebGraphicsContext3DInProcessCommandBufferImpl:: 117 WebGraphicsContext3DInProcessCommandBufferImpl::
117 ~WebGraphicsContext3DInProcessCommandBufferImpl() { 118 ~WebGraphicsContext3DInProcessCommandBufferImpl() {
118 } 119 }
119 120
120 // static
121 void WebGraphicsContext3DInProcessCommandBufferImpl::ConvertAttributes(
122 const blink::WebGraphicsContext3D::Attributes& attributes,
123 ::gpu::GLInProcessContextAttribs* output_attribs) {
124 output_attribs->alpha_size = attributes.alpha ? 8 : 0;
125 output_attribs->depth_size = attributes.depth ? 24 : 0;
126 output_attribs->stencil_size = attributes.stencil ? 8 : 0;
127 output_attribs->samples = attributes.antialias ? 4 : 0;
128 output_attribs->sample_buffers = attributes.antialias ? 1 : 0;
129 output_attribs->fail_if_major_perf_caveat =
130 attributes.failIfMajorPerformanceCaveat ? 1 : 0;
131 }
132
133 bool WebGraphicsContext3DInProcessCommandBufferImpl::MaybeInitializeGL() { 121 bool WebGraphicsContext3DInProcessCommandBufferImpl::MaybeInitializeGL() {
134 if (initialized_) 122 if (initialized_)
135 return true; 123 return true;
136 124
137 if (initialize_failed_) 125 if (initialize_failed_)
138 return false; 126 return false;
139 127
140 // Ensure the gles2 library is initialized first in a thread safe way. 128 // Ensure the gles2 library is initialized first in a thread safe way.
141 g_gles2_initializer.Get(); 129 g_gles2_initializer.Get();
142 130
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() { 190 void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() {
203 // TODO(kbr): improve the precision here. 191 // TODO(kbr): improve the precision here.
204 context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB; 192 context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB;
205 if (context_lost_callback_) { 193 if (context_lost_callback_) {
206 context_lost_callback_->onContextLost(); 194 context_lost_callback_->onContextLost();
207 } 195 }
208 } 196 }
209 197
210 } // namespace gpu 198 } // namespace gpu
211 } // namespace webkit 199 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698