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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ANDROID_COMPOSITOR_COMPOSITOR_VIEW_H_
#define CHROME_BROWSER_ANDROID_COMPOSITOR_COMPOSITOR_VIEW_H_
#include <jni.h>
#include "base/android/jni_android.h"
#include "base/android/scoped_java_ref.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "cc/resources/ui_resource_client.h"
#include "content/public/browser/android/compositor_client.h"
#include "content/public/browser/browser_child_process_observer.h"
#include "content/public/browser/gpu_feature_checker.h"
#include "third_party/skia/include/core/SkColor.h"
namespace cc::slim {
class SolidColorLayer;
} // namespace cc::slim
namespace content {
class Compositor;
}
namespace ui {
class WindowAndroid;
class ResourceManager;
class UIResourceProvider;
} // namespace ui
namespace android {
class SceneLayer;
class TabContentManager;
class CompositorView : public content::CompositorClient,
public content::BrowserChildProcessObserver {
public:
CompositorView(JNIEnv* env,
const base::android::JavaRef<jobject>& obj,
jboolean low_mem_device,
ui::WindowAndroid* window_android,
TabContentManager* tab_content_manager);
CompositorView(const CompositorView&) = delete;
CompositorView& operator=(const CompositorView&) = delete;
void Destroy(JNIEnv* env);
ui::ResourceManager* GetResourceManager();
base::android::ScopedJavaLocalRef<jobject> GetResourceManager(JNIEnv* env);
void SetNeedsComposite(JNIEnv* env);
void FinalizeLayers(JNIEnv* env);
void SetLayoutBounds(JNIEnv* env);
void SurfaceCreated(JNIEnv* env);
void SurfaceDestroyed(JNIEnv* env);
std::optional<int> SurfaceChanged(
JNIEnv* env,
jint format,
jint width,
jint height,
bool can_be_used_with_surface_control,
const base::android::JavaParamRef<jobject>& surface,
const base::android::JavaParamRef<jobject>& browser_input_token);
void OnPhysicalBackingSizeChanged(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& jweb_contents,
jint width,
jint height);
void OnControlsResizeViewChanged(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& jweb_contents,
jboolean controls_resize_view);
void NotifyVirtualKeyboardOverlayRect(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& jweb_contents,
jint x,
jint y,
jint width,
jint height);
void SetOverlayVideoMode(JNIEnv* env,
bool enabled);
void SetOverlayImmersiveArMode(
JNIEnv* env,
bool enabled);
void SetOverlayXrFullScreenMode(
JNIEnv* env,
bool enabled);
void SetSceneLayer(JNIEnv* env,
const base::android::JavaParamRef<jobject>& jscene_layer);
void SetCompositorWindow(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& window_android);
void CacheBackBufferForCurrentSurface(JNIEnv* env);
void EvictCachedBackBuffer(JNIEnv* env);
void OnTabChanged(JNIEnv* env);
void PreserveChildSurfaceControls(JNIEnv* env);
void SetDidSwapBuffersCallbackEnabled(JNIEnv* env, jboolean enable);
// CompositorClient implementation:
void RecreateSurface() override;
void UpdateLayerTreeHost() override;
void DidSwapFrame(int pending_frames) override;
void DidSwapBuffers(const gfx::Size& swap_size) override;
base::WeakPtr<ui::UIResourceProvider> GetUIResourceProvider();
private:
~CompositorView() override;
// content::BrowserChildProcessObserver implementation:
void BrowserChildProcessKilled(
const content::ChildProcessData& data,
const content::ChildProcessTerminationInfo& info) override;
void SetBackground(bool visible, SkColor color);
void OnSurfaceControlFeatureStatusUpdate(bool available);
base::android::ScopedJavaGlobalRef<jobject> obj_;
std::unique_ptr<content::Compositor> compositor_;
// TODO(crbug.com/324196360): One of these is triggering Dangling Pointer
// Detection. Figure out why and remove the DanglingUntriaged annotation.
raw_ptr<TabContentManager, DanglingUntriaged> tab_content_manager_;
scoped_refptr<cc::slim::SolidColorLayer> root_layer_;
// TODO(crbug.com/324196360): One of these is triggering Dangling Pointer
// Detection. Figure out why and remove the DanglingUntriaged annotation.
raw_ptr<SceneLayer, DanglingUntriaged> scene_layer_;
int current_surface_format_;
int content_width_;
int content_height_;
bool overlay_video_mode_;
bool overlay_immersive_ar_mode_;
bool overlay_xr_full_screen_mode_;
base::WeakPtrFactory<CompositorView> weak_factory_{this};
};
} // namespace android
#endif // CHROME_BROWSER_ANDROID_COMPOSITOR_COMPOSITOR_VIEW_H_
|