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

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

Issue 2508203004: Add hints for potential overlay promotion on android. (Closed)
Patch Set: added CC_EXPORT Created 4 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/overlay_processor.h" 5 #include "cc/output/overlay_processor.h"
6 6
7 #include "cc/output/output_surface.h" 7 #include "cc/output/output_surface.h"
8 #include "cc/output/overlay_strategy_single_on_top.h" 8 #include "cc/output/overlay_strategy_single_on_top.h"
9 #include "cc/output/overlay_strategy_underlay.h" 9 #include "cc/output/overlay_strategy_underlay.h"
10 #include "cc/quads/draw_quad.h" 10 #include "cc/quads/draw_quad.h"
11 #include "cc/resources/resource_provider.h"
11 #include "ui/gfx/geometry/rect_conversions.h" 12 #include "ui/gfx/geometry/rect_conversions.h"
12 #include "ui/gfx/transform.h" 13 #include "ui/gfx/transform.h"
13 14
15 namespace {
16
17 #if defined(OS_ANDROID)
18 // Utility class to make sure that we notify resource that they're promotable
19 // before returning from ProcessForOverlays.
20 class SendPromotionHintsBeforeReturning {
21 public:
22 SendPromotionHintsBeforeReturning(cc::ResourceProvider* resource_provider,
23 cc::OverlayCandidateList* candidates)
24 : resource_provider_(resource_provider), candidates_(candidates) {}
25 ~SendPromotionHintsBeforeReturning() {
26 resource_provider_->SendPromotionHints(
27 candidates_->promotable_resource_hints_);
28 }
29
30 private:
31 cc::ResourceProvider* resource_provider_;
32 cc::OverlayCandidateList* candidates_;
33
34 DISALLOW_COPY_AND_ASSIGN(SendPromotionHintsBeforeReturning);
35 };
36 #endif
37
38 } // namespace
39
14 namespace cc { 40 namespace cc {
15 41
16 OverlayProcessor::OverlayProcessor(OutputSurface* surface) : surface_(surface) { 42 OverlayProcessor::OverlayProcessor(OutputSurface* surface) : surface_(surface) {
17 } 43 }
18 44
19 void OverlayProcessor::Initialize() { 45 void OverlayProcessor::Initialize() {
20 DCHECK(surface_); 46 DCHECK(surface_);
21 OverlayCandidateValidator* validator = 47 OverlayCandidateValidator* validator =
22 surface_->GetOverlayCandidateValidator(); 48 surface_->GetOverlayCandidateValidator();
23 if (validator) 49 if (validator)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 overlay_damage_rect_ = render_pass->output_rect; 81 overlay_damage_rect_ = render_pass->output_rect;
56 *damage_rect = gfx::Rect(); 82 *damage_rect = gfx::Rect();
57 return true; 83 return true;
58 } 84 }
59 85
60 void OverlayProcessor::ProcessForOverlays(ResourceProvider* resource_provider, 86 void OverlayProcessor::ProcessForOverlays(ResourceProvider* resource_provider,
61 RenderPass* render_pass, 87 RenderPass* render_pass,
62 OverlayCandidateList* candidates, 88 OverlayCandidateList* candidates,
63 CALayerOverlayList* ca_layer_overlays, 89 CALayerOverlayList* ca_layer_overlays,
64 gfx::Rect* damage_rect) { 90 gfx::Rect* damage_rect) {
91 #if defined(OS_ANDROID)
92 // Be sure to send out notifications, regardless of whether we get to
93 // processing for overlays or not. If we don't, then we should notify that
94 // they are not promotable.
95 SendPromotionHintsBeforeReturning notifier(resource_provider, candidates);
96 #endif
97
65 // If we have any copy requests, we can't remove any quads for overlays or 98 // If we have any copy requests, we can't remove any quads for overlays or
66 // CALayers because the framebuffer would be missing the removed quads' 99 // CALayers because the framebuffer would be missing the removed quads'
67 // contents. 100 // contents.
68 if (!render_pass->copy_requests.empty()) { 101 if (!render_pass->copy_requests.empty()) {
69 // If overlay processing was skipped for a frame there's no way to be sure 102 // If overlay processing was skipped for a frame there's no way to be sure
70 // of the state of the previous frame, so reset. 103 // of the state of the previous frame, so reset.
71 previous_frame_underlay_rect_ = gfx::Rect(); 104 previous_frame_underlay_rect_ = gfx::Rect();
72 return; 105 return;
73 } 106 }
74 107
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 148 }
116 149
117 if (this_frame_underlay_rect == previous_frame_underlay_rect_) 150 if (this_frame_underlay_rect == previous_frame_underlay_rect_)
118 damage_rect->Subtract(this_frame_underlay_rect); 151 damage_rect->Subtract(this_frame_underlay_rect);
119 previous_frame_underlay_rect_ = this_frame_underlay_rect; 152 previous_frame_underlay_rect_ = this_frame_underlay_rect;
120 153
121 damage_rect->Union(output_surface_overlay_damage_rect); 154 damage_rect->Union(output_surface_overlay_damage_rect);
122 } 155 }
123 156
124 } // namespace cc 157 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698