OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/command_buffer/service/texture_definition.h" | 5 #include "gpu/command_buffer/service/texture_definition.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 | 10 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 bool needs_wait_before_read; | 147 bool needs_wait_before_read; |
148 }; | 148 }; |
149 std::list<ClientInfo> client_infos_; | 149 std::list<ClientInfo> client_infos_; |
150 gl::GLImage* write_client_; | 150 gl::GLImage* write_client_; |
151 | 151 |
152 DISALLOW_COPY_AND_ASSIGN(NativeImageBufferEGL); | 152 DISALLOW_COPY_AND_ASSIGN(NativeImageBufferEGL); |
153 }; | 153 }; |
154 | 154 |
155 scoped_refptr<NativeImageBufferEGL> NativeImageBufferEGL::Create( | 155 scoped_refptr<NativeImageBufferEGL> NativeImageBufferEGL::Create( |
156 GLuint texture_id) { | 156 GLuint texture_id) { |
157 EGLDisplay egl_display = gfx::GLSurfaceEGL::GetHardwareDisplay(); | 157 EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); |
158 EGLContext egl_context = eglGetCurrentContext(); | 158 EGLContext egl_context = eglGetCurrentContext(); |
159 | 159 |
160 DCHECK_NE(EGL_NO_CONTEXT, egl_context); | 160 DCHECK_NE(EGL_NO_CONTEXT, egl_context); |
161 DCHECK_NE(EGL_NO_DISPLAY, egl_display); | 161 DCHECK_NE(EGL_NO_DISPLAY, egl_display); |
162 DCHECK(glIsTexture(texture_id)); | 162 DCHECK(glIsTexture(texture_id)); |
163 | 163 |
164 DCHECK(gfx::g_driver_egl.ext.b_EGL_KHR_image_base && | 164 DCHECK(gl::g_driver_egl.ext.b_EGL_KHR_image_base && |
165 gfx::g_driver_egl.ext.b_EGL_KHR_gl_texture_2D_image && | 165 gl::g_driver_egl.ext.b_EGL_KHR_gl_texture_2D_image && |
166 gfx::g_driver_gl.ext.b_GL_OES_EGL_image); | 166 gl::g_driver_gl.ext.b_GL_OES_EGL_image); |
167 | 167 |
168 const EGLint egl_attrib_list[] = { | 168 const EGLint egl_attrib_list[] = { |
169 EGL_GL_TEXTURE_LEVEL_KHR, 0, EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE}; | 169 EGL_GL_TEXTURE_LEVEL_KHR, 0, EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE}; |
170 EGLClientBuffer egl_buffer = reinterpret_cast<EGLClientBuffer>(texture_id); | 170 EGLClientBuffer egl_buffer = reinterpret_cast<EGLClientBuffer>(texture_id); |
171 EGLenum egl_target = EGL_GL_TEXTURE_2D_KHR; | 171 EGLenum egl_target = EGL_GL_TEXTURE_2D_KHR; |
172 | 172 |
173 EGLImageKHR egl_image = eglCreateImageKHR( | 173 EGLImageKHR egl_image = eglCreateImageKHR( |
174 egl_display, egl_context, egl_target, egl_buffer, egl_attrib_list); | 174 egl_display, egl_context, egl_target, egl_buffer, egl_attrib_list); |
175 | 175 |
176 if (egl_image == EGL_NO_IMAGE_KHR) { | 176 if (egl_image == EGL_NO_IMAGE_KHR) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 | 256 |
257 DISALLOW_COPY_AND_ASSIGN(NativeImageBufferStub); | 257 DISALLOW_COPY_AND_ASSIGN(NativeImageBufferStub); |
258 }; | 258 }; |
259 | 259 |
260 bool g_avoid_egl_target_texture_reuse = false; | 260 bool g_avoid_egl_target_texture_reuse = false; |
261 | 261 |
262 } // anonymous namespace | 262 } // anonymous namespace |
263 | 263 |
264 // static | 264 // static |
265 scoped_refptr<NativeImageBuffer> NativeImageBuffer::Create(GLuint texture_id) { | 265 scoped_refptr<NativeImageBuffer> NativeImageBuffer::Create(GLuint texture_id) { |
266 switch (gfx::GetGLImplementation()) { | 266 switch (gl::GetGLImplementation()) { |
267 #if !defined(OS_MACOSX) | 267 #if !defined(OS_MACOSX) |
268 case gfx::kGLImplementationEGLGLES2: | 268 case gl::kGLImplementationEGLGLES2: |
269 return NativeImageBufferEGL::Create(texture_id); | 269 return NativeImageBufferEGL::Create(texture_id); |
270 #endif | 270 #endif |
271 case gfx::kGLImplementationMockGL: | 271 case gl::kGLImplementationMockGL: |
272 return new NativeImageBufferStub; | 272 return new NativeImageBufferStub; |
273 default: | 273 default: |
274 NOTREACHED(); | 274 NOTREACHED(); |
275 return NULL; | 275 return NULL; |
276 } | 276 } |
277 } | 277 } |
278 | 278 |
279 // static | 279 // static |
280 void TextureDefinition::AvoidEGLTargetTextureReuse() { | 280 void TextureDefinition::AvoidEGLTargetTextureReuse() { |
281 g_avoid_egl_target_texture_reuse = true; | 281 g_avoid_egl_target_texture_reuse = true; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 GLuint texture_id; | 370 GLuint texture_id; |
371 glGenTextures(1, &texture_id); | 371 glGenTextures(1, &texture_id); |
372 | 372 |
373 Texture* texture(new Texture(texture_id)); | 373 Texture* texture(new Texture(texture_id)); |
374 UpdateTextureInternal(texture); | 374 UpdateTextureInternal(texture); |
375 | 375 |
376 return texture; | 376 return texture; |
377 } | 377 } |
378 | 378 |
379 void TextureDefinition::UpdateTextureInternal(Texture* texture) const { | 379 void TextureDefinition::UpdateTextureInternal(Texture* texture) const { |
380 gfx::ScopedTextureBinder texture_binder(target_, texture->service_id()); | 380 gl::ScopedTextureBinder texture_binder(target_, texture->service_id()); |
381 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter_); | 381 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter_); |
382 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter_); | 382 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter_); |
383 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_s_); | 383 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_s_); |
384 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_t_); | 384 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_t_); |
385 | 385 |
386 if (image_buffer_.get()) { | 386 if (image_buffer_.get()) { |
387 gl::GLImage* existing_image = texture->GetLevelImage(target_, 0); | 387 gl::GLImage* existing_image = texture->GetLevelImage(target_, 0); |
388 // Don't need to re-bind if already bound before. | 388 // Don't need to re-bind if already bound before. |
389 if (!existing_image || !image_buffer_->IsClient(existing_image)) { | 389 if (!existing_image || !image_buffer_->IsClient(existing_image)) { |
390 image_buffer_->BindToTexture(target_); | 390 image_buffer_->BindToTexture(target_); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 return true; | 465 return true; |
466 } | 466 } |
467 | 467 |
468 bool TextureDefinition::SafeToRenderFrom() const { | 468 bool TextureDefinition::SafeToRenderFrom() const { |
469 return level_info_.cleared_rect.Contains( | 469 return level_info_.cleared_rect.Contains( |
470 gfx::Rect(level_info_.width, level_info_.height)); | 470 gfx::Rect(level_info_.width, level_info_.height)); |
471 } | 471 } |
472 | 472 |
473 } // namespace gles2 | 473 } // namespace gles2 |
474 } // namespace gpu | 474 } // namespace gpu |
OLD | NEW |