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

Unified Diff: remoting/capturer/video_frame_capturer_mac.mm

Issue 11470028: Move screen capturers to remoting/capturer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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/capturer/video_frame_capturer_mac.mm
diff --git a/remoting/host/video_frame_capturer_mac.mm b/remoting/capturer/video_frame_capturer_mac.mm
similarity index 94%
rename from remoting/host/video_frame_capturer_mac.mm
rename to remoting/capturer/video_frame_capturer_mac.mm
index 3d0d62490ae8314d592de669ca13c29f6b94e707..40c5765926b11d8214f41e8a68076cfbf6bd3390 100644
--- a/remoting/host/video_frame_capturer_mac.mm
+++ b/remoting/capturer/video_frame_capturer_mac.mm
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "remoting/host/video_frame_capturer.h"
+#include "remoting/capturer/video_frame_capturer.h"
#include <ApplicationServices/ApplicationServices.h>
#include <Cocoa/Cocoa.h>
@@ -21,13 +21,12 @@
#include "base/scoped_native_library.h"
#include "base/synchronization/waitable_event.h"
#include "base/time.h"
-#include "remoting/base/capture_data.h"
-#include "remoting/base/util.h"
-#include "remoting/host/mac/scoped_pixel_buffer_object.h"
-#include "remoting/host/video_frame.h"
-#include "remoting/host/video_frame_capturer_helper.h"
-#include "remoting/host/video_frame_queue.h"
-#include "remoting/proto/control.pb.h"
+#include "remoting/capturer/capture_data.h"
+#include "remoting/capturer/mac/scoped_pixel_buffer_object.h"
+#include "remoting/capturer/mouse_cursor_shape.h"
+#include "remoting/capturer/video_frame.h"
+#include "remoting/capturer/video_frame_capturer_helper.h"
+#include "remoting/capturer/video_frame_queue.h"
namespace remoting {
@@ -55,6 +54,30 @@ SkIRect CGRectToSkIRect(const CGRect& rect) {
return sk_rect;
}
+// Copy pixels in the |rect| from |src_place| to |dest_plane|.
+void CopyRect(const uint8* src_plane,
+ int src_plane_stride,
+ uint8* dest_plane,
+ int dest_plane_stride,
+ int bytes_per_pixel,
+ const SkIRect& rect) {
+ // Get the address of the starting point.
+ const int src_y_offset = src_plane_stride * rect.top();
+ const int dest_y_offset = dest_plane_stride * rect.top();
+ const int x_offset = bytes_per_pixel * rect.left();
+ src_plane += src_y_offset + x_offset;
+ dest_plane += dest_y_offset + x_offset;
+
+ // Copy pixels in the rectangle line by line.
+ const int bytes_per_line = bytes_per_pixel * rect.width();
+ const int height = rect.height();
+ for (int i = 0 ; i < height; ++i) {
+ memcpy(dest_plane, src_plane, bytes_per_line);
+ src_plane += src_plane_stride;
+ dest_plane += dest_plane_stride;
+ }
+}
+
// The amount of time allowed for displays to reconfigure.
const int64 kDisplayConfigurationEventTimeoutInSeconds = 10;
@@ -421,6 +444,9 @@ void VideoFrameCapturerMac::CaptureCursor() {
}
}
+ // Record the last cursor image.
+ current_cursor_.reset(CGImageCreateCopy(image));
+
VLOG(3) << "Sending cursor: " << size.width << "x" << size.height;
CGDataProviderRef provider = CGImageGetDataProvider(image);
@@ -429,27 +455,18 @@ void VideoFrameCapturerMac::CaptureCursor() {
if (image_data_ref.get() == NULL) {
return;
}
- const uint8* cursor_src_data = CFDataGetBytePtr(image_data_ref);
+ const char* cursor_src_data =
+ reinterpret_cast<const char*>(CFDataGetBytePtr(image_data_ref));
int data_size = CFDataGetLength(image_data_ref);
- // Create a CursorShapeInfo proto that describes the cursor and pass it to
+ // Create a MouseCursorShape that describes the cursor and pass it to
// the client.
- scoped_ptr<protocol::CursorShapeInfo> cursor_proto(
- new protocol::CursorShapeInfo());
- cursor_proto->mutable_data()->resize(data_size);
- uint8* cursor_tgt_data = const_cast<uint8*>(reinterpret_cast<const uint8*>(
- cursor_proto->mutable_data()->data()));
-
- memcpy(cursor_tgt_data, cursor_src_data, data_size);
+ scoped_ptr<MouseCursorShape> cursor_shape(new MouseCursorShape());
+ cursor_shape->size.set(size.width, size.height);
+ cursor_shape->hotspot.set(hotspot.x, hotspot.y);
+ cursor_shape->data.assign(cursor_src_data, cursor_src_data + data_size);
- cursor_proto->set_width(size.width);
- cursor_proto->set_height(size.height);
- cursor_proto->set_hotspot_x(hotspot.x);
- cursor_proto->set_hotspot_y(hotspot.y);
- delegate_->OnCursorShapeChanged(cursor_proto.Pass());
-
- // Record the last cursor image that we sent.
- current_cursor_.reset(CGImageCreateCopy(image));
+ delegate_->OnCursorShapeChanged(cursor_shape.Pass());
}
void VideoFrameCapturerMac::GlBlitFast(const VideoFrame& buffer,
« no previous file with comments | « remoting/capturer/video_frame_capturer_linux.cc ('k') | remoting/capturer/video_frame_capturer_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698