summaryrefslogtreecommitdiffstats
path: root/remoting/client
diff options
context:
space:
mode:
authorgarykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-21 20:21:37 +0000
committergarykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-21 20:21:37 +0000
commit7601f5371f4ae7f7598cc3b485450e032fa0f5e9 (patch)
tree21913ebe52c51891cee35d1e2102d914e8081990 /remoting/client
parent6cd410a1ebdebd4c7a1ff353d1baeaef1462db5e (diff)
downloadchromium_src-7601f5371f4ae7f7598cc3b485450e032fa0f5e9.zip
chromium_src-7601f5371f4ae7f7598cc3b485450e032fa0f5e9.tar.gz
chromium_src-7601f5371f4ae7f7598cc3b485450e032fa0f5e9.tar.bz2
Change Chromoting client to use Pepper's new Resource-base InputEvents.
Remove gfx::Point and gfx::Rect from the Chromoting client plugin code and consistently use pp::Point and pp::Rect. Push ConvertScreenToHost down into PepperView so it can take and return a pp::Point. BUG=none TEST=none Review URL: http://codereview.chromium.org/7453003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93462 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/client')
-rw-r--r--remoting/client/chromoting_view.h4
-rw-r--r--remoting/client/plugin/chromoting_instance.cc21
-rw-r--r--remoting/client/plugin/pepper_input_handler.cc45
-rw-r--r--remoting/client/plugin/pepper_input_handler.h14
-rw-r--r--remoting/client/plugin/pepper_view.cc40
-rw-r--r--remoting/client/plugin/pepper_view.h12
-rw-r--r--remoting/client/plugin/pepper_view_proxy.cc4
-rw-r--r--remoting/client/plugin/pepper_view_proxy.h7
8 files changed, 83 insertions, 64 deletions
diff --git a/remoting/client/chromoting_view.h b/remoting/client/chromoting_view.h
index 0a8c721..c6269e7 100644
--- a/remoting/client/chromoting_view.h
+++ b/remoting/client/chromoting_view.h
@@ -73,10 +73,6 @@ class ChromotingView {
// extends past the end of the backing store, it is filled with black.
virtual void SetViewport(int x, int y, int width, int height) = 0;
- // Converts screen co-ordinates to host co-ordinates, and clips to the host
- // screen.
- virtual gfx::Point ConvertScreenToHost(const gfx::Point& p) const = 0;
-
protected:
// Framebuffer for the decoder.
scoped_refptr<media::VideoFrame> frame_;
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index a83c053..af21adc 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -201,14 +201,17 @@ bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) {
return true;
}
- case PP_INPUTEVENT_TYPE_KEYDOWN:
+ case PP_INPUTEVENT_TYPE_KEYDOWN: {
+ pp::KeyboardInputEvent key = pp::KeyboardInputEvent(event);
+ logger_.VLog(3, "PP_INPUTEVENT_TYPE_KEYDOWN key=%d", key.GetKeyCode());
+ pih->HandleKeyEvent(true, key);
+ return true;
+ }
+
case PP_INPUTEVENT_TYPE_KEYUP: {
- pp::KeyboardInputEvent key_event(event);
- logger_.VLog(3, "PP_INPUTEVENT_TYPE_KEY%s key=%d",
- (event.GetType()==PP_INPUTEVENT_TYPE_KEYDOWN ? "DOWN" : "UP"),
- key_event.GetKeyCode());
- pih->HandleKeyEvent(event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN,
- key_event);
+ pp::KeyboardInputEvent key = pp::KeyboardInputEvent(event);
+ logger_.VLog(3, "PP_INPUTEVENT_TYPE_KEYUP key=%d", key.GetKeyCode());
+ pih->HandleKeyEvent(false, key);
return true;
}
@@ -217,8 +220,10 @@ bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) {
return true;
}
- default:
+ default: {
+ LOG(INFO) << "Unhandled input event: " << event.GetType();
break;
+ }
}
return false;
diff --git a/remoting/client/plugin/pepper_input_handler.cc b/remoting/client/plugin/pepper_input_handler.cc
index 01fd250..887338c 100644
--- a/remoting/client/plugin/pepper_input_handler.cc
+++ b/remoting/client/plugin/pepper_input_handler.cc
@@ -4,11 +4,9 @@
#include "remoting/client/plugin/pepper_input_handler.h"
-#include "ppapi/c/pp_input_event.h"
#include "ppapi/cpp/input_event.h"
#include "ppapi/cpp/point.h"
-#include "remoting/client/chromoting_view.h"
-#include "ui/gfx/point.h"
+#include "remoting/client/plugin/pepper_view_proxy.h"
namespace remoting {
@@ -19,8 +17,9 @@ using protocol::MouseEvent;
PepperInputHandler::PepperInputHandler(ClientContext* context,
protocol::ConnectionToHost* connection,
- ChromotingView* view)
- : InputHandler(context, connection, view) {
+ PepperViewProxy* view)
+ : InputHandler(context, connection, view),
+ pepper_view_(view) {
}
PepperInputHandler::~PepperInputHandler() {
@@ -30,32 +29,40 @@ void PepperInputHandler::Initialize() {
}
void PepperInputHandler::HandleKeyEvent(bool keydown,
- const KeyboardInputEvent& event) {
+ const pp::KeyboardInputEvent& event) {
SendKeyEvent(keydown, event.GetKeyCode());
}
-void PepperInputHandler::HandleCharacterEvent(const KeyboardInputEvent& event) {
+void PepperInputHandler::HandleCharacterEvent(
+ const pp::KeyboardInputEvent& event) {
// TODO(garykac): Coordinate key and char events.
}
-void PepperInputHandler::HandleMouseMoveEvent(const MouseInputEvent& event) {
- gfx::Point p(static_cast<int>(event.GetPosition().x()),
- static_cast<int>(event.GetPosition().y()));
+void PepperInputHandler::HandleMouseMoveEvent(
+ const pp::MouseInputEvent& event) {
// Pepper gives co-ordinates in the plugin instance's co-ordinate system,
// which may be different from the host desktop's co-ordinate system.
- p = view_->ConvertScreenToHost(p);
+ pp::Point p = pepper_view_->ConvertScreenToHost(event.GetPosition());
SendMouseMoveEvent(p.x(), p.y());
}
-void PepperInputHandler::HandleMouseButtonEvent(bool button_down,
- const MouseInputEvent& event) {
+void PepperInputHandler::HandleMouseButtonEvent(
+ bool button_down,
+ const pp::MouseInputEvent& event) {
MouseEvent::MouseButton button = MouseEvent::BUTTON_UNDEFINED;
- if (event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_LEFT) {
- button = MouseEvent::BUTTON_LEFT;
- } else if (event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_MIDDLE) {
- button = MouseEvent::BUTTON_MIDDLE;
- } else if (event.GetButton() == PP_INPUTEVENT_MOUSEBUTTON_RIGHT) {
- button = MouseEvent::BUTTON_RIGHT;
+ switch (event.GetButton()) {
+ case PP_INPUTEVENT_MOUSEBUTTON_LEFT:
+ button = MouseEvent::BUTTON_LEFT;
+ break;
+ case PP_INPUTEVENT_MOUSEBUTTON_MIDDLE:
+ button = MouseEvent::BUTTON_MIDDLE;
+ break;
+ case PP_INPUTEVENT_MOUSEBUTTON_RIGHT:
+ button = MouseEvent::BUTTON_RIGHT;
+ break;
+ case PP_INPUTEVENT_MOUSEBUTTON_NONE:
+ // Leave button undefined.
+ break;
}
if (button != MouseEvent::BUTTON_UNDEFINED) {
diff --git a/remoting/client/plugin/pepper_input_handler.h b/remoting/client/plugin/pepper_input_handler.h
index 5a19f88..7c1c0a9 100644
--- a/remoting/client/plugin/pepper_input_handler.h
+++ b/remoting/client/plugin/pepper_input_handler.h
@@ -7,9 +7,11 @@
#include "remoting/client/input_handler.h"
-struct PP_InputEvent_Character;
-struct PP_InputEvent_Key;
-struct PP_InputEvent_Mouse;
+namespace pp {
+class KeyboardInputEvent;
+class MouseInputEvent;
+class WheelInputEvent;
+}
namespace pp {
class KeyboardInputEvent;
@@ -18,11 +20,13 @@ class MouseInputEvent;
namespace remoting {
+class PepperViewProxy;
+
class PepperInputHandler : public InputHandler {
public:
PepperInputHandler(ClientContext* context,
protocol::ConnectionToHost* connection,
- ChromotingView* view);
+ PepperViewProxy* view);
virtual ~PepperInputHandler();
virtual void Initialize();
@@ -35,6 +39,8 @@ class PepperInputHandler : public InputHandler {
const pp::MouseInputEvent& event);
private:
+ PepperViewProxy* pepper_view_;
+
DISALLOW_COPY_AND_ASSIGN(PepperInputHandler);
};
diff --git a/remoting/client/plugin/pepper_view.cc b/remoting/client/plugin/pepper_view.cc
index bf5ae1c..6558a04 100644
--- a/remoting/client/plugin/pepper_view.cc
+++ b/remoting/client/plugin/pepper_view.cc
@@ -130,10 +130,10 @@ void PepperView::PaintFrame(media::VideoFrame* frame, UpdatedRects* rects) {
}
if (DoScaling()) {
- gfx::Rect r_scaled = UpdateScaledBackingStore(r);
+ pp::Rect r_scaled = UpdateScaledBackingStore(
+ pp::Rect(r.x(), r.y(), r.width(), r.height()));
graphics2d_.PaintImageData(*scaled_backing_store_.get(), pp::Point(0, 0),
- pp::Rect(r_scaled.x(), r_scaled.y(),
- r_scaled.width(), r_scaled.height()));
+ r_scaled);
} else {
// Pepper Graphics 2D has a strange and badly documented API that the
// point here is the offset from the source rect. Why?
@@ -149,18 +149,18 @@ void PepperView::PaintFrame(media::VideoFrame* frame, UpdatedRects* rects) {
TraceContext::tracer()->PrintString("End Paint Frame.");
}
-gfx::Rect PepperView::UpdateScaledBackingStore(const gfx::Rect& r) {
+pp::Rect PepperView::UpdateScaledBackingStore(const pp::Rect& r) {
const int kBytesPerPixel = GetBytesPerPixel(media::VideoFrame::RGB32);
// Find the updated rectangle in the scaled backing store.
- gfx::Point top_left = ConvertHostToScreen(r.origin());
- gfx::Point bottom_right = ConvertHostToScreen(gfx::Point(r.right(),
- r.bottom()));
+ pp::Point top_left = ConvertHostToScreen(r.point());
+ pp::Point bottom_right = ConvertHostToScreen(pp::Point(r.right(),
+ r.bottom()));
int r_scaled_left = top_left.x();
int r_scaled_right = bottom_right.x();
int r_scaled_top = top_left.y();
int r_scaled_bottom = bottom_right.y();
if (r_scaled_right <= r_scaled_left || r_scaled_bottom <= r_scaled_top)
- return gfx::Rect(r_scaled_left, r_scaled_top, 0, 0);
+ return pp::Rect(r_scaled_left, r_scaled_top, 0, 0);
// Allow for the fact that ConvertHostToScreen and ConvertScreenToHost aren't
// exact inverses.
@@ -179,7 +179,7 @@ gfx::Rect PepperView::UpdateScaledBackingStore(const gfx::Rect& r) {
// Blit from the backing store to the scaled backing store.
for (int y_scaled = r_scaled_top; y_scaled < r_scaled_bottom; y_scaled++) {
- int y = ConvertScreenToHost(gfx::Point(0, y_scaled)).y();
+ int y = ConvertScreenToHost(pp::Point(0, y_scaled)).y();
// Special case where each pixel is a word.
if ((kBytesPerPixel == 4) && (backing_store_->stride() % 4 == 0) &&
(scaled_backing_store_->stride() % 4 == 0)) {
@@ -206,11 +206,11 @@ gfx::Rect PepperView::UpdateScaledBackingStore(const gfx::Rect& r) {
}
}
}
- return gfx::Rect(r_scaled_left, r_scaled_top, r_scaled_right - r_scaled_left,
- r_scaled_bottom - r_scaled_top);
+ return pp::Rect(r_scaled_left, r_scaled_top, r_scaled_right - r_scaled_left,
+ r_scaled_bottom - r_scaled_top);
}
-void PepperView::BlankRect(pp::ImageData& image_data, const gfx::Rect& rect) {
+void PepperView::BlankRect(pp::ImageData& image_data, const pp::Rect& rect) {
const int kBytesPerPixel = GetBytesPerPixel(media::VideoFrame::RGB32);
for (int y = rect.y(); y < rect.bottom(); y++) {
uint8* to = reinterpret_cast<uint8*>(image_data.data()) +
@@ -285,7 +285,7 @@ void PepperView::SetViewport(int x, int y, int width, int height) {
instance_->GetScriptableObject()->SetDesktopSize(host_width_, host_height_);
}
-gfx::Point PepperView::ConvertScreenToHost(const gfx::Point& p) const {
+pp::Point PepperView::ConvertScreenToHost(const pp::Point& p) const {
DCHECK(CurrentlyOnPluginThread());
int x = static_cast<int>(p.x() / screen_scale_);
@@ -294,11 +294,11 @@ gfx::Point PepperView::ConvertScreenToHost(const gfx::Point& p) const {
int y = static_cast<int>(p.y() / screen_scale_);
y = std::min(y, host_height_ - 1);
y = std::max(y, 0);
- return gfx::Point(x, y);
+ return pp::Point(x, y);
}
-gfx::Point PepperView::ConvertHostToScreen(const gfx::Point& p) const {
- return gfx::Point(static_cast<int>(p.x() * screen_scale_),
+pp::Point PepperView::ConvertHostToScreen(const pp::Point& p) const {
+ return pp::Point(static_cast<int>(p.x() * screen_scale_),
static_cast<int>(p.y() * screen_scale_));
}
@@ -314,18 +314,18 @@ void PepperView::RefreshPaint() {
if (DoScaling()) {
// Render from the whole backing store, to the scaled backing store, at the
// current scale.
- gfx::Rect updated_rect = UpdateScaledBackingStore(gfx::Rect(
+ pp::Rect updated_rect = UpdateScaledBackingStore(pp::Rect(
host_width_, host_height_));
// If the scale has just decreased, then there is stale raster data
// to the right of, and below, the scaled copy of the host screen that's
// just been rendered into the scaled backing store.
// So blank out everything to the east of that copy...
- BlankRect(*scaled_backing_store_, gfx::Rect(
+ BlankRect(*scaled_backing_store_, pp::Rect(
updated_rect.right(), 0,
scaled_backing_store_->size().width() - updated_rect.right(),
updated_rect.bottom()));
// ...and everything to the south and south-east.
- BlankRect(*scaled_backing_store_, gfx::Rect(
+ BlankRect(*scaled_backing_store_, pp::Rect(
0, updated_rect.bottom(), scaled_backing_store_->size().width(),
scaled_backing_store_->size().height() - updated_rect.bottom()));
graphics2d_.PaintImageData(*scaled_backing_store_.get(), pp::Point(0, 0),
@@ -384,7 +384,7 @@ void PepperView::ResizeInternals() {
// to host screen co-ordinates.
screen_x_to_host_x_.reset(new int[client_width_]);
for (int x = 0; x < client_width_; x++)
- screen_x_to_host_x_[x] = ConvertScreenToHost(gfx::Point(x, 0)).x();
+ screen_x_to_host_x_[x] = ConvertScreenToHost(pp::Point(x, 0)).x();
}
bool PepperView::DoScaling() const {
diff --git a/remoting/client/plugin/pepper_view.h b/remoting/client/plugin/pepper_view.h
index e869d91..3e2f8a8 100644
--- a/remoting/client/plugin/pepper_view.h
+++ b/remoting/client/plugin/pepper_view.h
@@ -14,6 +14,7 @@
#include "base/task.h"
#include "media/base/video_frame.h"
#include "ppapi/cpp/graphics_2d.h"
+#include "ppapi/cpp/point.h"
#include "remoting/client/chromoting_view.h"
#include "remoting/client/frame_consumer.h"
@@ -40,7 +41,6 @@ class PepperView : public ChromotingView,
virtual void UpdateLoginStatus(bool success, const std::string& info)
OVERRIDE;
virtual void SetViewport(int x, int y, int width, int height) OVERRIDE;
- virtual gfx::Point ConvertScreenToHost(const gfx::Point& p) const OVERRIDE;
// FrameConsumer implementation.
virtual void AllocateFrame(media::VideoFrame::Format format,
@@ -55,6 +55,10 @@ class PepperView : public ChromotingView,
UpdatedRects* rects,
Task* done);
+ // Converts screen co-ordinates to host co-ordinates, and clips to the host
+ // screen.
+ pp::Point ConvertScreenToHost(const pp::Point& p) const;
+
// Sets the size of the visible screen area that this object can render into.
void SetScreenSize(int width, int height);
@@ -68,13 +72,13 @@ class PepperView : public ChromotingView,
// Blits the pixels in |r| in the backing store into the corresponding
// rectangle in the scaled backing store. Returns that rectangle.
- gfx::Rect UpdateScaledBackingStore(const gfx::Rect& r);
+ pp::Rect UpdateScaledBackingStore(const pp::Rect& r);
// Blanks out a rectangle in an image.
- void BlankRect(pp::ImageData& image_data, const gfx::Rect& rect);
+ void BlankRect(pp::ImageData& image_data, const pp::Rect& rect);
// Converts host co-ordinates to screen co-ordinates.
- gfx::Point ConvertHostToScreen(const gfx::Point& p) const;
+ pp::Point ConvertHostToScreen(const pp::Point& p) const;
// Sets the screen scale. A value of 1.0 indicates no scaling.
void SetScreenScale(double screen_scale);
diff --git a/remoting/client/plugin/pepper_view_proxy.cc b/remoting/client/plugin/pepper_view_proxy.cc
index 5f523a1..ad4557d 100644
--- a/remoting/client/plugin/pepper_view_proxy.cc
+++ b/remoting/client/plugin/pepper_view_proxy.cc
@@ -103,14 +103,14 @@ void PepperViewProxy::SetViewport(int x, int y, int width, int height) {
view_->SetViewport(x, y, width, height);
}
-gfx::Point PepperViewProxy::ConvertScreenToHost(const gfx::Point& p) const {
+pp::Point PepperViewProxy::ConvertScreenToHost(const pp::Point& p) const {
// This method returns a value, so must run synchronously, so must be
// called only on the pepper thread.
DCHECK(CurrentlyOnPluginThread());
if (view_)
return view_->ConvertScreenToHost(p);
- return gfx::Point();
+ return pp::Point();
}
void PepperViewProxy::AllocateFrame(
diff --git a/remoting/client/plugin/pepper_view_proxy.h b/remoting/client/plugin/pepper_view_proxy.h
index d9075442..a34a3c5 100644
--- a/remoting/client/plugin/pepper_view_proxy.h
+++ b/remoting/client/plugin/pepper_view_proxy.h
@@ -41,9 +41,6 @@ class PepperViewProxy : public base::RefCountedThreadSafe<PepperViewProxy>,
virtual void UpdateLoginStatus(bool success, const std::string& info)
OVERRIDE;
virtual void SetViewport(int x, int y, int width, int height) OVERRIDE;
- // This method returns a value, so must run synchronously, so must be
- // called only on the pepper thread.
- virtual gfx::Point ConvertScreenToHost(const gfx::Point& p) const OVERRIDE;
// FrameConsumer implementation.
virtual void AllocateFrame(media::VideoFrame::Format format,
@@ -60,6 +57,10 @@ class PepperViewProxy : public base::RefCountedThreadSafe<PepperViewProxy>,
void SetScaleToFit(bool scale_to_fit);
+ // This method returns a value, so must run synchronously, so must be
+ // called only on the pepper thread.
+ pp::Point ConvertScreenToHost(const pp::Point& p) const;
+
// Remove the reference to |instance_| and |view_| by setting the value to
// NULL.
// This method should only be called on pepper thread.