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/jni_frame_consumer.h" | 5 #include "remoting/client/jni/jni_frame_consumer.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
8 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 #include "remoting/base/util.h" | 12 #include "remoting/base/util.h" |
11 #include "remoting/client/jni/chromoting_jni_instance.h" | 13 #include "remoting/client/jni/chromoting_jni_instance.h" |
12 #include "remoting/client/jni/chromoting_jni_runtime.h" | 14 #include "remoting/client/jni/chromoting_jni_runtime.h" |
13 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 15 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
14 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" | 16 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" |
15 #include "ui/gfx/android/java_bitmap.h" | 17 #include "ui/gfx/android/java_bitmap.h" |
16 | 18 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 jni_runtime_->UpdateFrameBitmap(bitmap_global_ref_.obj()); | 62 jni_runtime_->UpdateFrameBitmap(bitmap_global_ref_.obj()); |
61 } | 63 } |
62 | 64 |
63 // Copy pixels from |frame| into the Java Bitmap. | 65 // Copy pixels from |frame| into the Java Bitmap. |
64 // TODO(lambroslambrou): Optimize away this copy by having the VideoDecoder | 66 // TODO(lambroslambrou): Optimize away this copy by having the VideoDecoder |
65 // decode directly into the Bitmap's pixel memory. This currently doesn't | 67 // decode directly into the Bitmap's pixel memory. This currently doesn't |
66 // work very well because the VideoDecoder writes the decoded data in BGRA, | 68 // work very well because the VideoDecoder writes the decoded data in BGRA, |
67 // and then the R/B channels are swapped in place (on the decoding thread). | 69 // and then the R/B channels are swapped in place (on the decoding thread). |
68 // If a repaint is triggered from a Java event handler, the unswapped pixels | 70 // If a repaint is triggered from a Java event handler, the unswapped pixels |
69 // can sometimes appear on the display. | 71 // can sometimes appear on the display. |
70 uint8* dest_buffer = static_cast<uint8*>(bitmap_->pixels()); | 72 uint8_t* dest_buffer = static_cast<uint8_t*>(bitmap_->pixels()); |
71 webrtc::DesktopRect buffer_rect = | 73 webrtc::DesktopRect buffer_rect = |
72 webrtc::DesktopRect::MakeSize(frame->size()); | 74 webrtc::DesktopRect::MakeSize(frame->size()); |
73 for (webrtc::DesktopRegion::Iterator i(frame->updated_region()); !i.IsAtEnd(); | 75 for (webrtc::DesktopRegion::Iterator i(frame->updated_region()); !i.IsAtEnd(); |
74 i.Advance()) { | 76 i.Advance()) { |
75 CopyRGB32Rect(frame->data(), frame->stride(), buffer_rect, dest_buffer, | 77 CopyRGB32Rect(frame->data(), frame->stride(), buffer_rect, dest_buffer, |
76 bitmap_->stride(), buffer_rect, i.rect()); | 78 bitmap_->stride(), buffer_rect, i.rect()); |
77 } | 79 } |
78 | 80 |
79 jni_runtime_->RedrawCanvas(); | 81 jni_runtime_->RedrawCanvas(); |
80 } | 82 } |
(...skipping 30 matching lines...) Expand all Loading... |
111 | 113 |
112 if (!done.is_null()) | 114 if (!done.is_null()) |
113 done.Run(); | 115 done.Run(); |
114 } | 116 } |
115 | 117 |
116 FrameConsumer::PixelFormat JniFrameConsumer::GetPixelFormat() { | 118 FrameConsumer::PixelFormat JniFrameConsumer::GetPixelFormat() { |
117 return FORMAT_RGBA; | 119 return FORMAT_RGBA; |
118 } | 120 } |
119 | 121 |
120 } // namespace remoting | 122 } // namespace remoting |
OLD | NEW |