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