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

Side by Side Diff: services/ui/demo/bitmap_uploader.cc

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

Powered by Google App Engine
This is Rietveld 408576698