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

Side by Side Diff: cc/output/direct_renderer.cc

Issue 2399983003: cc: Make OutputSurface::Reshape abstract (Closed)
Patch Set: reshapeabstract: . Created 4 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
« no previous file with comments | « cc/output/direct_renderer.h ('k') | cc/output/gl_renderer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "cc/output/direct_renderer.h" 5 #include "cc/output/direct_renderer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <unordered_map> 9 #include <unordered_map>
10 #include <utility> 10 #include <utility>
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 RenderPass* root_render_pass = render_passes_in_draw_order->back().get(); 226 RenderPass* root_render_pass = render_passes_in_draw_order->back().get();
227 DCHECK(root_render_pass); 227 DCHECK(root_render_pass);
228 228
229 DrawingFrame frame; 229 DrawingFrame frame;
230 frame.render_passes_in_draw_order = render_passes_in_draw_order; 230 frame.render_passes_in_draw_order = render_passes_in_draw_order;
231 frame.root_render_pass = root_render_pass; 231 frame.root_render_pass = root_render_pass;
232 frame.root_damage_rect = root_render_pass->damage_rect; 232 frame.root_damage_rect = root_render_pass->damage_rect;
233 frame.root_damage_rect.Union(overlay_processor_->GetAndResetOverlayDamage()); 233 frame.root_damage_rect.Union(overlay_processor_->GetAndResetOverlayDamage());
234 frame.root_damage_rect.Intersect(gfx::Rect(device_viewport_size)); 234 frame.root_damage_rect.Intersect(gfx::Rect(device_viewport_size));
235 frame.device_viewport_size = device_viewport_size; 235 frame.device_viewport_size = device_viewport_size;
236 frame.device_color_space = device_color_space;
236 237
237 // Only reshape when we know we are going to draw. Otherwise, the reshape 238 // Only reshape when we know we are going to draw. Otherwise, the reshape
238 // can leave the window at the wrong size if we never draw and the proper 239 // can leave the window at the wrong size if we never draw and the proper
239 // viewport size is never set. 240 // viewport size is never set.
240 output_surface_->Reshape(device_viewport_size, device_scale_factor, 241 bool frame_has_alpha = frame.root_render_pass->has_transparent_background;
241 device_color_space, 242 if (device_viewport_size != reshape_surface_size_ ||
242 frame.root_render_pass->has_transparent_background); 243 device_scale_factor != reshape_device_scale_factor_ ||
243 surface_size_for_swap_buffers_ = device_viewport_size; 244 device_color_space != reshape_device_color_space_ ||
245 frame_has_alpha != reshape_has_alpha_) {
246 reshape_surface_size_ = device_viewport_size;
247 reshape_device_scale_factor_ = device_scale_factor;
248 reshape_device_color_space_ = device_color_space;
249 reshape_has_alpha_ = frame.root_render_pass->has_transparent_background;
250 output_surface_->Reshape(reshape_surface_size_,
251 reshape_device_scale_factor_,
252 reshape_device_color_space_, reshape_has_alpha_);
253 }
244 254
245 BeginDrawingFrame(&frame); 255 BeginDrawingFrame(&frame);
246 256
247 // Draw all non-root render passes except for the root render pass. 257 // Draw all non-root render passes except for the root render pass.
248 for (const auto& pass : *render_passes_in_draw_order) { 258 for (const auto& pass : *render_passes_in_draw_order) {
249 if (pass.get() == root_render_pass) 259 if (pass.get() == root_render_pass)
250 break; 260 break;
251 DrawRenderPassAndExecuteCopyRequests(&frame, pass.get()); 261 DrawRenderPassAndExecuteCopyRequests(&frame, pass.get());
252 } 262 }
253 263
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 return true; 545 return true;
536 } 546 }
537 547
538 ScopedResource* texture = render_pass_textures_[render_pass->id].get(); 548 ScopedResource* texture = render_pass_textures_[render_pass->id].get();
539 DCHECK(texture); 549 DCHECK(texture);
540 550
541 gfx::Size size = RenderPassTextureSize(render_pass); 551 gfx::Size size = RenderPassTextureSize(render_pass);
542 size.Enlarge(enlarge_pass_texture_amount_.width(), 552 size.Enlarge(enlarge_pass_texture_amount_.width(),
543 enlarge_pass_texture_amount_.height()); 553 enlarge_pass_texture_amount_.height());
544 if (!texture->id()) { 554 if (!texture->id()) {
545 texture->Allocate(size, 555 texture->Allocate(
546 ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER, 556 size, ResourceProvider::TEXTURE_HINT_IMMUTABLE_FRAMEBUFFER,
547 resource_provider_->best_texture_format(), 557 resource_provider_->best_texture_format(), frame->device_color_space);
548 output_surface_->device_color_space());
549 } 558 }
550 DCHECK(texture->id()); 559 DCHECK(texture->id());
551 560
552 if (BindFramebufferToTexture(frame, texture)) { 561 if (BindFramebufferToTexture(frame, texture)) {
553 InitializeViewport(frame, render_pass->output_rect, 562 InitializeViewport(frame, render_pass->output_rect,
554 gfx::Rect(render_pass->output_rect.size()), 563 gfx::Rect(render_pass->output_rect.size()),
555 texture->size()); 564 texture->size());
556 return true; 565 return true;
557 } 566 }
558 567
559 return false; 568 return false;
560 } 569 }
561 570
562 bool DirectRenderer::HasAllocatedResourcesForTesting(RenderPassId id) const { 571 bool DirectRenderer::HasAllocatedResourcesForTesting(RenderPassId id) const {
563 auto iter = render_pass_textures_.find(id); 572 auto iter = render_pass_textures_.find(id);
564 return iter != render_pass_textures_.end() && iter->second->id(); 573 return iter != render_pass_textures_.end() && iter->second->id();
565 } 574 }
566 575
567 // static 576 // static
568 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { 577 gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) {
569 return render_pass->output_rect.size(); 578 return render_pass->output_rect.size();
570 } 579 }
571 580
572 } // namespace cc 581 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/direct_renderer.h ('k') | cc/output/gl_renderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698