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 <list> | 7 #include <list> |
8 | 8 |
9 #include "base/memory/linked_ptr.h" | 9 #include "base/memory/linked_ptr.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 texture->usage_ = usage_; | 404 texture->usage_ = usage_; |
405 } | 405 } |
406 | 406 |
407 void TextureDefinition::UpdateTexture(Texture* texture) const { | 407 void TextureDefinition::UpdateTexture(Texture* texture) const { |
408 GLuint old_service_id = 0u; | 408 GLuint old_service_id = 0u; |
409 if (image_buffer_.get() && g_avoid_egl_target_texture_reuse) { | 409 if (image_buffer_.get() && g_avoid_egl_target_texture_reuse) { |
410 GLuint service_id = 0u; | 410 GLuint service_id = 0u; |
411 glGenTextures(1, &service_id); | 411 glGenTextures(1, &service_id); |
412 old_service_id = texture->service_id(); | 412 old_service_id = texture->service_id(); |
413 texture->SetServiceId(service_id); | 413 texture->SetServiceId(service_id); |
| 414 |
| 415 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), target_); |
| 416 GLint bound_id = 0; |
| 417 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_id); |
| 418 if (bound_id == static_cast<GLint>(old_service_id)) { |
| 419 glBindTexture(target_, service_id); |
| 420 } |
414 } | 421 } |
415 | 422 |
416 UpdateTextureInternal(texture); | 423 UpdateTextureInternal(texture); |
417 | 424 |
418 if (old_service_id) { | 425 if (old_service_id) { |
419 glDeleteTextures(1, &old_service_id); | 426 glDeleteTextures(1, &old_service_id); |
420 } | 427 } |
421 } | 428 } |
422 | 429 |
423 bool TextureDefinition::Matches(const Texture* texture) const { | 430 bool TextureDefinition::Matches(const Texture* texture) const { |
(...skipping 16 matching lines...) Expand all Loading... |
440 | 447 |
441 return true; | 448 return true; |
442 } | 449 } |
443 | 450 |
444 bool TextureDefinition::SafeToRenderFrom() const { | 451 bool TextureDefinition::SafeToRenderFrom() const { |
445 return level_info_.cleared; | 452 return level_info_.cleared; |
446 } | 453 } |
447 | 454 |
448 } // namespace gles2 | 455 } // namespace gles2 |
449 } // namespace gpu | 456 } // namespace gpu |
OLD | NEW |