| 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/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 public: | 29 public: |
| 30 explicit GLImageSync(const scoped_refptr<NativeImageBuffer>& buffer, | 30 explicit GLImageSync(const scoped_refptr<NativeImageBuffer>& buffer, |
| 31 const gfx::Size& size); | 31 const gfx::Size& size); |
| 32 | 32 |
| 33 // Implement GLImage. | 33 // Implement GLImage. |
| 34 void Destroy(bool have_context) override; | 34 void Destroy(bool have_context) override; |
| 35 gfx::Size GetSize() override; | 35 gfx::Size GetSize() override; |
| 36 unsigned GetInternalFormat() override; | 36 unsigned GetInternalFormat() override; |
| 37 bool BindTexImage(unsigned target) override; | 37 bool BindTexImage(unsigned target) override; |
| 38 void ReleaseTexImage(unsigned target) override; | 38 void ReleaseTexImage(unsigned target) override; |
| 39 bool CopyTexImage(unsigned target) override; |
| 39 bool CopyTexSubImage(unsigned target, | 40 bool CopyTexSubImage(unsigned target, |
| 40 const gfx::Point& offset, | 41 const gfx::Point& offset, |
| 41 const gfx::Rect& rect) override; | 42 const gfx::Rect& rect) override; |
| 42 void WillUseTexImage() override; | |
| 43 void WillModifyTexImage() override; | |
| 44 void DidModifyTexImage() override; | |
| 45 void DidUseTexImage() override; | |
| 46 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | 43 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, |
| 47 int z_order, | 44 int z_order, |
| 48 gfx::OverlayTransform transform, | 45 gfx::OverlayTransform transform, |
| 49 const gfx::Rect& bounds_rect, | 46 const gfx::Rect& bounds_rect, |
| 50 const gfx::RectF& crop_rect) override; | 47 const gfx::RectF& crop_rect) override; |
| 51 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, | 48 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, |
| 52 uint64_t process_tracing_id, | 49 uint64_t process_tracing_id, |
| 53 const std::string& dump_name) override; | 50 const std::string& dump_name) override; |
| 54 | 51 |
| 55 protected: | 52 protected: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 84 |
| 88 bool GLImageSync::BindTexImage(unsigned target) { | 85 bool GLImageSync::BindTexImage(unsigned target) { |
| 89 NOTREACHED(); | 86 NOTREACHED(); |
| 90 return false; | 87 return false; |
| 91 } | 88 } |
| 92 | 89 |
| 93 void GLImageSync::ReleaseTexImage(unsigned target) { | 90 void GLImageSync::ReleaseTexImage(unsigned target) { |
| 94 NOTREACHED(); | 91 NOTREACHED(); |
| 95 } | 92 } |
| 96 | 93 |
| 94 bool GLImageSync::CopyTexImage(unsigned target) { |
| 95 NOTREACHED(); |
| 96 return false; |
| 97 } |
| 98 |
| 97 bool GLImageSync::CopyTexSubImage(unsigned target, | 99 bool GLImageSync::CopyTexSubImage(unsigned target, |
| 98 const gfx::Point& offset, | 100 const gfx::Point& offset, |
| 99 const gfx::Rect& rect) { | 101 const gfx::Rect& rect) { |
| 102 NOTREACHED(); |
| 100 return false; | 103 return false; |
| 101 } | 104 } |
| 102 | 105 |
| 103 void GLImageSync::WillUseTexImage() { | |
| 104 } | |
| 105 | |
| 106 void GLImageSync::DidUseTexImage() { | |
| 107 } | |
| 108 | |
| 109 void GLImageSync::WillModifyTexImage() { | |
| 110 } | |
| 111 | |
| 112 void GLImageSync::DidModifyTexImage() { | |
| 113 } | |
| 114 | |
| 115 bool GLImageSync::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | 106 bool GLImageSync::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, |
| 116 int z_order, | 107 int z_order, |
| 117 gfx::OverlayTransform transform, | 108 gfx::OverlayTransform transform, |
| 118 const gfx::Rect& bounds_rect, | 109 const gfx::Rect& bounds_rect, |
| 119 const gfx::RectF& crop_rect) { | 110 const gfx::RectF& crop_rect) { |
| 120 NOTREACHED(); | 111 NOTREACHED(); |
| 121 return false; | 112 return false; |
| 122 } | 113 } |
| 123 | 114 |
| 124 void GLImageSync::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, | 115 void GLImageSync::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 image_buffer_ = NativeImageBuffer::Create(texture->service_id()); | 341 image_buffer_ = NativeImageBuffer::Create(texture->service_id()); |
| 351 DCHECK(image_buffer_.get()); | 342 DCHECK(image_buffer_.get()); |
| 352 } | 343 } |
| 353 | 344 |
| 354 const Texture::FaceInfo& first_face = texture->face_infos_[0]; | 345 const Texture::FaceInfo& first_face = texture->face_infos_[0]; |
| 355 if (image_buffer_.get()) { | 346 if (image_buffer_.get()) { |
| 356 scoped_refptr<gfx::GLImage> gl_image( | 347 scoped_refptr<gfx::GLImage> gl_image( |
| 357 new GLImageSync(image_buffer_, | 348 new GLImageSync(image_buffer_, |
| 358 gfx::Size(first_face.level_infos[0].width, | 349 gfx::Size(first_face.level_infos[0].width, |
| 359 first_face.level_infos[0].height))); | 350 first_face.level_infos[0].height))); |
| 360 texture->SetLevelImage(NULL, target_, 0, gl_image.get()); | 351 texture->SetLevelImage(target_, 0, gl_image.get(), Texture::BOUND); |
| 361 } | 352 } |
| 362 | 353 |
| 363 const Texture::LevelInfo& level = first_face.level_infos[0]; | 354 const Texture::LevelInfo& level = first_face.level_infos[0]; |
| 364 level_info_ = LevelInfo(level.target, level.internal_format, level.width, | 355 level_info_ = LevelInfo(level.target, level.internal_format, level.width, |
| 365 level.height, level.depth, level.border, level.format, | 356 level.height, level.depth, level.border, level.format, |
| 366 level.type, level.cleared_rect); | 357 level.type, level.cleared_rect); |
| 367 } | 358 } |
| 368 | 359 |
| 369 TextureDefinition::~TextureDefinition() { | 360 TextureDefinition::~TextureDefinition() { |
| 370 } | 361 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 399 texture->face_infos_[0].level_infos.resize(1); | 390 texture->face_infos_[0].level_infos.resize(1); |
| 400 texture->SetLevelInfo(NULL, level_info_.target, 0, | 391 texture->SetLevelInfo(NULL, level_info_.target, 0, |
| 401 level_info_.internal_format, level_info_.width, | 392 level_info_.internal_format, level_info_.width, |
| 402 level_info_.height, level_info_.depth, | 393 level_info_.height, level_info_.depth, |
| 403 level_info_.border, level_info_.format, | 394 level_info_.border, level_info_.format, |
| 404 level_info_.type, level_info_.cleared_rect); | 395 level_info_.type, level_info_.cleared_rect); |
| 405 } | 396 } |
| 406 | 397 |
| 407 if (image_buffer_.get()) { | 398 if (image_buffer_.get()) { |
| 408 texture->SetLevelImage( | 399 texture->SetLevelImage( |
| 409 NULL, | 400 target_, 0, |
| 410 target_, | 401 new GLImageSync(image_buffer_, |
| 411 0, | 402 gfx::Size(level_info_.width, level_info_.height)), |
| 412 new GLImageSync( | 403 Texture::BOUND); |
| 413 image_buffer_, | |
| 414 gfx::Size(level_info_.width, level_info_.height))); | |
| 415 } | 404 } |
| 416 | 405 |
| 417 texture->target_ = target_; | 406 texture->target_ = target_; |
| 418 texture->SetImmutable(immutable_); | 407 texture->SetImmutable(immutable_); |
| 419 texture->min_filter_ = min_filter_; | 408 texture->min_filter_ = min_filter_; |
| 420 texture->mag_filter_ = mag_filter_; | 409 texture->mag_filter_ = mag_filter_; |
| 421 texture->wrap_s_ = wrap_s_; | 410 texture->wrap_s_ = wrap_s_; |
| 422 texture->wrap_t_ = wrap_t_; | 411 texture->wrap_t_ = wrap_t_; |
| 423 texture->usage_ = usage_; | 412 texture->usage_ = usage_; |
| 424 } | 413 } |
| 425 | 414 |
| 426 void TextureDefinition::UpdateTexture(Texture* texture) const { | 415 void TextureDefinition::UpdateTexture(Texture* texture) const { |
| 427 GLuint old_service_id = 0u; | 416 GLuint old_service_id = 0u; |
| 428 if (image_buffer_.get() && g_avoid_egl_target_texture_reuse) { | 417 if (image_buffer_.get() && g_avoid_egl_target_texture_reuse) { |
| 429 GLuint service_id = 0u; | 418 GLuint service_id = 0u; |
| 430 glGenTextures(1, &service_id); | 419 glGenTextures(1, &service_id); |
| 431 old_service_id = texture->service_id(); | 420 old_service_id = texture->service_id(); |
| 432 texture->SetServiceId(service_id); | 421 texture->SetServiceId(service_id); |
| 433 | 422 |
| 434 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), target_); | 423 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), target_); |
| 435 GLint bound_id = 0; | 424 GLint bound_id = 0; |
| 436 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_id); | 425 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_id); |
| 437 if (bound_id == static_cast<GLint>(old_service_id)) { | 426 if (bound_id == static_cast<GLint>(old_service_id)) { |
| 438 glBindTexture(target_, service_id); | 427 glBindTexture(target_, service_id); |
| 439 } | 428 } |
| 440 texture->SetLevelImage(NULL, target_, 0, NULL); | 429 texture->SetLevelImage(target_, 0, NULL, Texture::UNBOUND); |
| 441 } | 430 } |
| 442 | 431 |
| 443 UpdateTextureInternal(texture); | 432 UpdateTextureInternal(texture); |
| 444 | 433 |
| 445 if (old_service_id) { | 434 if (old_service_id) { |
| 446 glDeleteTextures(1, &old_service_id); | 435 glDeleteTextures(1, &old_service_id); |
| 447 } | 436 } |
| 448 } | 437 } |
| 449 | 438 |
| 450 bool TextureDefinition::Matches(const Texture* texture) const { | 439 bool TextureDefinition::Matches(const Texture* texture) const { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 468 return true; | 457 return true; |
| 469 } | 458 } |
| 470 | 459 |
| 471 bool TextureDefinition::SafeToRenderFrom() const { | 460 bool TextureDefinition::SafeToRenderFrom() const { |
| 472 return level_info_.cleared_rect.Contains( | 461 return level_info_.cleared_rect.Contains( |
| 473 gfx::Rect(level_info_.width, level_info_.height)); | 462 gfx::Rect(level_info_.width, level_info_.height)); |
| 474 } | 463 } |
| 475 | 464 |
| 476 } // namespace gles2 | 465 } // namespace gles2 |
| 477 } // namespace gpu | 466 } // namespace gpu |
| OLD | NEW |