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

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 22313011: (not for review) Add overhang resource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_wrap_mode
Patch Set: Created 7 years, 4 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/trees/layer_tree_host_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 19 matching lines...) Expand all
30 #include "cc/layers/render_surface_impl.h" 30 #include "cc/layers/render_surface_impl.h"
31 #include "cc/layers/scrollbar_layer_impl.h" 31 #include "cc/layers/scrollbar_layer_impl.h"
32 #include "cc/output/compositor_frame_metadata.h" 32 #include "cc/output/compositor_frame_metadata.h"
33 #include "cc/output/copy_output_request.h" 33 #include "cc/output/copy_output_request.h"
34 #include "cc/output/delegating_renderer.h" 34 #include "cc/output/delegating_renderer.h"
35 #include "cc/output/gl_renderer.h" 35 #include "cc/output/gl_renderer.h"
36 #include "cc/output/software_renderer.h" 36 #include "cc/output/software_renderer.h"
37 #include "cc/quads/render_pass_draw_quad.h" 37 #include "cc/quads/render_pass_draw_quad.h"
38 #include "cc/quads/shared_quad_state.h" 38 #include "cc/quads/shared_quad_state.h"
39 #include "cc/quads/solid_color_draw_quad.h" 39 #include "cc/quads/solid_color_draw_quad.h"
40 #include "cc/quads/texture_draw_quad.h"
40 #include "cc/resources/memory_history.h" 41 #include "cc/resources/memory_history.h"
41 #include "cc/resources/picture_layer_tiling.h" 42 #include "cc/resources/picture_layer_tiling.h"
42 #include "cc/resources/prioritized_resource_manager.h" 43 #include "cc/resources/prioritized_resource_manager.h"
43 #include "cc/resources/ui_resource_bitmap.h" 44 #include "cc/resources/ui_resource_bitmap.h"
44 #include "cc/scheduler/delay_based_time_source.h" 45 #include "cc/scheduler/delay_based_time_source.h"
45 #include "cc/scheduler/texture_uploader.h" 46 #include "cc/scheduler/texture_uploader.h"
46 #include "cc/trees/damage_tracker.h" 47 #include "cc/trees/damage_tracker.h"
47 #include "cc/trees/layer_tree_host.h" 48 #include "cc/trees/layer_tree_host.h"
48 #include "cc/trees/layer_tree_host_common.h" 49 #include "cc/trees/layer_tree_host_common.h"
49 #include "cc/trees/layer_tree_impl.h" 50 #include "cc/trees/layer_tree_impl.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 paint_time_counter_(PaintTimeCounter::Create()), 191 paint_time_counter_(PaintTimeCounter::Create()),
191 memory_history_(MemoryHistory::Create()), 192 memory_history_(MemoryHistory::Create()),
192 debug_rect_history_(DebugRectHistory::Create()), 193 debug_rect_history_(DebugRectHistory::Create()),
193 max_memory_needed_bytes_(0), 194 max_memory_needed_bytes_(0),
194 last_sent_memory_visible_bytes_(0), 195 last_sent_memory_visible_bytes_(0),
195 last_sent_memory_visible_and_nearby_bytes_(0), 196 last_sent_memory_visible_and_nearby_bytes_(0),
196 last_sent_memory_use_bytes_(0), 197 last_sent_memory_use_bytes_(0),
197 zero_budget_(false), 198 zero_budget_(false),
198 device_scale_factor_(1.f), 199 device_scale_factor_(1.f),
199 overdraw_bottom_height_(0.f), 200 overdraw_bottom_height_(0.f),
201 overhang_ui_resource_id_(0),
202 overhang_image_size_(0, 0),
200 external_stencil_test_enabled_(false), 203 external_stencil_test_enabled_(false),
201 animation_registrar_(AnimationRegistrar::Create()), 204 animation_registrar_(AnimationRegistrar::Create()),
202 rendering_stats_instrumentation_(rendering_stats_instrumentation), 205 rendering_stats_instrumentation_(rendering_stats_instrumentation),
203 need_to_update_visible_tiles_before_draw_(false) { 206 need_to_update_visible_tiles_before_draw_(false) {
204 DCHECK(proxy_->IsImplThread()); 207 DCHECK(proxy_->IsImplThread());
205 DidVisibilityChange(this, visible_); 208 DidVisibilityChange(this, visible_);
206 209
207 SetDebugState(settings.initial_debug_state); 210 SetDebugState(settings.initial_debug_state);
208 211
209 if (settings.calculate_top_controls_position) { 212 if (settings.calculate_top_controls_position) {
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 append_quads_data, 499 append_quads_data,
497 is_replica, 500 is_replica,
498 contributing_render_pass->id); 501 contributing_render_pass->id);
499 } 502 }
500 } 503 }
501 504
502 static void AppendQuadsToFillScreen( 505 static void AppendQuadsToFillScreen(
503 RenderPass* target_render_pass, 506 RenderPass* target_render_pass,
504 LayerImpl* root_layer, 507 LayerImpl* root_layer,
505 SkColor screen_background_color, 508 SkColor screen_background_color,
506 const OcclusionTrackerImpl& occlusion_tracker) { 509 const OcclusionTrackerImpl& occlusion_tracker,
510 ResourceProvider::ResourceId overhang_resource_id,
511 gfx::Size overhang_image_size) {
507 if (!root_layer || !SkColorGetA(screen_background_color)) 512 if (!root_layer || !SkColorGetA(screen_background_color))
508 return; 513 return;
509 514
510 Region fill_region = occlusion_tracker.ComputeVisibleRegionInScreen(); 515 Region fill_region = occlusion_tracker.ComputeVisibleRegionInScreen();
511 if (fill_region.IsEmpty()) 516 if (fill_region.IsEmpty())
512 return; 517 return;
513 518
514 bool for_surface = false; 519 bool for_surface = false;
515 QuadCuller quad_culler(&target_render_pass->quad_list, 520 QuadCuller quad_culler(&target_render_pass->quad_list,
516 &target_render_pass->shared_quad_state_list, 521 &target_render_pass->shared_quad_state_list,
(...skipping 26 matching lines...) Expand all
543 DCHECK(did_invert); 548 DCHECK(did_invert);
544 for (Region::Iterator fill_rects(fill_region); 549 for (Region::Iterator fill_rects(fill_region);
545 fill_rects.has_rect(); 550 fill_rects.has_rect();
546 fill_rects.next()) { 551 fill_rects.next()) {
547 // The root layer transform is composed of translations and scales only, 552 // The root layer transform is composed of translations and scales only,
548 // no perspective, so mapping is sufficient (as opposed to projecting). 553 // no perspective, so mapping is sufficient (as opposed to projecting).
549 gfx::Rect layer_rect = 554 gfx::Rect layer_rect =
550 MathUtil::MapClippedRect(transform_to_layer_space, fill_rects.rect()); 555 MathUtil::MapClippedRect(transform_to_layer_space, fill_rects.rect());
551 // Skip the quad culler and just append the quads directly to avoid 556 // Skip the quad culler and just append the quads directly to avoid
552 // occlusion checks. 557 // occlusion checks.
553 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); 558 if (overhang_resource_id) {
554 quad->SetNew(shared_quad_state, layer_rect, screen_background_color, false); 559 scoped_ptr<TextureDrawQuad> tex_quad = TextureDrawQuad::Create();
555 quad_culler.Append(quad.PassAs<DrawQuad>(), &append_quads_data); 560 const float vertex_opacity[4] = {1.f, 1.f, 1.f, 1.f};
561 tex_quad->SetNew(
562 shared_quad_state,
563 layer_rect,
564 layer_rect,
565 overhang_resource_id,
566 false,
567 gfx::PointF(
568 layer_rect.x() /
569 static_cast<float>(overhang_image_size.width()),
570 layer_rect.y() /
571 static_cast<float>(overhang_image_size.height())),
572 gfx::PointF(
573 (layer_rect.x() + layer_rect.width()) /
574 static_cast<float>(overhang_image_size.width()),
575 (layer_rect.y() + layer_rect.height()) /
576 static_cast<float>(overhang_image_size.height())),
577 screen_background_color,
578 vertex_opacity,
579 false);
580 quad_culler.Append(tex_quad.PassAs<DrawQuad>(), &append_quads_data);
581 } else {
582 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
583 quad->SetNew(
584 shared_quad_state, layer_rect, screen_background_color, false);
585 quad_culler.Append(quad.PassAs<DrawQuad>(), &append_quads_data);
586 }
556 } 587 }
557 } 588 }
558 589
559 bool LayerTreeHostImpl::CalculateRenderPasses(FrameData* frame) { 590 bool LayerTreeHostImpl::CalculateRenderPasses(FrameData* frame) {
560 DCHECK(frame->render_passes.empty()); 591 DCHECK(frame->render_passes.empty());
561 592
562 if (!CanDraw() || !active_tree_->root_layer()) 593 if (!CanDraw() || !active_tree_->root_layer())
563 return false; 594 return false;
564 595
565 TrackDamageForAllSurfaces(active_tree_->root_layer(), 596 TrackDamageForAllSurfaces(active_tree_->root_layer(),
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 != frame->render_passes_by_id.end()); 791 != frame->render_passes_by_id.end());
761 } 792 }
762 #endif 793 #endif
763 DCHECK(frame->render_passes.back()->output_rect.origin().IsOrigin()); 794 DCHECK(frame->render_passes.back()->output_rect.origin().IsOrigin());
764 795
765 if (!active_tree_->has_transparent_background()) { 796 if (!active_tree_->has_transparent_background()) {
766 frame->render_passes.back()->has_transparent_background = false; 797 frame->render_passes.back()->has_transparent_background = false;
767 AppendQuadsToFillScreen(frame->render_passes.back(), 798 AppendQuadsToFillScreen(frame->render_passes.back(),
768 active_tree_->root_layer(), 799 active_tree_->root_layer(),
769 active_tree_->background_color(), 800 active_tree_->background_color(),
770 occlusion_tracker); 801 occlusion_tracker,
802 ResourceIdForUIResource(overhang_ui_resource_id_),
803 overhang_image_size_);
771 } 804 }
772 805
773 if (draw_frame) 806 if (draw_frame)
774 occlusion_tracker.overdraw_metrics()->RecordMetrics(this); 807 occlusion_tracker.overdraw_metrics()->RecordMetrics(this);
775 else 808 else
776 DCHECK(!have_copy_request); 809 DCHECK(!have_copy_request);
777 810
778 RemoveRenderPasses(CullRenderPassesWithNoQuads(), frame); 811 RemoveRenderPasses(CullRenderPassesWithNoQuads(), frame);
779 if (!output_surface_->ForcedDrawToSoftwareDevice()) 812 if (!output_surface_->ForcedDrawToSoftwareDevice())
780 renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes); 813 renderer_->DecideRenderPassAllocationsForFrame(frame->render_passes);
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 1764
1732 void LayerTreeHostImpl::SetOverdrawBottomHeight(float overdraw_bottom_height) { 1765 void LayerTreeHostImpl::SetOverdrawBottomHeight(float overdraw_bottom_height) {
1733 if (overdraw_bottom_height == overdraw_bottom_height_) 1766 if (overdraw_bottom_height == overdraw_bottom_height_)
1734 return; 1767 return;
1735 overdraw_bottom_height_ = overdraw_bottom_height; 1768 overdraw_bottom_height_ = overdraw_bottom_height;
1736 1769
1737 UpdateMaxScrollOffset(); 1770 UpdateMaxScrollOffset();
1738 SetFullRootLayerDamage(); 1771 SetFullRootLayerDamage();
1739 } 1772 }
1740 1773
1774 void LayerTreeHostImpl::SetOverhangUIResource(
1775 UIResourceId overhang_ui_resource_id, gfx::Size overhang_image_size) {
1776 overhang_ui_resource_id_ = overhang_ui_resource_id;
1777 overhang_image_size_ = overhang_image_size;
1778 }
1779
1741 void LayerTreeHostImpl::SetDeviceScaleFactor(float device_scale_factor) { 1780 void LayerTreeHostImpl::SetDeviceScaleFactor(float device_scale_factor) {
1742 if (device_scale_factor == device_scale_factor_) 1781 if (device_scale_factor == device_scale_factor_)
1743 return; 1782 return;
1744 device_scale_factor_ = device_scale_factor; 1783 device_scale_factor_ = device_scale_factor;
1745 1784
1746 if (renderer_) 1785 if (renderer_)
1747 renderer_->ViewportChanged(); 1786 renderer_->ViewportChanged();
1748 1787
1749 UpdateMaxScrollOffset(); 1788 UpdateMaxScrollOffset();
1750 SetFullRootLayerDamage(); 1789 SetFullRootLayerDamage();
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
2514 2553
2515 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( 2554 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource(
2516 UIResourceId uid) const { 2555 UIResourceId uid) const {
2517 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); 2556 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid);
2518 if (iter != ui_resource_map_.end()) 2557 if (iter != ui_resource_map_.end())
2519 return iter->second; 2558 return iter->second;
2520 return 0; 2559 return 0;
2521 } 2560 }
2522 2561
2523 } // namespace cc 2562 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698