| 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 return false; |
| 96 } |
| 97 |
| 97 bool GLImageSync::CopyTexSubImage(unsigned target, | 98 bool GLImageSync::CopyTexSubImage(unsigned target, |
| 98 const gfx::Point& offset, | 99 const gfx::Point& offset, |
| 99 const gfx::Rect& rect) { | 100 const gfx::Rect& rect) { |
| 100 return false; | 101 return false; |
| 101 } | 102 } |
| 102 | 103 |
| 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, | 104 bool GLImageSync::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, |
| 116 int z_order, | 105 int z_order, |
| 117 gfx::OverlayTransform transform, | 106 gfx::OverlayTransform transform, |
| 118 const gfx::Rect& bounds_rect, | 107 const gfx::Rect& bounds_rect, |
| 119 const gfx::RectF& crop_rect) { | 108 const gfx::RectF& crop_rect) { |
| 120 NOTREACHED(); | 109 NOTREACHED(); |
| 121 return false; | 110 return false; |
| 122 } | 111 } |
| 123 | 112 |
| 124 void GLImageSync::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, | 113 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()); | 339 image_buffer_ = NativeImageBuffer::Create(texture->service_id()); |
| 351 DCHECK(image_buffer_.get()); | 340 DCHECK(image_buffer_.get()); |
| 352 } | 341 } |
| 353 | 342 |
| 354 const Texture::FaceInfo& first_face = texture->face_infos_[0]; | 343 const Texture::FaceInfo& first_face = texture->face_infos_[0]; |
| 355 if (image_buffer_.get()) { | 344 if (image_buffer_.get()) { |
| 356 scoped_refptr<gfx::GLImage> gl_image( | 345 scoped_refptr<gfx::GLImage> gl_image( |
| 357 new GLImageSync(image_buffer_, | 346 new GLImageSync(image_buffer_, |
| 358 gfx::Size(first_face.level_infos[0].width, | 347 gfx::Size(first_face.level_infos[0].width, |
| 359 first_face.level_infos[0].height))); | 348 first_face.level_infos[0].height))); |
| 360 texture->SetLevelImage(NULL, target_, 0, gl_image.get()); | 349 texture->SetLevelImage(target_, 0, gl_image.get(), Texture::BOUND); |
| 361 } | 350 } |
| 362 | 351 |
| 363 const Texture::LevelInfo& level = first_face.level_infos[0]; | 352 const Texture::LevelInfo& level = first_face.level_infos[0]; |
| 364 level_info_ = LevelInfo(level.target, level.internal_format, level.width, | 353 level_info_ = LevelInfo(level.target, level.internal_format, level.width, |
| 365 level.height, level.depth, level.border, level.format, | 354 level.height, level.depth, level.border, level.format, |
| 366 level.type, level.cleared_rect); | 355 level.type, level.cleared_rect); |
| 367 } | 356 } |
| 368 | 357 |
| 369 TextureDefinition::~TextureDefinition() { | 358 TextureDefinition::~TextureDefinition() { |
| 370 } | 359 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 399 texture->face_infos_[0].level_infos.resize(1); | 388 texture->face_infos_[0].level_infos.resize(1); |
| 400 texture->SetLevelInfo(NULL, level_info_.target, 0, | 389 texture->SetLevelInfo(NULL, level_info_.target, 0, |
| 401 level_info_.internal_format, level_info_.width, | 390 level_info_.internal_format, level_info_.width, |
| 402 level_info_.height, level_info_.depth, | 391 level_info_.height, level_info_.depth, |
| 403 level_info_.border, level_info_.format, | 392 level_info_.border, level_info_.format, |
| 404 level_info_.type, level_info_.cleared_rect); | 393 level_info_.type, level_info_.cleared_rect); |
| 405 } | 394 } |
| 406 | 395 |
| 407 if (image_buffer_.get()) { | 396 if (image_buffer_.get()) { |
| 408 texture->SetLevelImage( | 397 texture->SetLevelImage( |
| 409 NULL, | 398 target_, 0, |
| 410 target_, | 399 new GLImageSync(image_buffer_, |
| 411 0, | 400 gfx::Size(level_info_.width, level_info_.height)), |
| 412 new GLImageSync( | 401 Texture::BOUND); |
| 413 image_buffer_, | |
| 414 gfx::Size(level_info_.width, level_info_.height))); | |
| 415 } | 402 } |
| 416 | 403 |
| 417 texture->target_ = target_; | 404 texture->target_ = target_; |
| 418 texture->SetImmutable(immutable_); | 405 texture->SetImmutable(immutable_); |
| 419 texture->min_filter_ = min_filter_; | 406 texture->min_filter_ = min_filter_; |
| 420 texture->mag_filter_ = mag_filter_; | 407 texture->mag_filter_ = mag_filter_; |
| 421 texture->wrap_s_ = wrap_s_; | 408 texture->wrap_s_ = wrap_s_; |
| 422 texture->wrap_t_ = wrap_t_; | 409 texture->wrap_t_ = wrap_t_; |
| 423 texture->usage_ = usage_; | 410 texture->usage_ = usage_; |
| 424 } | 411 } |
| 425 | 412 |
| 426 void TextureDefinition::UpdateTexture(Texture* texture) const { | 413 void TextureDefinition::UpdateTexture(Texture* texture) const { |
| 427 GLuint old_service_id = 0u; | 414 GLuint old_service_id = 0u; |
| 428 if (image_buffer_.get() && g_avoid_egl_target_texture_reuse) { | 415 if (image_buffer_.get() && g_avoid_egl_target_texture_reuse) { |
| 429 GLuint service_id = 0u; | 416 GLuint service_id = 0u; |
| 430 glGenTextures(1, &service_id); | 417 glGenTextures(1, &service_id); |
| 431 old_service_id = texture->service_id(); | 418 old_service_id = texture->service_id(); |
| 432 texture->SetServiceId(service_id); | 419 texture->SetServiceId(service_id); |
| 433 | 420 |
| 434 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), target_); | 421 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), target_); |
| 435 GLint bound_id = 0; | 422 GLint bound_id = 0; |
| 436 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_id); | 423 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_id); |
| 437 if (bound_id == static_cast<GLint>(old_service_id)) { | 424 if (bound_id == static_cast<GLint>(old_service_id)) { |
| 438 glBindTexture(target_, service_id); | 425 glBindTexture(target_, service_id); |
| 439 } | 426 } |
| 440 texture->SetLevelImage(NULL, target_, 0, NULL); | 427 texture->SetLevelImage(target_, 0, NULL, Texture::UNBOUND); |
| 441 } | 428 } |
| 442 | 429 |
| 443 UpdateTextureInternal(texture); | 430 UpdateTextureInternal(texture); |
| 444 | 431 |
| 445 if (old_service_id) { | 432 if (old_service_id) { |
| 446 glDeleteTextures(1, &old_service_id); | 433 glDeleteTextures(1, &old_service_id); |
| 447 } | 434 } |
| 448 } | 435 } |
| 449 | 436 |
| 450 bool TextureDefinition::Matches(const Texture* texture) const { | 437 bool TextureDefinition::Matches(const Texture* texture) const { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 468 return true; | 455 return true; |
| 469 } | 456 } |
| 470 | 457 |
| 471 bool TextureDefinition::SafeToRenderFrom() const { | 458 bool TextureDefinition::SafeToRenderFrom() const { |
| 472 return level_info_.cleared_rect.Contains( | 459 return level_info_.cleared_rect.Contains( |
| 473 gfx::Rect(level_info_.width, level_info_.height)); | 460 gfx::Rect(level_info_.width, level_info_.height)); |
| 474 } | 461 } |
| 475 | 462 |
| 476 } // namespace gles2 | 463 } // namespace gles2 |
| 477 } // namespace gpu | 464 } // namespace gpu |
| OLD | NEW |