ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chrome / browser / android / compositor / scene_layer / scene_layer.cc
blobee8eeba52bf23269f19163c8b6535cd79c19f6ee
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 #include "chrome/browser/android/compositor/scene_layer/scene_layer.h"
7 #include "cc/layers/layer.h"
8 #include "jni/SceneLayer_jni.h"
10 namespace chrome {
11 namespace android {
13 // static
14 SceneLayer* SceneLayer::FromJavaObject(JNIEnv* env, jobject jobj) {
15 if (jobj == nullptr)
16 return nullptr;
17 return reinterpret_cast<SceneLayer*>(Java_SceneLayer_getNativePtr(env, jobj));
20 SceneLayer::SceneLayer(JNIEnv* env, jobject jobj)
21 : SceneLayer(env, jobj, cc::Layer::Create()) {
24 SceneLayer::SceneLayer(JNIEnv* env,
25 jobject jobj,
26 scoped_refptr<cc::Layer> layer)
27 : weak_java_scene_layer_(env, jobj), layer_(layer) {
28 Java_SceneLayer_setNativePtr(env, jobj, reinterpret_cast<intptr_t>(this));
31 SceneLayer::~SceneLayer() {
32 JNIEnv* env = base::android::AttachCurrentThread();
33 ScopedJavaLocalRef<jobject> jobj = weak_java_scene_layer_.get(env);
34 if (jobj.is_null())
35 return;
37 Java_SceneLayer_setNativePtr(
38 env, jobj.obj(),
39 reinterpret_cast<intptr_t>(static_cast<SceneLayer*>(NULL)));
42 void SceneLayer::OnDetach() {
43 layer()->RemoveFromParent();
46 void SceneLayer::Destroy(JNIEnv* env, jobject jobj) {
47 delete this;
50 bool SceneLayer::ShouldShowBackground() {
51 return false;
54 SkColor SceneLayer::GetBackgroundColor() {
55 return SK_ColorWHITE;
58 static jlong Init(JNIEnv* env, jobject jobj) {
59 // This will automatically bind to the Java object and pass ownership there.
60 SceneLayer* tree_provider = new SceneLayer(env, jobj);
61 return reinterpret_cast<intptr_t>(tree_provider);
64 bool RegisterSceneLayer(JNIEnv* env) {
65 return RegisterNativesImpl(env);
68 } // namespace android
69 } // namespace chrome