OLD | NEW |
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 "gpu/gles2_conform_support/egl/display.h" | 5 #include "gpu/gles2_conform_support/egl/display.h" |
6 | 6 |
7 #include "gpu/gles2_conform_support/egl/config.h" | 7 #include "gpu/gles2_conform_support/egl/config.h" |
8 #include "gpu/gles2_conform_support/egl/context.h" | 8 #include "gpu/gles2_conform_support/egl/context.h" |
9 #include "gpu/gles2_conform_support/egl/surface.h" | 9 #include "gpu/gles2_conform_support/egl/surface.h" |
10 #include "gpu/gles2_conform_support/egl/thread_state.h" | 10 #include "gpu/gles2_conform_support/egl/thread_state.h" |
| 11 #include "ui/gl/init/gl_factory.h" |
11 | 12 |
12 namespace egl { | 13 namespace egl { |
13 | 14 |
14 Display::Display() | 15 Display::Display() |
15 : is_initialized_(false), | 16 : is_initialized_(false), |
16 next_create_window_surface_creates_pbuffer_(false), | 17 next_create_window_surface_creates_pbuffer_(false), |
17 window_surface_pbuffer_width_(0), | 18 window_surface_pbuffer_width_(0), |
18 window_surface_pbuffer_height_(0) { | 19 window_surface_pbuffer_height_(0) { |
19 } | 20 } |
20 | 21 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 } | 172 } |
172 return DoCreatePbufferSurface(ts, config, width, height); | 173 return DoCreatePbufferSurface(ts, config, width, height); |
173 } | 174 } |
174 | 175 |
175 EGLSurface Display::DoCreatePbufferSurface(ThreadState* ts, | 176 EGLSurface Display::DoCreatePbufferSurface(ThreadState* ts, |
176 const Config* config, | 177 const Config* config, |
177 EGLint width, | 178 EGLint width, |
178 EGLint height) { | 179 EGLint height) { |
179 lock_.AssertAcquired(); | 180 lock_.AssertAcquired(); |
180 scoped_refptr<gfx::GLSurface> gl_surface; | 181 scoped_refptr<gfx::GLSurface> gl_surface; |
181 gl_surface = | 182 gl_surface = gl::init::CreateOffscreenGLSurface(gfx::Size(width, height)); |
182 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(width, height)); | |
183 if (!gl_surface) | 183 if (!gl_surface) |
184 return ts->ReturnError(EGL_BAD_ALLOC, nullptr); | 184 return ts->ReturnError(EGL_BAD_ALLOC, nullptr); |
185 surfaces_.emplace_back(new Surface(gl_surface.get(), config)); | 185 surfaces_.emplace_back(new Surface(gl_surface.get(), config)); |
186 return ts->ReturnSuccess<EGLSurface>(surfaces_.back().get()); | 186 return ts->ReturnSuccess<EGLSurface>(surfaces_.back().get()); |
187 } | 187 } |
188 | 188 |
189 EGLSurface Display::CreateWindowSurface(ThreadState* ts, | 189 EGLSurface Display::CreateWindowSurface(ThreadState* ts, |
190 EGLConfig cfg, | 190 EGLConfig cfg, |
191 EGLNativeWindowType win, | 191 EGLNativeWindowType win, |
192 const EGLint* attrib_list) { | 192 const EGLint* attrib_list) { |
(...skipping 14 matching lines...) Expand all Loading... |
207 if (next_create_window_surface_creates_pbuffer_) { | 207 if (next_create_window_surface_creates_pbuffer_) { |
208 EGLSurface result = DoCreatePbufferSurface(ts, config, | 208 EGLSurface result = DoCreatePbufferSurface(ts, config, |
209 window_surface_pbuffer_width_, | 209 window_surface_pbuffer_width_, |
210 window_surface_pbuffer_height_); | 210 window_surface_pbuffer_height_); |
211 next_create_window_surface_creates_pbuffer_ = false; | 211 next_create_window_surface_creates_pbuffer_ = false; |
212 window_surface_pbuffer_width_ = 0; | 212 window_surface_pbuffer_width_ = 0; |
213 window_surface_pbuffer_height_ = 0; | 213 window_surface_pbuffer_height_ = 0; |
214 return result; | 214 return result; |
215 } | 215 } |
216 scoped_refptr<gfx::GLSurface> gl_surface; | 216 scoped_refptr<gfx::GLSurface> gl_surface; |
217 gl_surface = gfx::GLSurface::CreateViewGLSurface(win); | 217 gl_surface = gl::init::CreateViewGLSurface(win); |
218 if (!gl_surface) | 218 if (!gl_surface) |
219 return ts->ReturnError(EGL_BAD_ALLOC, EGL_NO_SURFACE); | 219 return ts->ReturnError(EGL_BAD_ALLOC, EGL_NO_SURFACE); |
220 surfaces_.emplace_back(new Surface(gl_surface.get(), config)); | 220 surfaces_.emplace_back(new Surface(gl_surface.get(), config)); |
221 return ts->ReturnSuccess(surfaces_.back().get()); | 221 return ts->ReturnSuccess(surfaces_.back().get()); |
222 } | 222 } |
223 | 223 |
224 EGLBoolean Display::DestroySurface(ThreadState* ts, EGLSurface sfe) { | 224 EGLBoolean Display::DestroySurface(ThreadState* ts, EGLSurface sfe) { |
225 base::AutoLock auto_lock(lock_); | 225 base::AutoLock auto_lock(lock_); |
226 if (!is_initialized_) | 226 if (!is_initialized_) |
227 return ts->ReturnError(EGL_NOT_INITIALIZED, EGL_FALSE); | 227 return ts->ReturnError(EGL_NOT_INITIALIZED, EGL_FALSE); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 | 393 |
394 Context* Display::GetContext(EGLContext context) { | 394 Context* Display::GetContext(EGLContext context) { |
395 lock_.AssertAcquired(); | 395 lock_.AssertAcquired(); |
396 auto it = std::find(contexts_.begin(), contexts_.end(), context); | 396 auto it = std::find(contexts_.begin(), contexts_.end(), context); |
397 if (it == contexts_.end()) | 397 if (it == contexts_.end()) |
398 return nullptr; | 398 return nullptr; |
399 return it->get(); | 399 return it->get(); |
400 } | 400 } |
401 | 401 |
402 } // namespace egl | 402 } // namespace egl |
OLD | NEW |