Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: gpu/command_buffer/service/stream_texture_manager_in_process_android.cc

Issue 1418603002: Revert of Re-land: ui: Move GLImage::BindTexImage fallback from GLImage implementations to GLES2CmdDecoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/stream_texture_manager_in_process_android.h " 5 #include "gpu/command_buffer/service/stream_texture_manager_in_process_android.h "
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "gpu/command_buffer/service/texture_manager.h" 9 #include "gpu/command_buffer/service/texture_manager.h"
10 #include "ui/gfx/geometry/size.h" 10 #include "ui/gfx/geometry/size.h"
11 #include "ui/gl/android/surface_texture.h" 11 #include "ui/gl/android/surface_texture.h"
12 #include "ui/gl/gl_bindings.h" 12 #include "ui/gl/gl_bindings.h"
13 #include "ui/gl/gl_image.h" 13 #include "ui/gl/gl_image.h"
14 14
15 namespace gpu { 15 namespace gpu {
16 16
17 namespace { 17 namespace {
18 18
19 // Simply wraps a SurfaceTexture reference as a GLImage. 19 // Simply wraps a SurfaceTexture reference as a GLImage.
20 class GLImageImpl : public gfx::GLImage { 20 class GLImageImpl : public gfx::GLImage {
21 public: 21 public:
22 GLImageImpl(uint32 texture_id, 22 GLImageImpl(const scoped_refptr<gfx::SurfaceTexture>& surface_texture,
23 gles2::TextureManager* texture_manager,
24 const scoped_refptr<gfx::SurfaceTexture>& surface_texture,
25 const base::Closure& release_callback); 23 const base::Closure& release_callback);
26 24
27 // implement gfx::GLImage 25 // implement gfx::GLImage
28 void Destroy(bool have_context) override; 26 void Destroy(bool have_context) override;
29 gfx::Size GetSize() override; 27 gfx::Size GetSize() override;
30 unsigned GetInternalFormat() override; 28 unsigned GetInternalFormat() override;
31 bool BindTexImage(unsigned target) override; 29 bool BindTexImage(unsigned target) override;
32 void ReleaseTexImage(unsigned target) override; 30 void ReleaseTexImage(unsigned target) override;
33 bool CopyTexImage(unsigned target) override;
34 bool CopyTexSubImage(unsigned target, 31 bool CopyTexSubImage(unsigned target,
35 const gfx::Point& offset, 32 const gfx::Point& offset,
36 const gfx::Rect& rect) override; 33 const gfx::Rect& rect) override;
34 void WillUseTexImage() override;
35 void DidUseTexImage() override {}
36 void WillModifyTexImage() override {}
37 void DidModifyTexImage() override {}
37 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget, 38 bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
38 int z_order, 39 int z_order,
39 gfx::OverlayTransform transform, 40 gfx::OverlayTransform transform,
40 const gfx::Rect& bounds_rect, 41 const gfx::Rect& bounds_rect,
41 const gfx::RectF& crop_rect) override; 42 const gfx::RectF& crop_rect) override;
42 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, 43 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
43 uint64_t process_tracing_id, 44 uint64_t process_tracing_id,
44 const std::string& dump_name) override; 45 const std::string& dump_name) override;
45 46
46 private: 47 private:
47 ~GLImageImpl() override; 48 ~GLImageImpl() override;
48 49
49 uint32 texture_id_;
50 gles2::TextureManager* texture_manager_;
51 scoped_refptr<gfx::SurfaceTexture> surface_texture_; 50 scoped_refptr<gfx::SurfaceTexture> surface_texture_;
52 base::Closure release_callback_; 51 base::Closure release_callback_;
53 52
54 DISALLOW_COPY_AND_ASSIGN(GLImageImpl); 53 DISALLOW_COPY_AND_ASSIGN(GLImageImpl);
55 }; 54 };
56 55
57 GLImageImpl::GLImageImpl( 56 GLImageImpl::GLImageImpl(
58 uint32 texture_id,
59 gles2::TextureManager* texture_manager,
60 const scoped_refptr<gfx::SurfaceTexture>& surface_texture, 57 const scoped_refptr<gfx::SurfaceTexture>& surface_texture,
61 const base::Closure& release_callback) 58 const base::Closure& release_callback)
62 : texture_id_(texture_id), 59 : surface_texture_(surface_texture), release_callback_(release_callback) {}
63 texture_manager_(texture_manager),
64 surface_texture_(surface_texture),
65 release_callback_(release_callback) {}
66 60
67 GLImageImpl::~GLImageImpl() { 61 GLImageImpl::~GLImageImpl() {
68 release_callback_.Run(); 62 release_callback_.Run();
69 } 63 }
70 64
71 void GLImageImpl::Destroy(bool have_context) { 65 void GLImageImpl::Destroy(bool have_context) {
72 NOTREACHED(); 66 NOTREACHED();
73 } 67 }
74 68
75 gfx::Size GLImageImpl::GetSize() { 69 gfx::Size GLImageImpl::GetSize() {
76 return gfx::Size(); 70 return gfx::Size();
77 } 71 }
78 72
79 unsigned GLImageImpl::GetInternalFormat() { 73 unsigned GLImageImpl::GetInternalFormat() {
80 return GL_RGBA; 74 return GL_RGBA;
81 } 75 }
82 76
83 bool GLImageImpl::BindTexImage(unsigned target) { 77 bool GLImageImpl::BindTexImage(unsigned target) {
84 NOTREACHED(); 78 NOTREACHED();
85 return false; 79 return false;
86 } 80 }
87 81
88 void GLImageImpl::ReleaseTexImage(unsigned target) { 82 void GLImageImpl::ReleaseTexImage(unsigned target) {
89 NOTREACHED(); 83 NOTREACHED();
90 } 84 }
91 85
92 bool GLImageImpl::CopyTexImage(unsigned target) {
93 surface_texture_->UpdateTexImage();
94
95 gles2::Texture* texture =
96 texture_manager_->GetTextureForServiceId(texture_id_);
97 if (texture) {
98 // By setting image state to UNBOUND instead of COPIED we ensure that
99 // CopyTexImage() is called each time the surface texture is used for
100 // drawing.
101 texture->SetLevelImage(GL_TEXTURE_EXTERNAL_OES, 0, this,
102 gles2::Texture::UNBOUND);
103 }
104 return true;
105 }
106
107 bool GLImageImpl::CopyTexSubImage(unsigned target, 86 bool GLImageImpl::CopyTexSubImage(unsigned target,
108 const gfx::Point& offset, 87 const gfx::Point& offset,
109 const gfx::Rect& rect) { 88 const gfx::Rect& rect) {
110 return false; 89 return false;
111 } 90 }
112 91
92 void GLImageImpl::WillUseTexImage() {
93 surface_texture_->UpdateTexImage();
94 }
95
113 bool GLImageImpl::ScheduleOverlayPlane(gfx::AcceleratedWidget widget, 96 bool GLImageImpl::ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
114 int z_order, 97 int z_order,
115 gfx::OverlayTransform transform, 98 gfx::OverlayTransform transform,
116 const gfx::Rect& bounds_rect, 99 const gfx::Rect& bounds_rect,
117 const gfx::RectF& crop_rect) { 100 const gfx::RectF& crop_rect) {
118 NOTREACHED(); 101 NOTREACHED();
119 return false; 102 return false;
120 } 103 }
121 104
122 void GLImageImpl::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, 105 void GLImageImpl::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
(...skipping 26 matching lines...) Expand all
149 return 0; 132 return 0;
150 } 133 }
151 134
152 scoped_refptr<gfx::SurfaceTexture> surface_texture( 135 scoped_refptr<gfx::SurfaceTexture> surface_texture(
153 gfx::SurfaceTexture::Create(texture->service_id())); 136 gfx::SurfaceTexture::Create(texture->service_id()));
154 137
155 uint32 stream_id = next_id_++; 138 uint32 stream_id = next_id_++;
156 base::Closure release_callback = 139 base::Closure release_callback =
157 base::Bind(&StreamTextureManagerInProcess::OnReleaseStreamTexture, 140 base::Bind(&StreamTextureManagerInProcess::OnReleaseStreamTexture,
158 weak_factory_.GetWeakPtr(), stream_id); 141 weak_factory_.GetWeakPtr(), stream_id);
159 scoped_refptr<gfx::GLImage> gl_image( 142 scoped_refptr<gfx::GLImage> gl_image(new GLImageImpl(surface_texture,
160 new GLImageImpl(texture->service_id(), texture_manager, surface_texture, 143 release_callback));
161 release_callback));
162 144
163 gfx::Size size = gl_image->GetSize(); 145 gfx::Size size = gl_image->GetSize();
164 texture_manager->SetTarget(texture, GL_TEXTURE_EXTERNAL_OES); 146 texture_manager->SetTarget(texture, GL_TEXTURE_EXTERNAL_OES);
165 texture_manager->SetLevelInfo(texture, GL_TEXTURE_EXTERNAL_OES, 0, GL_RGBA, 147 texture_manager->SetLevelInfo(texture, GL_TEXTURE_EXTERNAL_OES, 0, GL_RGBA,
166 size.width(), size.height(), 1, 0, GL_RGBA, 148 size.width(), size.height(), 1, 0, GL_RGBA,
167 GL_UNSIGNED_BYTE, gfx::Rect(size)); 149 GL_UNSIGNED_BYTE, gfx::Rect(size));
168 texture_manager->SetLevelImage(texture, GL_TEXTURE_EXTERNAL_OES, 0, 150 texture_manager->SetLevelImage(
169 gl_image.get(), gles2::Texture::UNBOUND); 151 texture, GL_TEXTURE_EXTERNAL_OES, 0, gl_image.get());
170 152
171 { 153 {
172 base::AutoLock lock(map_lock_); 154 base::AutoLock lock(map_lock_);
173 textures_[stream_id] = surface_texture; 155 textures_[stream_id] = surface_texture;
174 } 156 }
175 157
176 if (next_id_ == 0) 158 if (next_id_ == 0)
177 next_id_++; 159 next_id_++;
178 160
179 return stream_id; 161 return stream_id;
(...skipping 10 matching lines...) Expand all
190 StreamTextureManagerInProcess::GetSurfaceTexture(uint32 stream_id) { 172 StreamTextureManagerInProcess::GetSurfaceTexture(uint32 stream_id) {
191 base::AutoLock lock(map_lock_); 173 base::AutoLock lock(map_lock_);
192 TextureMap::const_iterator it = textures_.find(stream_id); 174 TextureMap::const_iterator it = textures_.find(stream_id);
193 if (it != textures_.end()) 175 if (it != textures_.end())
194 return it->second; 176 return it->second;
195 177
196 return NULL; 178 return NULL;
197 } 179 }
198 180
199 } // namespace gpu 181 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/mailbox_manager_sync.cc ('k') | gpu/command_buffer/service/texture_definition.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698