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

Unified Diff: content/browser/renderer_host/compositing_iosurface_mac.h

Issue 10917307: Implement asynchronous operation for RWHVP::CopyFromCompositingSurface on Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mazda comments Created 8 years, 3 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: content/browser/renderer_host/compositing_iosurface_mac.h
diff --git a/content/browser/renderer_host/compositing_iosurface_mac.h b/content/browser/renderer_host/compositing_iosurface_mac.h
index 7fa3ece56d9019857da09978ac759dd59068797c..eeedd85d47a6358391c3ffb68930f0a0095b6965 100644
--- a/content/browser/renderer_host/compositing_iosurface_mac.h
+++ b/content/browser/renderer_host/compositing_iosurface_mac.h
@@ -9,12 +9,14 @@
#import <QuartzCore/CVDisplayLink.h>
#include <QuartzCore/QuartzCore.h>
+#include "base/callback.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/memory/scoped_nsobject.h"
#include "base/synchronization/lock.h"
#include "base/time.h"
#include "base/timer.h"
#include "ui/gfx/native_widget_types.h"
+#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
class IOSurfaceSupport;
@@ -49,9 +51,10 @@ class CompositingIOSurfaceMac {
// |src_pixel_subrect| and |dst_pixel_size| are not in DIP but in pixel.
// Caller must ensure that |out| is allocated with the size no less than
// |4 * dst_pixel_size.width() * dst_pixel_size.height()| bytes.
Nico 2012/09/22 11:12:21 Describe |callback|, mention that only one callbac
- bool CopyTo(const gfx::Rect& src_pixel_subrect,
+ void CopyTo(const gfx::Rect& src_pixel_subrect,
const gfx::Size& dst_pixel_size,
- void* out);
+ void* out,
+ const base::Callback<void(bool)>& callback);
// Unref the IOSurface and delete the associated GL texture. If the GPU
// process is no longer referencing it, this will delete the IOSurface.
@@ -143,6 +146,36 @@ class CompositingIOSurfaceMac {
SurfaceVertex verts_[4];
};
+ // Keeps track of states and buffers for asynchronous readback of IOSurface.
+ struct CopyContext {
+ CopyContext();
+ ~CopyContext();
+
+ void Reset() {
+ started = false;
+ cycles_elapsed = 0;
+ frame_buffer = 0;
+ frame_buffer_texture = 0;
+ pixel_buffer = 0;
+ use_fence = false;
+ fence = 0;
Nico 2012/09/22 11:12:21 you're not setting src_rect and dest_size to their
+ out_buf = NULL;
+ callback.Reset();
+ }
+
+ bool started;
+ int cycles_elapsed;
+ GLuint frame_buffer;
+ GLuint frame_buffer_texture;
+ GLuint pixel_buffer;
+ bool use_fence;
+ GLuint fence;
+ gfx::Rect src_rect;
+ gfx::Size dest_size;
+ void* out_buf;
+ base::Callback<void(bool)> callback;
+ };
+
CompositingIOSurfaceMac(IOSurfaceSupport* io_surface_support,
NSOpenGLContext* glContext,
CGLContextObj cglContext,
@@ -172,6 +205,9 @@ class CompositingIOSurfaceMac {
void StartOrContinueDisplayLink();
void StopDisplayLink();
+ void FinishCopy();
+ void CleanupResourcesForCopy();
+
// Cached pointer to IOSurfaceSupport Singleton.
IOSurfaceSupport* io_surface_support_;
@@ -194,6 +230,11 @@ class CompositingIOSurfaceMac {
// with it.
GLuint texture_;
+ CopyContext copy_context_;
+
+ // Timer for finishing a copy operation.
+ base::RepeatingTimer<CompositingIOSurfaceMac> copy_timer_;
+
// Shader parameters.
GLuint shader_program_blit_rgb_;
GLint blit_rgb_sampler_location_;

Powered by Google App Engine
This is Rietveld 408576698