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

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

Issue 10382184: [Chromoting] Initial plumbing for cursor shape. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Call SetCursor only for native format images 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
Index: remoting/client/plugin/pepper_view.cc
diff --git a/remoting/client/plugin/pepper_view.cc b/remoting/client/plugin/pepper_view.cc
index 6b67eacf77cf674332e270353e812ee77e032fbb..abf518160d5e80ad0eeba4e6cae82cc3cd572967 100644
--- a/remoting/client/plugin/pepper_view.cc
+++ b/remoting/client/plugin/pepper_view.cc
@@ -12,6 +12,7 @@
#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/graphics_2d.h"
#include "ppapi/cpp/image_data.h"
+#include "ppapi/cpp/mouse_cursor.h"
#include "ppapi/cpp/point.h"
#include "ppapi/cpp/rect.h"
#include "ppapi/cpp/size.h"
@@ -149,6 +150,51 @@ protocol::ClipboardStub* PepperView::GetClipboardStub() {
return instance_;
}
+void PepperView::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) {
+ LOG(WARNING) << "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) {
+ LOG(WARNING) << "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(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
+ pp::Size(width, height), false);
+
+ int bytes_per_row = width * 4;
+ 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(instance_, PP_MOUSECURSOR_TYPE_CUSTOM,
+ cursor_image,
+ pp::Point(hotspot_x, hotspot_y));
+}
+
void PepperView::SetView(const SkISize& view_size, const SkIRect& clip_area) {
bool view_changed = false;

Powered by Google App Engine
This is Rietveld 408576698