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" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" |
12 #include "cc/ipc/compositor_frame.mojom.h" | 13 #include "cc/ipc/compositor_frame.mojom.h" |
13 #include "cc/quads/render_pass.h" | 14 #include "cc/quads/render_pass.h" |
14 #include "cc/quads/solid_color_draw_quad.h" | 15 #include "cc/quads/solid_color_draw_quad.h" |
15 #include "cc/quads/texture_draw_quad.h" | 16 #include "cc/quads/texture_draw_quad.h" |
16 #include "services/ui/public/cpp/gles2_context.h" | 17 #include "services/ui/public/cpp/gles2_context.h" |
17 #include "services/ui/public/cpp/gpu_service.h" | 18 #include "services/ui/public/cpp/gpu_service.h" |
18 #include "services/ui/public/cpp/window.h" | 19 #include "services/ui/public/cpp/window.h" |
19 #include "services/ui/public/cpp/window_surface.h" | 20 #include "services/ui/public/cpp/window_surface.h" |
20 | 21 |
21 namespace ui { | 22 namespace ui { |
(...skipping 14 matching lines...) Expand all Loading... |
36 format_(BGRA), | 37 format_(BGRA), |
37 next_resource_id_(1u) { | 38 next_resource_id_(1u) { |
38 } | 39 } |
39 | 40 |
40 void BitmapUploader::Init(ui::GpuService* gpu_service) { | 41 void BitmapUploader::Init(ui::GpuService* gpu_service) { |
41 surface_ = window_->RequestSurface(mojom::SurfaceType::DEFAULT); | 42 surface_ = window_->RequestSurface(mojom::SurfaceType::DEFAULT); |
42 surface_->BindToThread(); | 43 surface_->BindToThread(); |
43 surface_->set_client(this); | 44 surface_->set_client(this); |
44 | 45 |
45 gles2_context_ = GLES2Context::CreateOffscreenContext( | 46 gles2_context_ = GLES2Context::CreateOffscreenContext( |
46 gpu_service->EstablishGpuChannelSync()); | 47 gpu_service->EstablishGpuChannelSync(), |
| 48 base::ThreadTaskRunnerHandle::Get()); |
47 } | 49 } |
48 | 50 |
49 BitmapUploader::~BitmapUploader() {} | 51 BitmapUploader::~BitmapUploader() {} |
50 | 52 |
51 // Sets the color which is RGBA. | 53 // Sets the color which is RGBA. |
52 void BitmapUploader::SetColor(uint32_t color) { | 54 void BitmapUploader::SetColor(uint32_t color) { |
53 if (color_ == color) | 55 if (color_ == color) |
54 return; | 56 return; |
55 color_ = color; | 57 color_ = color; |
56 if (surface_) | 58 if (surface_) |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 DCHECK_EQ(1, resource.count); | 196 DCHECK_EQ(1, resource.count); |
195 gl->WaitSyncTokenCHROMIUM(resource.sync_token.GetConstData()); | 197 gl->WaitSyncTokenCHROMIUM(resource.sync_token.GetConstData()); |
196 uint32_t texture_id = resource_to_texture_id_map_[resource.id]; | 198 uint32_t texture_id = resource_to_texture_id_map_[resource.id]; |
197 DCHECK_NE(0u, texture_id); | 199 DCHECK_NE(0u, texture_id); |
198 resource_to_texture_id_map_.erase(resource.id); | 200 resource_to_texture_id_map_.erase(resource.id); |
199 gl->DeleteTextures(1, &texture_id); | 201 gl->DeleteTextures(1, &texture_id); |
200 } | 202 } |
201 } | 203 } |
202 | 204 |
203 } // namespace ui | 205 } // namespace ui |
OLD | NEW |