Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Unified Diff: remoting/client/plugin/chromoting_instance.cc

Issue 10382184: [Chromoting] Initial plumbing for cursor shape. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unused vars. Fix Mac Capturer Unittest. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/client/plugin/chromoting_instance.h ('k') | remoting/client/plugin/pepper_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/plugin/chromoting_instance.cc
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index ddc6b97364cd191484cfc0ff1933299b898df4d6..2a2da9eaddeb39ffb5861bdcc6d658933f4b6282 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -23,6 +23,7 @@
#include "media/base/media.h"
#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/input_event.h"
+#include "ppapi/cpp/mouse_cursor.h"
#include "ppapi/cpp/rect.h"
// TODO(wez): Remove this when crbug.com/86353 is complete.
#include "ppapi/cpp/private/var_private.h"
@@ -51,6 +52,9 @@ namespace remoting {
namespace {
+// 32-bit BGRA is 4 bytes per pixel.
+const int kBytesPerPixel = 4;
+
const int kPerfStatsIntervalMs = 1000;
std::string ConnectionStateToString(ChromotingInstance::ConnectionState state) {
@@ -556,6 +560,52 @@ void ChromotingInstance::InjectClipboardEvent(
PostChromotingMessage("injectClipboardItem", data.Pass());
}
+void ChromotingInstance::SetCursorShape(
+ const protocol::CursorShapeInfo& cursor_shape) {
+ if (!cursor_shape.has_data() ||
+ !cursor_shape.has_width() ||
+ !cursor_shape.has_height() ||
+ !cursor_shape.has_hotspot_x() ||
+ !cursor_shape.has_hotspot_y()) {
+ return;
+ }
+
+ if (pp::ImageData::GetNativeImageDataFormat() !=
+ PP_IMAGEDATAFORMAT_BGRA_PREMUL) {
+ VLOG(2) << "Unable to set cursor shape - non-native image format";
+ return;
+ }
+
+ int width = cursor_shape.width();
+ int height = cursor_shape.height();
+
+ if (width > 32 || height > 32) {
+ VLOG(2) << "Cursor too large for SetCursor: "
+ << width << "x" << height << " > 32x32";
+ return;
+ }
+
+ int hotspot_x = cursor_shape.hotspot_x();
+ int hotspot_y = cursor_shape.hotspot_y();
+
+ pp::ImageData cursor_image(this, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::Size(width, height), false);
+
+ int bytes_per_row = width * kBytesPerPixel;
+ const uint8* src_row_data = reinterpret_cast<const uint8*>(
+ cursor_shape.data().data());
+ uint8* dst_row_data = reinterpret_cast<uint8*>(cursor_image.data());
+ for (int row = 0; row < height; row++) {
+ memcpy(dst_row_data, src_row_data, bytes_per_row);
+ src_row_data += bytes_per_row;
+ dst_row_data += cursor_image.stride();
+ }
+
+ pp::MouseCursor::SetCursor(this, PP_MOUSECURSOR_TYPE_CUSTOM,
+ cursor_image,
+ pp::Point(hotspot_x, hotspot_y));
+}
+
// static
void ChromotingInstance::RegisterLogMessageHandler() {
base::AutoLock lock(g_logging_lock.Get());
« no previous file with comments | « remoting/client/plugin/chromoting_instance.h ('k') | remoting/client/plugin/pepper_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698