| 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 "ui/gl/gl_image_surface_texture.h" | 5 #include "ui/gl/gl_image_surface_texture.h" |
| 6 | 6 |
| 7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
| 8 #include "ui/gl/android/surface_texture.h" | 8 #include "ui/gl/android/surface_texture.h" |
| 9 | 9 |
| 10 namespace gfx { | 10 namespace gfx { |
| 11 | 11 |
| 12 GLImageSurfaceTexture::GLImageSurfaceTexture(const gfx::Size& size) | 12 GLImageSurfaceTexture::GLImageSurfaceTexture(const Size& size) |
| 13 : size_(size), texture_id_(0) { | 13 : size_(size), texture_id_(0) {} |
| 14 } | |
| 15 | 14 |
| 16 GLImageSurfaceTexture::~GLImageSurfaceTexture() { | 15 GLImageSurfaceTexture::~GLImageSurfaceTexture() { |
| 17 DCHECK(thread_checker_.CalledOnValidThread()); | 16 DCHECK(thread_checker_.CalledOnValidThread()); |
| 18 DCHECK(!surface_texture_.get()); | 17 DCHECK(!surface_texture_.get()); |
| 19 DCHECK_EQ(0, texture_id_); | 18 DCHECK_EQ(0, texture_id_); |
| 20 } | 19 } |
| 21 | 20 |
| 22 bool GLImageSurfaceTexture::Initialize(SurfaceTexture* surface_texture) { | 21 bool GLImageSurfaceTexture::Initialize(SurfaceTexture* surface_texture) { |
| 23 DCHECK(thread_checker_.CalledOnValidThread()); | 22 DCHECK(thread_checker_.CalledOnValidThread()); |
| 24 DCHECK(!surface_texture_.get()); | 23 DCHECK(!surface_texture_.get()); |
| 25 surface_texture_ = surface_texture; | 24 surface_texture_ = surface_texture; |
| 26 return true; | 25 return true; |
| 27 } | 26 } |
| 28 | 27 |
| 29 void GLImageSurfaceTexture::Destroy(bool have_context) { | 28 void GLImageSurfaceTexture::Destroy(bool have_context) { |
| 30 DCHECK(thread_checker_.CalledOnValidThread()); | 29 DCHECK(thread_checker_.CalledOnValidThread()); |
| 31 surface_texture_ = NULL; | 30 surface_texture_ = NULL; |
| 32 texture_id_ = 0; | 31 texture_id_ = 0; |
| 33 } | 32 } |
| 34 | 33 |
| 35 gfx::Size GLImageSurfaceTexture::GetSize() { return size_; } | 34 Size GLImageSurfaceTexture::GetSize() { |
| 35 return size_; |
| 36 } |
| 36 | 37 |
| 37 unsigned GLImageSurfaceTexture::GetInternalFormat() { return GL_RGBA; } | 38 unsigned GLImageSurfaceTexture::GetInternalFormat() { return GL_RGBA; } |
| 38 | 39 |
| 39 bool GLImageSurfaceTexture::BindTexImage(unsigned target) { | 40 bool GLImageSurfaceTexture::BindTexImage(unsigned target) { |
| 40 TRACE_EVENT0("gpu", "GLImageSurfaceTexture::BindTexImage"); | 41 TRACE_EVENT0("gpu", "GLImageSurfaceTexture::BindTexImage"); |
| 41 DCHECK(thread_checker_.CalledOnValidThread()); | 42 DCHECK(thread_checker_.CalledOnValidThread()); |
| 42 | 43 |
| 43 if (target != GL_TEXTURE_EXTERNAL_OES) { | 44 if (target != GL_TEXTURE_EXTERNAL_OES) { |
| 44 LOG(ERROR) | 45 LOG(ERROR) |
| 45 << "Surface texture can only be bound to TEXTURE_EXTERNAL_OES target"; | 46 << "Surface texture can only be bound to TEXTURE_EXTERNAL_OES target"; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 71 // This will attach the surface texture to the texture currently bound to | 72 // This will attach the surface texture to the texture currently bound to |
| 72 // GL_TEXTURE_EXTERNAL_OES target. | 73 // GL_TEXTURE_EXTERNAL_OES target. |
| 73 surface_texture_->AttachToGLContext(); | 74 surface_texture_->AttachToGLContext(); |
| 74 texture_id_ = texture_id; | 75 texture_id_ = texture_id; |
| 75 } | 76 } |
| 76 | 77 |
| 77 surface_texture_->UpdateTexImage(); | 78 surface_texture_->UpdateTexImage(); |
| 78 return true; | 79 return true; |
| 79 } | 80 } |
| 80 | 81 |
| 82 bool GLImageSurfaceTexture::CopyTexImage(unsigned target) { |
| 83 return false; |
| 84 } |
| 85 |
| 81 bool GLImageSurfaceTexture::CopyTexSubImage(unsigned target, | 86 bool GLImageSurfaceTexture::CopyTexSubImage(unsigned target, |
| 82 const Point& offset, | 87 const Point& offset, |
| 83 const Rect& rect) { | 88 const Rect& rect) { |
| 84 return false; | 89 return false; |
| 85 } | 90 } |
| 86 | 91 |
| 87 bool GLImageSurfaceTexture::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, | 92 bool GLImageSurfaceTexture::ScheduleOverlayPlane(AcceleratedWidget widget, |
| 88 int z_order, | 93 int z_order, |
| 89 OverlayTransform transform, | 94 OverlayTransform transform, |
| 90 const Rect& bounds_rect, | 95 const Rect& bounds_rect, |
| 91 const RectF& crop_rect) { | 96 const RectF& crop_rect) { |
| 92 return false; | 97 return false; |
| 93 } | 98 } |
| 94 | 99 |
| 95 void GLImageSurfaceTexture::OnMemoryDump( | 100 void GLImageSurfaceTexture::OnMemoryDump( |
| 96 base::trace_event::ProcessMemoryDump* pmd, | 101 base::trace_event::ProcessMemoryDump* pmd, |
| 97 uint64_t process_tracing_id, | 102 uint64_t process_tracing_id, |
| 98 const std::string& dump_name) { | 103 const std::string& dump_name) { |
| 99 // TODO(ericrk): Add OnMemoryDump for GLImages. crbug.com/514914 | 104 // TODO(ericrk): Add OnMemoryDump for GLImages. crbug.com/514914 |
| 100 } | 105 } |
| 101 | 106 |
| 102 } // namespace gfx | 107 } // namespace gfx |
| OLD | NEW |