| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/plugin/chromoting_instance.h" | 5 #include "remoting/client/plugin/chromoting_instance.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 GetScriptableObject()->SetConnectionStatus( | 181 GetScriptableObject()->SetConnectionStatus( |
| 182 ChromotingScriptableObject::STATUS_CLOSED, | 182 ChromotingScriptableObject::STATUS_CLOSED, |
| 183 ChromotingScriptableObject::ERROR_NONE); | 183 ChromotingScriptableObject::ERROR_NONE); |
| 184 } | 184 } |
| 185 | 185 |
| 186 void ChromotingInstance::DidChangeView(const pp::Rect& position, | 186 void ChromotingInstance::DidChangeView(const pp::Rect& position, |
| 187 const pp::Rect& clip) { | 187 const pp::Rect& clip) { |
| 188 DCHECK(plugin_message_loop_->BelongsToCurrentThread()); | 188 DCHECK(plugin_message_loop_->BelongsToCurrentThread()); |
| 189 | 189 |
| 190 SkISize new_size = SkISize::Make(position.width(), position.height()); | 190 SkISize new_size = SkISize::Make(position.width(), position.height()); |
| 191 if (view_->SetViewSize(new_size)) { | 191 SkIRect new_clip = |
| 192 SkIRect::MakeXYWH(clip.x(), clip.y(), clip.width(), clip.height()); |
| 193 |
| 194 if (view_->SetView(new_size, new_clip)) { |
| 192 if (mouse_input_filter_.get()) { | 195 if (mouse_input_filter_.get()) { |
| 193 mouse_input_filter_->set_input_size(new_size); | 196 mouse_input_filter_->set_input_size(new_size); |
| 194 } | 197 } |
| 195 rectangle_decoder_->SetOutputSize(new_size); | 198 // TODO(alexeypa): Update only the changed area if possible. |
| 199 rectangle_decoder_->RefreshFullFrame(); |
| 196 } | 200 } |
| 201 } |
| 197 | 202 |
| 198 rectangle_decoder_->UpdateClipRect( | 203 void ChromotingInstance::RefreshFullFrame() { |
| 199 SkIRect::MakeXYWH(clip.x(), clip.y(), clip.width(), clip.height())); | 204 rectangle_decoder_->RefreshFullFrame(); |
| 200 } | 205 } |
| 201 | 206 |
| 202 bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) { | 207 bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) { |
| 203 DCHECK(plugin_message_loop_->BelongsToCurrentThread()); | 208 DCHECK(plugin_message_loop_->BelongsToCurrentThread()); |
| 204 | 209 |
| 205 // Never inject events if the end of the input pipeline doesn't exist. | 210 // Never inject events if the end of the input pipeline doesn't exist. |
| 206 // If it does exist but the pipeline doesn't, construct a pipeline. | 211 // If it does exist but the pipeline doesn't, construct a pipeline. |
| 207 // TODO(wez): This is really ugly. We should create the pipeline when | 212 // TODO(wez): This is really ugly. We should create the pipeline when |
| 208 // the ConnectionToHost's InputStub exists. | 213 // the ConnectionToHost's InputStub exists. |
| 209 if (!host_connection_.get()) { | 214 if (!host_connection_.get()) { |
| 210 return false; | 215 return false; |
| 211 } else if (!input_handler_.get()) { | 216 } else if (!input_handler_.get()) { |
| 212 protocol::InputStub* input_stub = host_connection_->input_stub(); | 217 protocol::InputStub* input_stub = host_connection_->input_stub(); |
| 213 if (!input_stub) | 218 if (!input_stub) |
| 214 return false; | 219 return false; |
| 215 mouse_input_filter_.reset(new MouseInputFilter(input_stub)); | 220 mouse_input_filter_.reset(new MouseInputFilter(input_stub)); |
| 216 mouse_input_filter_->set_input_size(view_->get_view_size()); | 221 mouse_input_filter_->set_input_size(view_->get_view_size()); |
| 217 key_event_tracker_.reset( | 222 key_event_tracker_.reset( |
| 218 new protocol::KeyEventTracker(mouse_input_filter_.get())); | 223 new protocol::KeyEventTracker(mouse_input_filter_.get())); |
| 219 input_handler_.reset( | 224 input_handler_.reset( |
| 220 new PepperInputHandler(key_event_tracker_.get())); | 225 new PepperInputHandler(key_event_tracker_.get())); |
| 221 } | 226 } |
| 222 | 227 |
| 223 // TODO(wez): When we have a good hook into Host dimensions changes, move | 228 // TODO(wez): When we have a good hook into Host dimensions changes, move |
| 224 // this there. | 229 // this there. |
| 225 mouse_input_filter_->set_output_size(view_->get_host_size()); | 230 mouse_input_filter_->set_output_size(view_->get_screen_size()); |
| 226 | 231 |
| 227 return input_handler_->HandleInputEvent(event); | 232 return input_handler_->HandleInputEvent(event); |
| 228 } | 233 } |
| 229 | 234 |
| 230 ChromotingScriptableObject* ChromotingInstance::GetScriptableObject() { | 235 ChromotingScriptableObject* ChromotingInstance::GetScriptableObject() { |
| 231 pp::VarPrivate object = GetInstanceObject(); | 236 pp::VarPrivate object = GetInstanceObject(); |
| 232 if (!object.is_undefined()) { | 237 if (!object.is_undefined()) { |
| 233 pp::deprecated::ScriptableObject* so = object.AsScriptableObject(); | 238 pp::deprecated::ScriptableObject* so = object.AsScriptableObject(); |
| 234 DCHECK(so != NULL); | 239 DCHECK(so != NULL); |
| 235 return static_cast<ChromotingScriptableObject*>(so); | 240 return static_cast<ChromotingScriptableObject*>(so); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 return client_->GetStats(); | 357 return client_->GetStats(); |
| 353 } | 358 } |
| 354 | 359 |
| 355 void ChromotingInstance::ReleaseAllKeys() { | 360 void ChromotingInstance::ReleaseAllKeys() { |
| 356 if (key_event_tracker_.get()) { | 361 if (key_event_tracker_.get()) { |
| 357 key_event_tracker_->ReleaseAllKeys(); | 362 key_event_tracker_->ReleaseAllKeys(); |
| 358 } | 363 } |
| 359 } | 364 } |
| 360 | 365 |
| 361 } // namespace remoting | 366 } // namespace remoting |
| OLD | NEW |