OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "services/ui/demo/bitmap_uploader.h" | 5 #include "services/ui/demo/bitmap_uploader.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 : window_(window), | 33 : window_(window), |
34 color_(g_transparent_color), | 34 color_(g_transparent_color), |
35 width_(0), | 35 width_(0), |
36 height_(0), | 36 height_(0), |
37 format_(BGRA), | 37 format_(BGRA), |
38 next_resource_id_(1u), | 38 next_resource_id_(1u), |
39 weak_factory_(this) {} | 39 weak_factory_(this) {} |
40 | 40 |
41 void BitmapUploader::Init(ui::GpuService* gpu_service) { | 41 void BitmapUploader::Init(ui::GpuService* gpu_service) { |
42 gpu_service->EstablishGpuChannel(base::Bind( | 42 gpu_service->EstablishGpuChannel(base::Bind( |
43 &BitmapUploader::OnGpuChannelEstablished, weak_factory_.GetWeakPtr())); | 43 &BitmapUploader::OnGpuChannelEstablished, weak_factory_.GetWeakPtr(), |
| 44 gpu_service->gpu_memory_buffer_manager())); |
44 } | 45 } |
45 | 46 |
46 BitmapUploader::~BitmapUploader() { | 47 BitmapUploader::~BitmapUploader() { |
47 compositor_frame_sink_->DetachFromClient(); | 48 compositor_frame_sink_->DetachFromClient(); |
48 } | 49 } |
49 | 50 |
50 // Sets the color which is RGBA. | 51 // Sets the color which is RGBA. |
51 void BitmapUploader::SetColor(uint32_t color) { | 52 void BitmapUploader::SetColor(uint32_t color) { |
52 if (color_ == color) | 53 if (color_ == color) |
53 return; | 54 return; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 force_antialiasing_off); | 167 force_antialiasing_off); |
167 } | 168 } |
168 | 169 |
169 frame.delegated_frame_data->render_pass_list.push_back(std::move(pass)); | 170 frame.delegated_frame_data->render_pass_list.push_back(std::move(pass)); |
170 | 171 |
171 // TODO(rjkroege, fsamuel): We should throttle frames. | 172 // TODO(rjkroege, fsamuel): We should throttle frames. |
172 compositor_frame_sink_->SubmitCompositorFrame(std::move(frame)); | 173 compositor_frame_sink_->SubmitCompositorFrame(std::move(frame)); |
173 } | 174 } |
174 | 175 |
175 void BitmapUploader::OnGpuChannelEstablished( | 176 void BitmapUploader::OnGpuChannelEstablished( |
| 177 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
176 scoped_refptr<gpu::GpuChannelHost> gpu_channel) { | 178 scoped_refptr<gpu::GpuChannelHost> gpu_channel) { |
177 compositor_frame_sink_ = window_->RequestCompositorFrameSink( | 179 compositor_frame_sink_ = window_->RequestCompositorFrameSink( |
178 mojom::CompositorFrameSinkType::DEFAULT, | 180 mojom::CompositorFrameSinkType::DEFAULT, |
179 new ContextProvider(std::move(gpu_channel))); | 181 new ContextProvider(std::move(gpu_channel)), gpu_memory_buffer_manager); |
180 compositor_frame_sink_->BindToClient(this); | 182 compositor_frame_sink_->BindToClient(this); |
181 } | 183 } |
182 | 184 |
183 uint32_t BitmapUploader::BindTextureForSize(const gfx::Size& size) { | 185 uint32_t BitmapUploader::BindTextureForSize(const gfx::Size& size) { |
184 gpu::gles2::GLES2Interface* gl = | 186 gpu::gles2::GLES2Interface* gl = |
185 compositor_frame_sink_->context_provider()->ContextGL(); | 187 compositor_frame_sink_->context_provider()->ContextGL(); |
186 // TODO(jamesr): Recycle textures. | 188 // TODO(jamesr): Recycle textures. |
187 GLuint texture = 0u; | 189 GLuint texture = 0u; |
188 gl->GenTextures(1, &texture); | 190 gl->GenTextures(1, &texture); |
189 gl->BindTexture(GL_TEXTURE_2D, texture); | 191 gl->BindTexture(GL_TEXTURE_2D, texture); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // TODO(fsamuel): Implement this. | 235 // TODO(fsamuel): Implement this. |
234 } | 236 } |
235 | 237 |
236 void BitmapUploader::SetExternalTilePriorityConstraints( | 238 void BitmapUploader::SetExternalTilePriorityConstraints( |
237 const gfx::Rect& viewport_rect, | 239 const gfx::Rect& viewport_rect, |
238 const gfx::Transform& transform) { | 240 const gfx::Transform& transform) { |
239 // TODO(fsamuel): Implement this. | 241 // TODO(fsamuel): Implement this. |
240 } | 242 } |
241 | 243 |
242 } // namespace ui | 244 } // namespace ui |
OLD | NEW |