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