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

Side by Side Diff: content/browser/android/overscroll_glow.h

Issue 377013002: android: Use UIResource for overscroll glow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments. moved system_ui_resource* implementation to content Created 6 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #ifndef CONTENT_BROWSER_ANDROID_OVERSCROLL_GLOW_H_ 5 #ifndef CONTENT_BROWSER_ANDROID_OVERSCROLL_GLOW_H_
6 #define CONTENT_BROWSER_ANDROID_OVERSCROLL_GLOW_H_ 6 #define CONTENT_BROWSER_ANDROID_OVERSCROLL_GLOW_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "content/browser/android/edge_effect.h" 11 #include "content/browser/android/edge_effect.h"
12 #include "ui/gfx/size_f.h" 12 #include "ui/gfx/size_f.h"
13 #include "ui/gfx/vector2d_f.h" 13 #include "ui/gfx/vector2d_f.h"
14 14
15 class SkBitmap; 15 class SkBitmap;
16 16
17 namespace cc { 17 namespace cc {
18 class Layer; 18 class Layer;
19 } 19 }
20 20
21 namespace ui {
22 class SystemUIResourceManager;
23 }
24
21 namespace content { 25 namespace content {
22 26
23 /* |OverscrollGlow| mirrors its Android counterpart, OverscrollGlow.java. 27 /* |OverscrollGlow| mirrors its Android counterpart, OverscrollGlow.java.
24 * Conscious tradeoffs were made to align this as closely as possible with the 28 * Conscious tradeoffs were made to align this as closely as possible with the
25 * original Android Java version. 29 * original Android Java version.
26 */ 30 */
27 class OverscrollGlow { 31 class OverscrollGlow {
28 public: 32 public:
29 // Create a new effect. If |enabled| is false, the effect will remain 33 // Create a new effect. |resource_manager| provides the resource for the
30 // deactivated until explicitly enabled. 34 // effect. |resource_manager| must outlive the effect. If |enabled| is false,
31 // Note: No resources will be allocated until the effect is both 35 // the effect will remain deactivated until explicitly enabled.
32 // enabled and an overscroll event has occurred. 36 static scoped_ptr<OverscrollGlow> Create(
33 static scoped_ptr<OverscrollGlow> Create(bool enabled); 37 ui::SystemUIResourceManager* resource_manager);
34 38
35 ~OverscrollGlow(); 39 ~OverscrollGlow();
36 40
37 // Enable the effect. If the effect was previously disabled, it will remain 41 // Enable the effect. If the effect was previously disabled, it will remain
38 // dormant until subsequent calls to |OnOverscrolled()|. 42 // dormant until subsequent calls to |OnOverscrolled()|.
39 void Enable(); 43 void Enable();
40 44
41 // Deactivate and detach the effect. Subsequent calls to |OnOverscrolled()| or 45 // Deactivate and detach the effect. Subsequent calls to |OnOverscrolled()| or
42 // |Animate()| will have no effect. 46 // |Animate()| will have no effect.
43 void Disable(); 47 void Disable();
(...skipping 19 matching lines...) Expand all
63 gfx::SizeF size; 67 gfx::SizeF size;
64 float edge_offsets[EdgeEffect::EDGE_COUNT]; 68 float edge_offsets[EdgeEffect::EDGE_COUNT];
65 float device_scale_factor; 69 float device_scale_factor;
66 }; 70 };
67 void UpdateDisplayParameters(const DisplayParameters& params); 71 void UpdateDisplayParameters(const DisplayParameters& params);
68 72
69 73
70 private: 74 private:
71 enum Axis { AXIS_X, AXIS_Y }; 75 enum Axis { AXIS_X, AXIS_Y };
72 76
73 OverscrollGlow(bool enabled); 77 OverscrollGlow(ui::SystemUIResourceManager* resource_manager);
74 78
75 // Returns whether the effect is initialized. 79 // Returns whether the effect is initialized.
76 bool InitializeIfNecessary(); 80 bool InitializeIfNecessary();
77 bool NeedsAnimate() const; 81 bool NeedsAnimate() const;
78 void UpdateLayerAttachment(cc::Layer* parent); 82 void UpdateLayerAttachment(cc::Layer* parent);
79 void Detach(); 83 void Detach();
80 void Pull(base::TimeTicks current_time, gfx::Vector2dF overscroll_delta); 84 void Pull(base::TimeTicks current_time, gfx::Vector2dF overscroll_delta);
81 void Absorb(base::TimeTicks current_time, 85 void Absorb(base::TimeTicks current_time,
82 gfx::Vector2dF velocity, 86 gfx::Vector2dF velocity,
83 bool x_overscroll_started, 87 bool x_overscroll_started,
84 bool y_overscroll_started); 88 bool y_overscroll_started);
85 void Release(base::TimeTicks current_time); 89 void Release(base::TimeTicks current_time);
86 void ReleaseAxis(Axis axis, base::TimeTicks current_time); 90 void ReleaseAxis(Axis axis, base::TimeTicks current_time);
87 91
88 EdgeEffect* GetOppositeEdge(int edge_index); 92 EdgeEffect* GetOppositeEdge(int edge_index);
89 93
90 scoped_ptr<EdgeEffect> edge_effects_[EdgeEffect::EDGE_COUNT]; 94 scoped_ptr<EdgeEffect> edge_effects_[EdgeEffect::EDGE_COUNT];
91 95
92 DisplayParameters display_params_; 96 DisplayParameters display_params_;
93 bool enabled_; 97 bool enabled_;
94 bool initialized_; 98 bool initialized_;
95 99
96 scoped_refptr<cc::Layer> root_layer_; 100 scoped_refptr<cc::Layer> root_layer_;
101 ui::SystemUIResourceManager* resource_manager_;
97 102
98 DISALLOW_COPY_AND_ASSIGN(OverscrollGlow); 103 DISALLOW_COPY_AND_ASSIGN(OverscrollGlow);
99 }; 104 };
100 105
101 } // namespace content 106 } // namespace content
102 107
103 #endif // CONTENT_BROWSER_ANDROID_SCROLL_GLOW_H_ 108 #endif // CONTENT_BROWSER_ANDROID_SCROLL_GLOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698