Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "remoting/client/jni/chromoting_jni_runtime.h" | 5 #include "remoting/client/jni/chromoting_jni_runtime.h" |
| 6 | 6 |
| 7 #include "base/android/base_jni_registrar.h" | 7 #include "base/android/base_jni_registrar.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 host_jstr, | 164 host_jstr, |
| 165 id_arr, | 165 id_arr, |
| 166 secret_arr); | 166 secret_arr); |
| 167 | 167 |
| 168 // Because we passed them as arguments, their corresponding Java objects were | 168 // Because we passed them as arguments, their corresponding Java objects were |
| 169 // GCd as soon as the managed method returned, so we mustn't release it here. | 169 // GCd as soon as the managed method returned, so we mustn't release it here. |
| 170 } | 170 } |
| 171 | 171 |
| 172 void ChromotingJniRuntime::UpdateImageBuffer(int width, | 172 void ChromotingJniRuntime::UpdateImageBuffer(int width, |
| 173 int height, | 173 int height, |
| 174 jobject buffer) { | 174 uint8* data) { |
| 175 DCHECK(display_task_runner_->BelongsToCurrentThread()); | 175 DCHECK(display_task_runner_->BelongsToCurrentThread()); |
| 176 | 176 |
| 177 JNIEnv* env = base::android::AttachCurrentThread(); | 177 JNIEnv* env = base::android::AttachCurrentThread(); |
| 178 env->SetStaticIntField( | 178 |
| 179 base::android::ScopedJavaLocalRef<jobject> buffer(env, | |
| 180 env->NewDirectByteBuffer(data, width * height * kBytesPerPixel)); | |
|
Sergey Ulanov
2013/09/25 23:32:08
frame stride may not be equal width*kBytesPerPixel
solb
2013/09/26 14:21:36
I can see the argument for this, but at the same t
Lambros
2013/09/26 22:29:37
It's possible to deal with strides that are differ
| |
| 181 | |
| 182 env->CallStaticVoidMethod( | |
| 179 class_, | 183 class_, |
| 180 env->GetStaticFieldID(class_, "sWidth", "I"), | 184 env->GetStaticMethodID( |
| 181 width); | 185 class_, |
| 182 env->SetStaticIntField( | 186 "setVideoFrame", |
| 183 class_, | 187 "(IILjava/nio/ByteBuffer;)V"), |
| 184 env->GetStaticFieldID(class_, "sHeight", "I"), | 188 width, |
| 185 height); | 189 height, |
| 186 env->SetStaticObjectField( | 190 buffer.obj()); |
| 187 class_, | |
| 188 env->GetStaticFieldID(class_, "sBuffer", "Ljava/nio/ByteBuffer;"), | |
| 189 buffer); | |
| 190 } | 191 } |
| 191 | 192 |
| 192 void ChromotingJniRuntime::UpdateCursorShape( | 193 void ChromotingJniRuntime::UpdateCursorShape( |
| 193 const protocol::CursorShapeInfo& cursor_shape) { | 194 const protocol::CursorShapeInfo& cursor_shape) { |
| 194 DCHECK(display_task_runner_->BelongsToCurrentThread()); | 195 DCHECK(display_task_runner_->BelongsToCurrentThread()); |
| 195 | 196 |
| 196 // const_cast<> is safe as long as the Java updateCursorShape() method copies | 197 // const_cast<> is safe as long as the Java updateCursorShape() method copies |
| 197 // the data out of the buffer without mutating it, and doesn't keep any | 198 // the data out of the buffer without mutating it, and doesn't keep any |
| 198 // reference to the buffer afterwards. Unfortunately, there seems to be no way | 199 // reference to the buffer afterwards. Unfortunately, there seems to be no way |
| 199 // to create a read-only ByteBuffer from a pointer-to-const. | 200 // to create a read-only ByteBuffer from a pointer-to-const. |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 225 class_, | 226 class_, |
| 226 env->GetStaticMethodID(class_, "redrawGraphicsInternal", "()V")); | 227 env->GetStaticMethodID(class_, "redrawGraphicsInternal", "()V")); |
| 227 } | 228 } |
| 228 | 229 |
| 229 void ChromotingJniRuntime::DetachFromVmAndSignal(base::WaitableEvent* waiter) { | 230 void ChromotingJniRuntime::DetachFromVmAndSignal(base::WaitableEvent* waiter) { |
| 230 base::android::DetachFromVM(); | 231 base::android::DetachFromVM(); |
| 231 waiter->Signal(); | 232 waiter->Signal(); |
| 232 } | 233 } |
| 233 | 234 |
| 234 } // namespace remoting | 235 } // namespace remoting |
| OLD | NEW |