Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / android / compositor / compositor_view.h
blob44815058d36a6e5ecd0a33491467f5102c7aedea
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_ANDROID_COMPOSITOR_COMPOSITOR_VIEW_H_
6 #define CHROME_BROWSER_ANDROID_COMPOSITOR_COMPOSITOR_VIEW_H_
8 #include <jni.h>
10 #include "base/android/jni_android.h"
11 #include "base/android/scoped_java_ref.h"
12 #include "base/containers/scoped_ptr_hash_map.h"
13 #include "base/memory/weak_ptr.h"
14 #include "cc/layers/layer_lists.h"
15 #include "cc/resources/ui_resource_client.h"
16 #include "content/public/browser/android/compositor_client.h"
17 #include "content/public/browser/browser_child_process_observer.h"
18 #include "third_party/skia/include/core/SkColor.h"
20 class DecorationBackground;
21 class DecorationCounter;
22 class SkBitmap;
23 class TabLayerContainer;
25 namespace cc {
26 class Layer;
27 class SolidColorLayer;
28 class TextureLayer;
29 class UIResourceBitmap;
32 namespace gfx {
33 class JavaBitmap;
36 namespace content {
37 class Compositor;
40 namespace ui {
41 class WindowAndroid;
42 class ResourceManager;
43 class UIResourceProvider;
46 namespace chrome {
47 namespace android {
49 class LayerTitleCache;
50 class SceneLayer;
51 class TabContentManager;
52 class ToolbarLayer;
54 class CompositorView : public content::CompositorClient,
55 public content::BrowserChildProcessObserver {
56 public:
57 CompositorView(JNIEnv* env,
58 jobject obj,
59 jint empty_background_color,
60 jboolean low_mem_device,
61 ui::WindowAndroid* window_android,
62 LayerTitleCache* layer_title_cache,
63 TabContentManager* tab_content_manager);
65 void Destroy(JNIEnv* env, jobject object);
67 ui::ResourceManager* GetResourceManager();
68 base::android::ScopedJavaLocalRef<jobject> GetResourceManager(JNIEnv* env,
69 jobject jobj);
70 void SetNeedsComposite(JNIEnv* env, jobject object);
71 void FinalizeLayers(JNIEnv* env, jobject jobj);
72 void SetLayoutViewport(JNIEnv* env,
73 jobject object,
74 jfloat x,
75 jfloat y,
76 jfloat width,
77 jfloat height,
78 jfloat visible_x_offset,
79 jfloat visible_y_offset,
80 jfloat overdraw_bottom_height,
81 jfloat dp_to_pixel);
82 void UpdateToolbarLayer(JNIEnv* env,
83 jobject object,
84 jint toolbar_resource_id,
85 jfloat top_offset,
86 jfloat brightness,
87 bool visible,
88 bool show_shadow);
89 void UpdateProgressBar(JNIEnv* env,
90 jobject object,
91 jint progress_bar_x,
92 jint progress_bar_y,
93 jint progress_bar_width,
94 jint progress_bar_height,
95 jint progress_bar_color,
96 jint progress_bar_background_x,
97 jint progress_bar_background_y,
98 jint progress_bar_background_width,
99 jint progress_bar_background_height,
100 jint progress_bar_background_color);
102 void SurfaceCreated(JNIEnv* env, jobject object);
103 void SurfaceDestroyed(JNIEnv* env, jobject object);
104 void SurfaceChanged(JNIEnv* env,
105 jobject object,
106 jint format,
107 jint width,
108 jint height,
109 jobject surface);
111 void SetOverlayVideoMode(JNIEnv* env, jobject object, bool enabled);
112 void SetSceneLayer(JNIEnv* env, jobject object, jobject jscene_layer);
114 // CompositorClient implementation:
115 void Layout() override;
116 void OnSwapBuffersCompleted(int pending_swap_buffers) override;
117 ui::UIResourceProvider* GetUIResourceProvider();
119 private:
120 ~CompositorView() override;
122 // content::BrowserChildProcessObserver implementation:
123 void BrowserChildProcessHostDisconnected(
124 const content::ChildProcessData& data) override;
125 void BrowserChildProcessCrashed(const content::ChildProcessData& data,
126 int exit_code) override;
128 void SetBackground(bool visible, SkColor color);
130 int GetUsableContentHeight();
132 base::android::ScopedJavaGlobalRef<jobject> obj_;
133 scoped_ptr<content::Compositor> compositor_;
134 LayerTitleCache* layer_title_cache_;
135 TabContentManager* tab_content_manager_;
137 scoped_refptr<cc::SolidColorLayer> root_layer_;
138 scoped_refptr<ToolbarLayer> toolbar_layer_;
139 SceneLayer* scene_layer_;
140 scoped_refptr<cc::Layer> scene_layer_layer_;
142 int current_surface_format_;
143 int content_width_;
144 int content_height_;
145 int overdraw_bottom_height_;
146 bool overlay_video_mode_;
147 SkColor empty_background_color_;
149 base::WeakPtrFactory<CompositorView> weak_factory_;
151 DISALLOW_COPY_AND_ASSIGN(CompositorView);
154 bool RegisterCompositorView(JNIEnv* env);
156 } // namespace android
157 } // namespace chrome
159 #endif // CHROME_BROWSER_ANDROID_COMPOSITOR_COMPOSITOR_VIEW_H_