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