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

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

Issue 199443004: gpu: Raise GL_OUT_OF_MEMORY when BeginQueryEXT fails to allocate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: checkmem: benchmark Created 6 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 | Annotate | Revision Log
« 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
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 static base::LazyInstance<GLES2Initializer> g_gles2_initializer = 67 static base::LazyInstance<GLES2Initializer> g_gles2_initializer =
68 LAZY_INSTANCE_INITIALIZER; 68 LAZY_INSTANCE_INITIALIZER;
69 69
70 } // namespace anonymous 70 } // namespace anonymous
71 71
72 // static 72 // static
73 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> 73 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
74 WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext( 74 WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext(
75 const blink::WebGraphicsContext3D::Attributes& attributes, 75 const blink::WebGraphicsContext3D::Attributes& attributes,
76 bool lose_context_when_out_of_memory,
76 gfx::AcceleratedWidget window) { 77 gfx::AcceleratedWidget window) {
77 DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone); 78 DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone);
79 bool is_offscreen = false;
78 return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl( 80 return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl(
79 scoped_ptr< ::gpu::GLInProcessContext>(), attributes, false, window)); 81 scoped_ptr< ::gpu::GLInProcessContext>(),
82 attributes,
83 lose_context_when_out_of_memory,
84 is_offscreen,
85 window));
80 } 86 }
81 87
82 // static 88 // static
83 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> 89 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
84 WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext( 90 WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
85 const blink::WebGraphicsContext3D::Attributes& attributes) { 91 const blink::WebGraphicsContext3D::Attributes& attributes,
92 bool lose_context_when_out_of_memory) {
93 bool is_offscreen = true;
86 return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl( 94 return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl(
87 scoped_ptr< ::gpu::GLInProcessContext>(), 95 scoped_ptr< ::gpu::GLInProcessContext>(),
88 attributes, 96 attributes,
89 true, 97 lose_context_when_out_of_memory,
98 is_offscreen,
90 gfx::kNullAcceleratedWidget)); 99 gfx::kNullAcceleratedWidget));
91 } 100 }
92 101
93 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> 102 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
94 WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext( 103 WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext(
95 scoped_ptr< ::gpu::GLInProcessContext> context, 104 scoped_ptr< ::gpu::GLInProcessContext> context,
96 const blink::WebGraphicsContext3D::Attributes& attributes) { 105 const blink::WebGraphicsContext3D::Attributes& attributes) {
106 bool lose_context_when_out_of_memory = false; // Not used.
107 bool is_offscreen = true; // Not used.
97 return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl( 108 return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl(
98 context.Pass(), 109 context.Pass(),
99 attributes, 110 attributes,
100 true /* is_offscreen. Not used. */, 111 lose_context_when_out_of_memory,
112 is_offscreen,
101 gfx::kNullAcceleratedWidget /* window. Not used. */)); 113 gfx::kNullAcceleratedWidget /* window. Not used. */));
102 } 114 }
103 115
104 WebGraphicsContext3DInProcessCommandBufferImpl:: 116 WebGraphicsContext3DInProcessCommandBufferImpl::
105 WebGraphicsContext3DInProcessCommandBufferImpl( 117 WebGraphicsContext3DInProcessCommandBufferImpl(
106 scoped_ptr< ::gpu::GLInProcessContext> context, 118 scoped_ptr< ::gpu::GLInProcessContext> context,
107 const blink::WebGraphicsContext3D::Attributes& attributes, 119 const blink::WebGraphicsContext3D::Attributes& attributes,
120 bool lose_context_when_out_of_memory,
108 bool is_offscreen, 121 bool is_offscreen,
109 gfx::AcceleratedWidget window) 122 gfx::AcceleratedWidget window)
110 : is_offscreen_(is_offscreen), 123 : is_offscreen_(is_offscreen),
111 window_(window), 124 window_(window),
112 initialized_(false), 125 initialized_(false),
113 initialize_failed_(false), 126 initialize_failed_(false),
114 context_(context.Pass()), 127 context_(context.Pass()),
115 gl_(NULL), 128 gl_(NULL),
116 context_lost_callback_(NULL), 129 context_lost_callback_(NULL),
117 context_lost_reason_(GL_NO_ERROR), 130 context_lost_reason_(GL_NO_ERROR),
118 attributes_(attributes), 131 attributes_(attributes),
119 flush_id_(0) { 132 lose_context_when_out_of_memory_(lose_context_when_out_of_memory),
120 } 133 flush_id_(0) {}
121 134
122 WebGraphicsContext3DInProcessCommandBufferImpl:: 135 WebGraphicsContext3DInProcessCommandBufferImpl::
123 ~WebGraphicsContext3DInProcessCommandBufferImpl() { 136 ~WebGraphicsContext3DInProcessCommandBufferImpl() {
124 } 137 }
125 138
126 // static 139 // static
127 void WebGraphicsContext3DInProcessCommandBufferImpl::ConvertAttributes( 140 void WebGraphicsContext3DInProcessCommandBufferImpl::ConvertAttributes(
128 const blink::WebGraphicsContext3D::Attributes& attributes, 141 const blink::WebGraphicsContext3D::Attributes& attributes,
129 ::gpu::GLInProcessContextAttribs* output_attribs) { 142 ::gpu::GLInProcessContextAttribs* output_attribs) {
130 output_attribs->alpha_size = attributes.alpha ? 8 : 0; 143 output_attribs->alpha_size = attributes.alpha ? 8 : 0;
(...skipping 17 matching lines...) Expand all
148 161
149 if (!context_) { 162 if (!context_) {
150 // TODO(kbr): More work will be needed in this implementation to 163 // TODO(kbr): More work will be needed in this implementation to
151 // properly support GPU switching. Like in the out-of-process 164 // properly support GPU switching. Like in the out-of-process
152 // command buffer implementation, all previously created contexts 165 // command buffer implementation, all previously created contexts
153 // will need to be lost either when the first context requesting the 166 // will need to be lost either when the first context requesting the
154 // discrete GPU is created, or the last one is destroyed. 167 // discrete GPU is created, or the last one is destroyed.
155 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu; 168 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
156 169
157 ::gpu::GLInProcessContextAttribs attrib_struct; 170 ::gpu::GLInProcessContextAttribs attrib_struct;
158 ConvertAttributes(attributes_, &attrib_struct), 171 ConvertAttributes(attributes_, &attrib_struct);
172 attrib_struct.lose_context_when_out_of_memory =
173 lose_context_when_out_of_memory_;
159 174
160 context_.reset(GLInProcessContext::CreateContext( 175 context_.reset(GLInProcessContext::CreateContext(
161 is_offscreen_, 176 is_offscreen_,
162 window_, 177 window_,
163 gfx::Size(1, 1), 178 gfx::Size(1, 1),
164 attributes_.shareResources, 179 attributes_.shareResources,
165 attrib_struct, 180 attrib_struct,
166 gpu_preference)); 181 gpu_preference));
167 } 182 }
168 183
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 1195
1181 DELEGATE_TO_GL_9(asyncTexSubImage2DCHROMIUM, AsyncTexSubImage2DCHROMIUM, 1196 DELEGATE_TO_GL_9(asyncTexSubImage2DCHROMIUM, AsyncTexSubImage2DCHROMIUM,
1182 WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei, 1197 WGC3Denum, WGC3Dint, WGC3Dint, WGC3Dint, WGC3Dsizei, WGC3Dsizei,
1183 WGC3Denum, WGC3Denum, const void*) 1198 WGC3Denum, WGC3Denum, const void*)
1184 1199
1185 DELEGATE_TO_GL_1(waitAsyncTexImage2DCHROMIUM, WaitAsyncTexImage2DCHROMIUM, 1200 DELEGATE_TO_GL_1(waitAsyncTexImage2DCHROMIUM, WaitAsyncTexImage2DCHROMIUM,
1186 WGC3Denum) 1201 WGC3Denum)
1187 1202
1188 } // namespace gpu 1203 } // namespace gpu
1189 } // namespace webkit 1204 } // 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