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_
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
;
23 class TabLayerContainer
;
27 class SolidColorLayer
;
29 class UIResourceBitmap
;
42 class ResourceManager
;
43 class UIResourceProvider
;
49 class LayerTitleCache
;
51 class TabContentManager
;
54 class CompositorView
: public content::CompositorClient
,
55 public content::BrowserChildProcessObserver
{
57 CompositorView(JNIEnv
* env
,
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
,
70 void SetNeedsComposite(JNIEnv
* env
, jobject object
);
71 void FinalizeLayers(JNIEnv
* env
, jobject jobj
);
72 void SetLayoutViewport(JNIEnv
* env
,
78 jfloat visible_x_offset
,
79 jfloat visible_y_offset
,
80 jfloat overdraw_bottom_height
,
82 void UpdateToolbarLayer(JNIEnv
* env
,
84 jint toolbar_resource_id
,
89 void UpdateProgressBar(JNIEnv
* env
,
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
,
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();
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_
;
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_