Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/android/resources/resource_manager_impl.h" | 5 #include "ui/android/resources/resource_manager_impl.h" |
| 6 | 6 |
| 7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
| 8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "cc/resources/scoped_ui_resource.h" | 9 #include "cc/resources/scoped_ui_resource.h" |
| 10 #include "jni/ResourceManager_jni.h" | 10 #include "jni/ResourceManager_jni.h" |
| 11 #include "ui/android/resources/ui_resource_provider.h" | 11 #include "ui/android/resources/ui_resource_provider.h" |
| 12 #include "ui/android/window_android.h" | |
| 12 #include "ui/gfx/android/java_bitmap.h" | 13 #include "ui/gfx/android/java_bitmap.h" |
| 13 | 14 |
| 14 namespace ui { | 15 namespace ui { |
| 15 | 16 |
| 16 // static | 17 // static |
| 17 ResourceManagerImpl* ResourceManagerImpl::FromJavaObject(jobject jobj) { | 18 ResourceManagerImpl* ResourceManagerImpl::FromJavaObject(jobject jobj) { |
| 18 return reinterpret_cast<ResourceManagerImpl*>( | 19 return reinterpret_cast<ResourceManagerImpl*>( |
| 19 Java_ResourceManager_getNativePtr(base::android::AttachCurrentThread(), | 20 Java_ResourceManager_getNativePtr(base::android::AttachCurrentThread(), |
| 20 jobj)); | 21 jobj)); |
| 21 } | 22 } |
| 22 | 23 |
| 23 ResourceManagerImpl::ResourceManagerImpl() : host_(nullptr) { | 24 ResourceManagerImpl::ResourceManagerImpl(gfx::NativeWindow native_window) |
| 25 : host_(nullptr) { | |
|
boliu
2015/10/26 16:31:49
This constructorcan call through to the one below,
gsennton
2015/10/26 16:48:47
Done.
| |
| 24 JNIEnv* env = base::android::AttachCurrentThread(); | 26 JNIEnv* env = base::android::AttachCurrentThread(); |
| 25 java_obj_.Reset(env, Java_ResourceManager_create( | 27 java_obj_.Reset(env, Java_ResourceManager_create( |
| 26 env, base::android::GetApplicationContext(), | 28 env, native_window->GetJavaDisplayContext().obj(), |
| 27 reinterpret_cast<intptr_t>(this)).obj()); | 29 reinterpret_cast<intptr_t>(this)) |
| 30 .obj()); | |
| 28 DCHECK(!java_obj_.is_null()); | 31 DCHECK(!java_obj_.is_null()); |
| 29 } | 32 } |
| 30 | 33 |
| 34 ResourceManagerImpl::ResourceManagerImpl(jobject context) : host_(nullptr) { | |
| 35 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 36 java_obj_.Reset(env, Java_ResourceManager_create( | |
| 37 env, context, reinterpret_cast<intptr_t>(this)) | |
| 38 .obj()); | |
| 39 DCHECK(!java_obj_.is_null()); | |
| 40 } | |
| 41 | |
| 31 ResourceManagerImpl::~ResourceManagerImpl() { | 42 ResourceManagerImpl::~ResourceManagerImpl() { |
| 32 Java_ResourceManager_destroy(base::android::AttachCurrentThread(), | 43 Java_ResourceManager_destroy(base::android::AttachCurrentThread(), |
| 33 java_obj_.obj()); | 44 java_obj_.obj()); |
| 34 } | 45 } |
| 35 | 46 |
| 36 void ResourceManagerImpl::Init(cc::LayerTreeHost* host) { | 47 void ResourceManagerImpl::Init(cc::LayerTreeHost* host) { |
| 37 DCHECK(!host_); | 48 DCHECK(!host_); |
| 38 DCHECK(host); | 49 DCHECK(host); |
| 39 host_ = host; | 50 host_ = host; |
| 40 } | 51 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 void ResourceManagerImpl::RequestResourceFromJava(AndroidResourceType res_type, | 141 void ResourceManagerImpl::RequestResourceFromJava(AndroidResourceType res_type, |
| 131 int res_id) { | 142 int res_id) { |
| 132 TRACE_EVENT2("ui", "ResourceManagerImpl::RequestResourceFromJava", | 143 TRACE_EVENT2("ui", "ResourceManagerImpl::RequestResourceFromJava", |
| 133 "resource_type", res_type, | 144 "resource_type", res_type, |
| 134 "resource_id", res_id); | 145 "resource_id", res_id); |
| 135 Java_ResourceManager_resourceRequested(base::android::AttachCurrentThread(), | 146 Java_ResourceManager_resourceRequested(base::android::AttachCurrentThread(), |
| 136 java_obj_.obj(), res_type, res_id); | 147 java_obj_.obj(), res_type, res_id); |
| 137 } | 148 } |
| 138 | 149 |
| 139 } // namespace ui | 150 } // namespace ui |
| OLD | NEW |