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

Unified Diff: remoting/host/capturer.h

Issue 2690003: Copy the (early prototype of) remoting in Chrome into the public tree.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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/simple_client.cc ('k') | remoting/host/capturer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/capturer.h
===================================================================
--- remoting/host/capturer.h (revision 0)
+++ remoting/host/capturer.h (revision 0)
@@ -0,0 +1,123 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_HOST_CAPTURER_H_
+#define REMOTING_HOST_CAPTURER_H_
+
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/task.h"
+#include "gfx/rect.h"
+#include "remoting/base/protocol/chromotocol.pb.h"
+
+namespace remoting {
+
+typedef std::vector<gfx::Rect> DirtyRects;
+
+// A class to perform the task of capturing the image of a window.
+// The capture action is asynchronous to allow maximum throughput.
+//
+// Implementation has to ensure the following gurantees:
+// 1. Double buffering
+// Since data can be read while another capture action is
+// happening.
+class Capturer {
+ public:
+ Capturer();
+ virtual ~Capturer();
+
+ // Capture the full screen. When the action is completed |done_task|
+ // is called.
+ //
+ // It is OK to call this methods while another thread is reading
+ // data of the last capture.
+ // There can be at most one concurrent read going on when this
+ // methods is called.
+ virtual void CaptureFullScreen(Task* done_task) = 0;
+
+ // Capture the updated regions since last capture. If the last
+ // capture doesn't exist, the full window is captured.
+ //
+ // When complete |done_task| is called.
+ //
+ // It is OK to call this method while another thread is reading
+ // data of the last capture.
+ // There can be at most one concurrent read going on when this
+ // methods is called.
+ virtual void CaptureDirtyRects(Task* done_task) = 0;
+
+ // Capture the specified screen rect and call |done_task| when complete.
+ // Dirty or invalid regions are ignored and only the given |rect| area is
+ // captured.
+ //
+ // It is OK to call this method while another thread is reading
+ // data of the last capture.
+ // There can be at most one concurrent read going on when this
+ // methods is called.
+ virtual void CaptureRect(const gfx::Rect& rect, Task* done_task) = 0;
+
+ // Get the image data of the last capture. The pointers to data is
+ // written to |planes|. |planes| should be an array of 3 elements.
+ virtual void GetData(const uint8* planes[]) const = 0;
+
+ // Get the image data stride of the last capture. This size of strides
+ // is written to |strides|. |strides| should be array of 3 elements.
+ virtual void GetDataStride(int strides[]) const = 0;
+
+ // Get the list of updated rectangles in the last capture. The result is
+ // written into |rects|.
+ virtual void GetDirtyRects(DirtyRects* rects) const;
+
+ // Get the width of the image captured.
+ virtual int GetWidth() const;
+
+ // Get the height of the image captured.
+ virtual int GetHeight() const;
+
+ // Get the pixel format of the image captured.
+ virtual chromotocol_pb::PixelFormat GetPixelFormat() const;
+
+ // Invalidate the specified screen rect.
+ virtual void InvalidateRect(gfx::Rect dirty);
+
+ protected:
+ // Finish/cleanup capture task.
+ // This should be called at the end of each of the CaptureXxx() routines.
+ // This routine should (at least):
+ // (1) Call the |done_task| routine.
+ // (2) Select the next screen buffer.
+ // Note that capturers are required to be double-buffered so that we can
+ // read from one which capturing into another.
+ virtual void FinishCapture(Task* done_task);
+
+ // Number of screen buffers.
+ static const int kNumBuffers = 2;
+
+ // Capture screen dimensions.
+ int width_;
+ int height_;
+
+ // Format of pixels returned in buffer.
+ chromotocol_pb::PixelFormat pixel_format_;
+
+ // Information about screen.
+ int bytes_per_pixel_;
+ int bytes_per_row_;
+
+ // The current buffer with valid data for reading.
+ int current_buffer_;
+
+ // List of dirty rects.
+ // These are the rects that we send to the client to update.
+ DirtyRects dirty_rects_;
+
+ // Rects that have been manually invalidated (through InvalidateRect).
+ // These will be merged into |dirty_rects_| during the next capture.
+ DirtyRects inval_rects_;
+};
+
+} // namespace remoting
+
+#endif // REMOTING_HOST_CAPTURER_H_
Property changes on: remoting/host/capturer.h
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « remoting/client/simple_client.cc ('k') | remoting/host/capturer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698