| 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 <vector> | 7 #include <vector> |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "gpu/command_buffer/client/gles2_lib.h" | 10 #include "gpu/command_buffer/client/gles2_lib.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 bool Display::Initialize() { | 36 bool Display::Initialize() { |
| 37 gles2::Initialize(); | 37 gles2::Initialize(); |
| 38 is_initialized_ = true; | 38 is_initialized_ = true; |
| 39 return true; | 39 return true; |
| 40 } | 40 } |
| 41 | 41 |
| 42 bool Display::IsValidConfig(EGLConfig config) { | 42 bool Display::IsValidConfig(EGLConfig config) { |
| 43 return (config != NULL) && (config == config_.get()); | 43 return (config != NULL) && (config == config_.get()); |
| 44 } | 44 } |
| 45 | 45 |
| 46 bool Display::ChooseConfigs(EGLConfig* configs, |
| 47 EGLint config_size, |
| 48 EGLint* num_config) { |
| 49 // TODO(alokp): Find out a way to find all configs. CommandBuffer currently |
| 50 // does not support finding or choosing configs. |
| 51 *num_config = 1; |
| 52 if (configs != NULL) { |
| 53 if (config_ == NULL) { |
| 54 config_.reset(new Config); |
| 55 } |
| 56 configs[0] = config_.get(); |
| 57 } |
| 58 return true; |
| 59 } |
| 60 |
| 46 bool Display::GetConfigs(EGLConfig* configs, | 61 bool Display::GetConfigs(EGLConfig* configs, |
| 47 EGLint config_size, | 62 EGLint config_size, |
| 48 EGLint* num_config) { | 63 EGLint* num_config) { |
| 49 // TODO(alokp): Find out a way to find all configs. CommandBuffer currently | 64 // TODO(alokp): Find out a way to find all configs. CommandBuffer currently |
| 50 // does not support finding or choosing configs. | 65 // does not support finding or choosing configs. |
| 51 *num_config = 1; | 66 *num_config = 1; |
| 52 if (configs != NULL) { | 67 if (configs != NULL) { |
| 53 if (config_ == NULL) { | 68 if (config_ == NULL) { |
| 54 config_.reset(new Config); | 69 config_.reset(new Config); |
| 55 } | 70 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 return EGL_NO_SURFACE; | 137 return EGL_NO_SURFACE; |
| 123 | 138 |
| 124 gl_context_ = gfx::GLContext::CreateGLContext(NULL, | 139 gl_context_ = gfx::GLContext::CreateGLContext(NULL, |
| 125 gl_surface_.get(), | 140 gl_surface_.get(), |
| 126 gfx::PreferDiscreteGpu); | 141 gfx::PreferDiscreteGpu); |
| 127 if (!gl_context_.get()) | 142 if (!gl_context_.get()) |
| 128 return EGL_NO_SURFACE; | 143 return EGL_NO_SURFACE; |
| 129 | 144 |
| 130 gl_context_->MakeCurrent(gl_surface_); | 145 gl_context_->MakeCurrent(gl_surface_); |
| 131 | 146 |
| 147 EGLint depth_size = 0; |
| 148 EGLint alpha_size = 0; |
| 149 EGLint stencil_size = 0; |
| 150 GetConfigAttrib(config, EGL_DEPTH_SIZE, &depth_size); |
| 151 GetConfigAttrib(config, EGL_ALPHA_SIZE, &alpha_size); |
| 152 GetConfigAttrib(config, EGL_STENCIL_SIZE, &stencil_size); |
| 132 std::vector<int32> attribs; | 153 std::vector<int32> attribs; |
| 154 attribs.push_back(EGL_DEPTH_SIZE); |
| 155 attribs.push_back(depth_size); |
| 156 attribs.push_back(EGL_ALPHA_SIZE); |
| 157 attribs.push_back(alpha_size); |
| 158 attribs.push_back(EGL_STENCIL_SIZE); |
| 159 attribs.push_back(stencil_size); |
| 160 // TODO(gman): Insert attrib_list. Although ES 1.1 says it must be null |
| 161 attribs.push_back(EGL_NONE); |
| 162 |
| 133 if (!decoder_->Initialize(gl_surface_.get(), | 163 if (!decoder_->Initialize(gl_surface_.get(), |
| 134 gl_context_.get(), | 164 gl_context_.get(), |
| 135 gl_surface_->IsOffscreen(), | 165 gl_surface_->IsOffscreen(), |
| 136 size, | 166 size, |
| 137 gpu::gles2::DisallowedFeatures(), | 167 gpu::gles2::DisallowedFeatures(), |
| 138 NULL, | 168 NULL, |
| 139 attribs)) { | 169 attribs)) { |
| 140 return EGL_NO_SURFACE; | 170 return EGL_NO_SURFACE; |
| 141 } | 171 } |
| 142 | 172 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 } else { | 257 } else { |
| 228 DCHECK(IsValidSurface(draw)); | 258 DCHECK(IsValidSurface(draw)); |
| 229 DCHECK(IsValidSurface(read)); | 259 DCHECK(IsValidSurface(read)); |
| 230 DCHECK(IsValidContext(ctx)); | 260 DCHECK(IsValidContext(ctx)); |
| 231 gles2::SetGLContext(context_.get()); | 261 gles2::SetGLContext(context_.get()); |
| 232 } | 262 } |
| 233 return true; | 263 return true; |
| 234 } | 264 } |
| 235 | 265 |
| 236 } // namespace egl | 266 } // namespace egl |
| OLD | NEW |