| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 void BitmapUploader::Upload() { | 73 void BitmapUploader::Upload() { |
| 74 if (!compositor_frame_sink_ || !compositor_frame_sink_->context_provider()) | 74 if (!compositor_frame_sink_ || !compositor_frame_sink_->context_provider()) |
| 75 return; | 75 return; |
| 76 | 76 |
| 77 const gfx::Rect bounds(window_->bounds().size()); | 77 const gfx::Rect bounds(window_->bounds().size()); |
| 78 | 78 |
| 79 cc::CompositorFrame frame; | 79 cc::CompositorFrame frame; |
| 80 // TODO(rjkroege): Support device scale factors other than 1. | 80 // TODO(rjkroege): Support device scale factors other than 1. |
| 81 frame.metadata.device_scale_factor = 1.0f; | 81 frame.metadata.device_scale_factor = 1.0f; |
| 82 frame.delegated_frame_data.reset(new cc::DelegatedFrameData()); | 82 frame.resource_list.resize(0u); |
| 83 frame.delegated_frame_data->resource_list.resize(0u); | |
| 84 | 83 |
| 85 const cc::RenderPassId render_pass_id(1, 1); | 84 const cc::RenderPassId render_pass_id(1, 1); |
| 86 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); | 85 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); |
| 87 pass->SetAll(render_pass_id, bounds, bounds, gfx::Transform(), | 86 pass->SetAll(render_pass_id, bounds, bounds, gfx::Transform(), |
| 88 true /* has_transparent_background */); | 87 true /* has_transparent_background */); |
| 89 | 88 |
| 90 // The SharedQuadState is owned by the SharedQuadStateList | 89 // The SharedQuadState is owned by the SharedQuadStateList |
| 91 // shared_quad_state_list. | 90 // shared_quad_state_list. |
| 92 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 91 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
| 93 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, | 92 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 117 resource.id = next_resource_id_++; | 116 resource.id = next_resource_id_++; |
| 118 resource_to_texture_id_map_[resource.id] = texture_id; | 117 resource_to_texture_id_map_[resource.id] = texture_id; |
| 119 resource.format = cc::ResourceFormat::RGBA_8888; | 118 resource.format = cc::ResourceFormat::RGBA_8888; |
| 120 resource.filter = GL_LINEAR; | 119 resource.filter = GL_LINEAR; |
| 121 resource.size = bitmap_size; | 120 resource.size = bitmap_size; |
| 122 resource.mailbox_holder = | 121 resource.mailbox_holder = |
| 123 gpu::MailboxHolder(mailbox, sync_token, GL_TEXTURE_2D); | 122 gpu::MailboxHolder(mailbox, sync_token, GL_TEXTURE_2D); |
| 124 resource.read_lock_fences_enabled = false; | 123 resource.read_lock_fences_enabled = false; |
| 125 resource.is_software = false; | 124 resource.is_software = false; |
| 126 resource.is_overlay_candidate = false; | 125 resource.is_overlay_candidate = false; |
| 127 frame.delegated_frame_data->resource_list.push_back(std::move(resource)); | 126 frame.resource_list.push_back(std::move(resource)); |
| 128 | 127 |
| 129 cc::TextureDrawQuad* quad = | 128 cc::TextureDrawQuad* quad = |
| 130 pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); | 129 pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); |
| 131 | 130 |
| 132 gfx::Size rect_size; | 131 gfx::Size rect_size; |
| 133 if (width_ <= bounds.width() && height_ <= bounds.height()) { | 132 if (width_ <= bounds.width() && height_ <= bounds.height()) { |
| 134 rect_size.SetSize(width_, height_); | 133 rect_size.SetSize(width_, height_); |
| 135 } else { | 134 } else { |
| 136 // The source bitmap is larger than the viewport. Resize it while | 135 // The source bitmap is larger than the viewport. Resize it while |
| 137 // maintaining the aspect ratio. | 136 // maintaining the aspect ratio. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 160 if (color_ != g_transparent_color) { | 159 if (color_ != g_transparent_color) { |
| 161 cc::SolidColorDrawQuad* quad = | 160 cc::SolidColorDrawQuad* quad = |
| 162 pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); | 161 pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); |
| 163 const bool force_antialiasing_off = false; | 162 const bool force_antialiasing_off = false; |
| 164 const gfx::Rect opaque_rect(0, 0, 0, 0); | 163 const gfx::Rect opaque_rect(0, 0, 0, 0); |
| 165 const bool needs_blending = true; | 164 const bool needs_blending = true; |
| 166 quad->SetAll(sqs, bounds, opaque_rect, bounds, needs_blending, color_, | 165 quad->SetAll(sqs, bounds, opaque_rect, bounds, needs_blending, color_, |
| 167 force_antialiasing_off); | 166 force_antialiasing_off); |
| 168 } | 167 } |
| 169 | 168 |
| 170 frame.delegated_frame_data->render_pass_list.push_back(std::move(pass)); | 169 frame.render_pass_list.push_back(std::move(pass)); |
| 171 | 170 |
| 172 // TODO(rjkroege, fsamuel): We should throttle frames. | 171 // TODO(rjkroege, fsamuel): We should throttle frames. |
| 173 compositor_frame_sink_->SubmitCompositorFrame(std::move(frame)); | 172 compositor_frame_sink_->SubmitCompositorFrame(std::move(frame)); |
| 174 } | 173 } |
| 175 | 174 |
| 176 void BitmapUploader::OnGpuChannelEstablished( | 175 void BitmapUploader::OnGpuChannelEstablished( |
| 177 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 176 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 178 scoped_refptr<gpu::GpuChannelHost> gpu_channel) { | 177 scoped_refptr<gpu::GpuChannelHost> gpu_channel) { |
| 179 compositor_frame_sink_ = window_->RequestCompositorFrameSink( | 178 compositor_frame_sink_ = window_->RequestCompositorFrameSink( |
| 180 mojom::CompositorFrameSinkType::DEFAULT, | 179 mojom::CompositorFrameSinkType::DEFAULT, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 // TODO(fsamuel): Implement this. | 234 // TODO(fsamuel): Implement this. |
| 236 } | 235 } |
| 237 | 236 |
| 238 void BitmapUploader::SetExternalTilePriorityConstraints( | 237 void BitmapUploader::SetExternalTilePriorityConstraints( |
| 239 const gfx::Rect& viewport_rect, | 238 const gfx::Rect& viewport_rect, |
| 240 const gfx::Transform& transform) { | 239 const gfx::Transform& transform) { |
| 241 // TODO(fsamuel): Implement this. | 240 // TODO(fsamuel): Implement this. |
| 242 } | 241 } |
| 243 | 242 |
| 244 } // namespace ui | 243 } // namespace ui |
| OLD | NEW |