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_SCENE_LAYER_SCENE_LAYER_H_
6 #define CHROME_BROWSER_ANDROID_COMPOSITOR_SCENE_LAYER_SCENE_LAYER_H_
10 #include "base/android/jni_weak_ref.h"
11 #include "base/android/scoped_java_ref.h"
12 #include "base/basictypes.h"
13 #include "base/memory/ref_counted.h"
14 #include "cc/layers/layer.h"
15 #include "third_party/skia/include/core/SkColor.h"
20 // A native-side, cc::Layer based representation of how a scene should be drawn.
21 // Basically, this is a wrapper around cc::Layer and bridge with its Java
25 static SceneLayer
* FromJavaObject(JNIEnv
* env
, jobject jobj
);
27 // Create SceneLayer and creates an empty cc::Layer.
28 SceneLayer(JNIEnv
* env
, jobject jobj
);
29 // Create SceneLayer with the already-instantiated |layer|.
31 SceneLayer(JNIEnv
* env
, jobject jobj
, scoped_refptr
<cc::Layer
> layer
);
32 virtual ~SceneLayer();
34 // Notifies that this scene layer is about to be detached from its parent.
35 // TODO(changwan): check if we can remove this.
36 virtual void OnDetach();
38 // Java SceneLayer can use this method to destroy its native-side counterpart.
39 virtual void Destroy(JNIEnv
* env
, jobject jobj
);
41 // Returns cc::Layer object that this SceneLayer contains.
42 scoped_refptr
<cc::Layer
> layer() { return layer_
; }
44 // Returns whether we should show background when we draw this SceneLayer.
45 virtual bool ShouldShowBackground();
47 // Returns the background color if it is needed.
48 virtual SkColor
GetBackgroundColor();
51 JavaObjectWeakGlobalRef weak_java_scene_layer_
;
52 scoped_refptr
<cc::Layer
> layer_
;
55 DISALLOW_COPY_AND_ASSIGN(SceneLayer
);
58 bool RegisterSceneLayer(JNIEnv
* env
);
60 } // namespace android
63 #endif // CHROME_BROWSER_ANDROID_COMPOSITOR_SCENE_LAYER_SCENE_LAYER_H_