compositor_view_impl.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Copyright 2019 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.
  4. #ifndef COMPONENTS_THIN_WEBVIEW_INTERNAL_COMPOSITOR_VIEW_IMPL_H_
  5. #define COMPONENTS_THIN_WEBVIEW_INTERNAL_COMPOSITOR_VIEW_IMPL_H_
  6. #include <jni.h>
  7. #include "base/android/jni_android.h"
  8. #include "base/android/scoped_java_ref.h"
  9. #include "cc/layers/layer.h"
  10. #include "components/thin_webview/compositor_view.h"
  11. #include "content/public/browser/android/compositor_client.h"
  12. namespace cc {
  13. class SolidColorLayer;
  14. } // namespace cc
  15. namespace content {
  16. class Compositor;
  17. } // namespace content
  18. namespace ui {
  19. class WindowAndroid;
  20. } // namespace ui
  21. namespace thin_webview {
  22. namespace android {
  23. // Native counterpart of CompositorViewImpl.java.
  24. class CompositorViewImpl : public CompositorView,
  25. public content::CompositorClient {
  26. public:
  27. CompositorViewImpl(JNIEnv* env,
  28. jobject obj,
  29. ui::WindowAndroid* window_android,
  30. int64_t java_background_color);
  31. CompositorViewImpl(const CompositorViewImpl&) = delete;
  32. CompositorViewImpl& operator=(const CompositorViewImpl&) = delete;
  33. ~CompositorViewImpl() override;
  34. void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& object);
  35. void SetNeedsComposite(JNIEnv* env,
  36. const base::android::JavaParamRef<jobject>& object);
  37. void SurfaceCreated(JNIEnv* env,
  38. const base::android::JavaParamRef<jobject>& object);
  39. void SurfaceDestroyed(JNIEnv* env,
  40. const base::android::JavaParamRef<jobject>& object);
  41. void SurfaceChanged(JNIEnv* env,
  42. const base::android::JavaParamRef<jobject>& object,
  43. jint format,
  44. jint width,
  45. jint height,
  46. bool can_be_used_with_surface_control,
  47. const base::android::JavaParamRef<jobject>& surface);
  48. // CompositorView implementation.
  49. void SetRootLayer(scoped_refptr<cc::Layer> layer) override;
  50. // CompositorClient implementation.
  51. void RecreateSurface() override;
  52. void UpdateLayerTreeHost() override;
  53. private:
  54. base::android::ScopedJavaGlobalRef<jobject> obj_;
  55. std::unique_ptr<content::Compositor> compositor_;
  56. scoped_refptr<cc::SolidColorLayer> root_layer_;
  57. int current_surface_format_;
  58. };
  59. } // namespace android
  60. } // namespace thin_webview
  61. #endif // COMPONENTS_THIN_WEBVIEW_INTERNAL_COMPOSITOR_VIEW_IMPL_H_