blob: 77e99390f8c96c5738c0f0c172f70aabfada3faf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/scheduler/renderer/render_widget_scheduling_state.h"
#include "components/scheduler/renderer/render_widget_signals.h"
namespace scheduler {
RenderWidgetSchedulingState::RenderWidgetSchedulingState(
RenderWidgetSignals* render_widget_scheduling_signals)
: render_widget_signals_(render_widget_scheduling_signals),
hidden_(false),
has_touch_handler_(false) {
render_widget_signals_->IncNumVisibleRenderWidgets();
}
RenderWidgetSchedulingState::~RenderWidgetSchedulingState() {
if (hidden_)
return;
render_widget_signals_->DecNumVisibleRenderWidgets();
if (has_touch_handler_) {
render_widget_signals_->DecNumVisibleRenderWidgetsWithTouchHandlers();
}
}
void RenderWidgetSchedulingState::SetHidden(bool hidden) {
if (hidden_ == hidden)
return;
hidden_ = hidden;
if (hidden_) {
render_widget_signals_->DecNumVisibleRenderWidgets();
if (has_touch_handler_) {
render_widget_signals_->DecNumVisibleRenderWidgetsWithTouchHandlers();
}
} else {
render_widget_signals_->IncNumVisibleRenderWidgets();
if (has_touch_handler_) {
render_widget_signals_->IncNumVisibleRenderWidgetsWithTouchHandlers();
}
}
}
void RenderWidgetSchedulingState::SetHasTouchHandler(bool has_touch_handler) {
if (has_touch_handler_ == has_touch_handler)
return;
has_touch_handler_ = has_touch_handler;
if (hidden_)
return;
if (has_touch_handler_) {
render_widget_signals_->IncNumVisibleRenderWidgetsWithTouchHandlers();
} else {
render_widget_signals_->DecNumVisibleRenderWidgetsWithTouchHandlers();
}
}
} // namespace scheduler
|