| 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..d6b95041f509c9d690364605c4db38f8369178d3 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,12 @@ 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.
|
| - bool CopyTo(const gfx::Rect& src_pixel_subrect,
|
| + // |callback| is invoked when the operation is completed or failed.
|
| + // Do no call this method again before |callback| is invoked.
|
| + 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 +148,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;
|
| + 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 +207,9 @@ class CompositingIOSurfaceMac {
|
| void StartOrContinueDisplayLink();
|
| void StopDisplayLink();
|
|
|
| + void FinishCopy();
|
| + void CleanupResourcesForCopy();
|
| +
|
| // Cached pointer to IOSurfaceSupport Singleton.
|
| IOSurfaceSupport* io_surface_support_;
|
|
|
| @@ -194,6 +232,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_;
|
|
|