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

Side by Side 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: Remove extra LOGs 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/pepper_view.h" 5 #include "remoting/client/plugin/pepper_view.h"
6 6
7 #include <functional> 7 #include <functional>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
12 #include "ppapi/cpp/completion_callback.h" 12 #include "ppapi/cpp/completion_callback.h"
13 #include "ppapi/cpp/graphics_2d.h" 13 #include "ppapi/cpp/graphics_2d.h"
14 #include "ppapi/cpp/image_data.h" 14 #include "ppapi/cpp/image_data.h"
15 #include "ppapi/cpp/mouse_cursor.h"
15 #include "ppapi/cpp/point.h" 16 #include "ppapi/cpp/point.h"
16 #include "ppapi/cpp/rect.h" 17 #include "ppapi/cpp/rect.h"
17 #include "ppapi/cpp/size.h" 18 #include "ppapi/cpp/size.h"
18 #include "remoting/base/util.h" 19 #include "remoting/base/util.h"
19 #include "remoting/client/chromoting_stats.h" 20 #include "remoting/client/chromoting_stats.h"
20 #include "remoting/client/client_context.h" 21 #include "remoting/client/client_context.h"
21 #include "remoting/client/frame_producer.h" 22 #include "remoting/client/frame_producer.h"
22 #include "remoting/client/plugin/chromoting_instance.h" 23 #include "remoting/client/plugin/chromoting_instance.h"
23 #include "remoting/client/plugin/pepper_util.h" 24 #include "remoting/client/plugin/pepper_util.h"
24 25
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 ChromotingInstance::STATE_FAILED, 143 ChromotingInstance::STATE_FAILED,
143 ConvertConnectionError(error)); 144 ConvertConnectionError(error));
144 break; 145 break;
145 } 146 }
146 } 147 }
147 148
148 protocol::ClipboardStub* PepperView::GetClipboardStub() { 149 protocol::ClipboardStub* PepperView::GetClipboardStub() {
149 return instance_; 150 return instance_;
150 } 151 }
151 152
153 void PepperView::SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) {
154 if (!cursor_shape.has_data())
155 return;
156
157 int width = cursor_shape.width();
Wez 2012/05/23 00:01:57 This and the other fields you use below are option
garykac 2012/05/26 01:58:01 Done.
158 int height = cursor_shape.height();
159 int hotspot_x = cursor_shape.hotspot_x();
160 int hotspot_y = cursor_shape.hotspot_y();
161
162 pp::ImageData* cursor_image;
163 cursor_image = new pp::ImageData(instance_,
164 PP_IMAGEDATAFORMAT_BGRA_PREMUL,
165 pp::Size(width, height),
166 false);
Wez 2012/05/23 00:01:57 You're leaking the C++ wrapper for the ImageData r
garykac 2012/05/26 01:58:01 Done.
167
168 int total_bytes = width * height * 4;
169 memcpy(cursor_image->data(), cursor_shape.data().data(), total_bytes);
Wez 2012/05/23 00:01:57 Are we guaranteed that the stride of the ImageData
garykac 2012/05/26 01:58:01 Done.
170
171 // TODO(garykac) Use pp::ImageData::GetNativeImageDataFormat() and
172 // constrain to 32x32 pixels.
Wez 2012/05/23 00:01:57 nit: Clarify that this is because the SetCursor()
garykac 2012/05/26 01:58:01 Done.
173 pp::MouseCursor::SetCursor(instance_, PP_MOUSECURSOR_TYPE_CUSTOM,
174 *cursor_image,
175 pp::Point(hotspot_x, hotspot_y));
176 }
177
152 void PepperView::SetView(const SkISize& view_size, const SkIRect& clip_area) { 178 void PepperView::SetView(const SkISize& view_size, const SkIRect& clip_area) {
153 bool view_changed = false; 179 bool view_changed = false;
154 180
155 if (view_size_ != view_size) { 181 if (view_size_ != view_size) {
156 view_changed = true; 182 view_changed = true;
157 view_size_ = view_size; 183 view_size_ = view_size;
158 184
159 pp::Size pp_size = pp::Size(view_size_.width(), view_size_.height()); 185 pp::Size pp_size = pp::Size(view_size_.width(), view_size_.height());
160 graphics2d_ = pp::Graphics2D(instance_, pp_size, true); 186 graphics2d_ = pp::Graphics2D(instance_, pp_size, true);
161 bool result = instance_->BindGraphics(graphics2d_); 187 bool result = instance_->BindGraphics(graphics2d_);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 365
340 // If there is a buffer queued for rendering then render it now. 366 // If there is a buffer queued for rendering then render it now.
341 if (merge_buffer_ != NULL) { 367 if (merge_buffer_ != NULL) {
342 buffer = merge_buffer_; 368 buffer = merge_buffer_;
343 merge_buffer_ = NULL; 369 merge_buffer_ = NULL;
344 FlushBuffer(merge_clip_area_, buffer, merge_region_); 370 FlushBuffer(merge_clip_area_, buffer, merge_region_);
345 } 371 }
346 } 372 }
347 373
348 } // namespace remoting 374 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698