| 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 "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "remoting/client/frame_producer.h" | 10 #include "remoting/client/frame_producer.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // and cropping on the managed canvas. | 101 // and cropping on the managed canvas. |
| 102 view_size_ = source_size; | 102 view_size_ = source_size; |
| 103 clip_area_ = SkIRect::MakeSize(view_size_); | 103 clip_area_ = SkIRect::MakeSize(view_size_); |
| 104 frame_producer_->SetOutputSizeAndClip(view_size_, clip_area_); | 104 frame_producer_->SetOutputSizeAndClip(view_size_, clip_area_); |
| 105 | 105 |
| 106 // Unless being destructed, allocate buffer and start drawing frames onto it. | 106 // Unless being destructed, allocate buffer and start drawing frames onto it. |
| 107 frame_producer_->RequestReturnBuffers(base::Bind( | 107 frame_producer_->RequestReturnBuffers(base::Bind( |
| 108 &JniFrameConsumer::AllocateBuffer, base::Unretained(this))); | 108 &JniFrameConsumer::AllocateBuffer, base::Unretained(this))); |
| 109 } | 109 } |
| 110 | 110 |
| 111 FrameConsumer::PixelFormat JniFrameConsumer::GetPixelFormat() { |
| 112 return FORMAT_RGBA; |
| 113 } |
| 114 |
| 111 void JniFrameConsumer::AllocateBuffer() { | 115 void JniFrameConsumer::AllocateBuffer() { |
| 112 // Only do anything if we're not being destructed. | 116 // Only do anything if we're not being destructed. |
| 113 if (!in_dtor_) { | 117 if (!in_dtor_) { |
| 114 if (!jni_runtime_->display_task_runner()->BelongsToCurrentThread()) { | 118 if (!jni_runtime_->display_task_runner()->BelongsToCurrentThread()) { |
| 115 jni_runtime_->display_task_runner()->PostTask(FROM_HERE, | 119 jni_runtime_->display_task_runner()->PostTask(FROM_HERE, |
| 116 base::Bind(&JniFrameConsumer::AllocateBuffer, | 120 base::Bind(&JniFrameConsumer::AllocateBuffer, |
| 117 base::Unretained(this))); | 121 base::Unretained(this))); |
| 118 return; | 122 return; |
| 119 } | 123 } |
| 120 | 124 |
| 121 DirectDesktopFrame* buffer = new DirectDesktopFrame(view_size_.width(), | 125 DirectDesktopFrame* buffer = new DirectDesktopFrame(view_size_.width(), |
| 122 view_size_.height()); | 126 view_size_.height()); |
| 123 | 127 |
| 124 // Update Java's reference to the buffer and record of its dimensions. | 128 // Update Java's reference to the buffer and record of its dimensions. |
| 125 jni_runtime_->UpdateImageBuffer(view_size_.width(), | 129 jni_runtime_->UpdateImageBuffer(view_size_.width(), |
| 126 view_size_.height(), | 130 view_size_.height(), |
| 127 buffer->buffer()); | 131 buffer->buffer()); |
| 128 | 132 |
| 129 frame_producer_->DrawBuffer(buffer); | 133 frame_producer_->DrawBuffer(buffer); |
| 130 } | 134 } |
| 131 } | 135 } |
| 132 | 136 |
| 133 } // namespace remoting | 137 } // namespace remoting |
| OLD | NEW |