| Index: content/browser/compositor/io_surface_layer_mac.h
|
| diff --git a/content/browser/renderer_host/compositing_iosurface_layer_mac.h b/content/browser/compositor/io_surface_layer_mac.h
|
| similarity index 44%
|
| rename from content/browser/renderer_host/compositing_iosurface_layer_mac.h
|
| rename to content/browser/compositor/io_surface_layer_mac.h
|
| index a01b6fc125ce6fa609b61c09ce6a7a8337a5e0bc..65df67277f996403853ce24dea654663fbc8f9c4 100644
|
| --- a/content/browser/renderer_host/compositing_iosurface_layer_mac.h
|
| +++ b/content/browser/compositor/io_surface_layer_mac.h
|
| @@ -2,91 +2,72 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_LAYER_MAC_H_
|
| -#define CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_LAYER_MAC_H_
|
| +#ifndef CONTENT_BROWSER_COMPOSITOR_IO_SURFACE_LAYER_MAC_H_
|
| +#define CONTENT_BROWSER_COMPOSITOR_IO_SURFACE_LAYER_MAC_H_
|
|
|
| #import <Cocoa/Cocoa.h>
|
| +#include <IOSurface/IOSurfaceAPI.h>
|
|
|
| #include "base/mac/scoped_cftyperef.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/timer/timer.h"
|
| +#include "ui/gfx/size.h"
|
|
|
| -@class CompositingIOSurfaceLayer;
|
| +@class IOSurfaceLayer;
|
|
|
| namespace content {
|
| class CompositingIOSurfaceMac;
|
| class CompositingIOSurfaceContext;
|
|
|
| -// The interface through which the CompositingIOSurfaceLayer calls back into
|
| +// The interface through which the IOSurfaceLayer calls back into
|
| // the structrue that created it (RenderWidgetHostViewMac or
|
| // BrowserCompositorViewMac).
|
| -class CompositingIOSurfaceLayerClient {
|
| +class IOSurfaceLayerClient {
|
| public:
|
| // Used to indicate that the layer should attempt to draw immediately and
|
| // should (even if the draw is elided by the system), ack the frame
|
| // immediately.
|
| - virtual bool AcceleratedLayerShouldAckImmediately() const = 0;
|
| + virtual bool IOSurfaceLayerShouldAckImmediately() const = 0;
|
|
|
| // Called when a frame is drawn or when, because the layer is not visible, it
|
| // is known that the frame will never drawn.
|
| - virtual void AcceleratedLayerDidDrawFrame() = 0;
|
| + virtual void IOSurfaceLayerDidDrawFrame() = 0;
|
|
|
| // Called when an error prevents the frame from being drawn.
|
| - virtual void AcceleratedLayerHitError() = 0;
|
| + virtual void IOSurfaceLayerHitError() = 0;
|
| };
|
|
|
| -// CompositingIOSurfaceLayerHelper provides C++ functionality needed for the
|
| -// CompositingIOSurfaceLayer class, and does most of the heavy lifting for the
|
| +// IOSurfaceLayerHelper provides C++ functionality needed for the
|
| +// IOSurfaceLayer class, and does most of the heavy lifting for the
|
| // class.
|
| -// TODO(ccameron): This class should own CompositingIOSurfaceLayer, rather than
|
| +// TODO(ccameron): This class should own IOSurfaceLayer, rather than
|
| // vice versa.
|
| -class CompositingIOSurfaceLayerHelper {
|
| +class IOSurfaceLayerHelper {
|
| public:
|
| - CompositingIOSurfaceLayerHelper(CompositingIOSurfaceLayerClient* client,
|
| - CompositingIOSurfaceLayer* layer);
|
| - ~CompositingIOSurfaceLayerHelper();
|
| -
|
| - // Called when the CompositingIOSurfaceLayer gets a new frame.
|
| - void GotNewFrame();
|
| -
|
| - // Called whenever -[CompositingIOSurfaceLayer setNeedsDisplay] is called.
|
| - void SetNeedsDisplay();
|
| -
|
| - // Called whenever -[CompositingIOSurfaceLayer canDrawInCGLContext] is called,
|
| - // to determine if a new frame should be drawn.
|
| - bool CanDraw();
|
| -
|
| - // Called whenever -[CompositingIOSurfaceLayer drawInCGLContext] draws a
|
| - // frame.
|
| - void DidDraw(bool success);
|
| -
|
| - // Immediately re-draw the layer, even if the content has not changed, and
|
| - // ensure that the frame be acked.
|
| - void SetNeedsDisplayAndDisplayAndAck();
|
| -
|
| - // Immediately draw the layer, only if one is pending, and ensure that the
|
| - // frame be acked.
|
| - void DisplayIfNeededAndAck();
|
| -
|
| - // Mark a bracket in which new frames are being pumped in a restricted nested
|
| - // run loop. During this time frames are acked immediately and draws are
|
| - // deferred until the bracket ends.
|
| - void BeginPumpingFrames();
|
| - void EndPumpingFrames();
|
| + IOSurfaceLayerHelper(IOSurfaceLayer* layer);
|
| + ~IOSurfaceLayerHelper();
|
| + void ResetTimer();
|
|
|
| private:
|
| - // Called whenever the frame provided in GotNewFrame should be acknowledged
|
| - // (this may be because it was drawn, or it may be to unblock the
|
| - // compositor).
|
| - void AckPendingFrame(bool success);
|
| -
|
| void TimerFired();
|
|
|
| - // The client that the owning layer was created with.
|
| - content::CompositingIOSurfaceLayerClient* const client_;
|
| -
|
| // The layer that owns this helper.
|
| - CompositingIOSurfaceLayer* const layer_;
|
| + IOSurfaceLayer* const layer_;
|
| +
|
| + // The browser places back-pressure on the GPU by not acknowledging swap
|
| + // calls until they appear on the screen. This can lead to hangs if the
|
| + // view is moved offscreen (among other things). Prevent hangs by always
|
| + // acknowledging the frame after timeout of 1/6th of a second has passed.
|
| + base::DelayTimer<IOSurfaceLayerHelper> timer_;
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +// The CoreAnimation layer for drawing accelerated content.
|
| +@interface IOSurfaceLayer : CAOpenGLLayer {
|
| + @private
|
| + content::IOSurfaceLayerClient* client_;
|
| + scoped_ptr<content::IOSurfaceLayerHelper> helper_;
|
|
|
| // Used to track when canDrawInCGLContext should return YES. This can be
|
| // in response to receiving a new compositor frame, or from any of the events
|
| @@ -103,39 +84,33 @@ class CompositingIOSurfaceLayerHelper {
|
| // Set when inside a BeginPumpingFrames/EndPumpingFrames block.
|
| bool is_pumping_frames_;
|
|
|
| - // The browser places back-pressure on the GPU by not acknowledging swap
|
| - // calls until they appear on the screen. This can lead to hangs if the
|
| - // view is moved offscreen (among other things). Prevent hangs by always
|
| - // acknowledging the frame after timeout of 1/6th of a second has passed.
|
| - base::DelayTimer<CompositingIOSurfaceLayerHelper> timer_;
|
| -};
|
| + // The IOSurface being drawn by this layer.
|
| + base::ScopedCFTypeRef<IOSurfaceRef> io_surface_;
|
|
|
| -} // namespace content
|
| + // The GL texture that is bound to |io_surface_|. If |io_surface_| changes,
|
| + // then this is marked as dirty by setting |io_surface_texture_dirty_|.
|
| + GLuint io_surface_texture_;
|
| + bool io_surface_texture_dirty_;
|
|
|
| -// The CoreAnimation layer for drawing accelerated content.
|
| -@interface CompositingIOSurfaceLayer : CAOpenGLLayer {
|
| - @private
|
| - scoped_refptr<content::CompositingIOSurfaceMac> iosurface_;
|
| - scoped_refptr<content::CompositingIOSurfaceContext> context_;
|
| -
|
| - scoped_ptr<content::CompositingIOSurfaceLayerHelper> helper_;
|
| + // The CGL renderer ID, captured at draw time.
|
| + GLint cgl_renderer_id_;
|
| }
|
|
|
| -- (content::CompositingIOSurfaceMac*)iosurface;
|
| -- (content::CompositingIOSurfaceContext*)context;
|
| +- (id)initWithClient:(content::IOSurfaceLayerClient*)client
|
| + withScaleFactor:(float)scale_factor;
|
| +
|
| +- (void)gotFrameWithIOSurface:(IOSurfaceID)io_surface_id
|
| + withPixelSize:(gfx::Size)pixel_size
|
| + withScaleFactor:(float)scale_factor;
|
|
|
| -- (id)initWithIOSurface:(scoped_refptr<content::CompositingIOSurfaceMac>)
|
| - iosurface
|
| - withScaleFactor:(float)scale_factor
|
| - withClient:(content::CompositingIOSurfaceLayerClient*)client;
|
| +- (float)scaleFactor;
|
| +- (int)rendererID;
|
| +- (void)timerFired;
|
|
|
| // Mark that the client is no longer valid and cannot be called back into. This
|
| // must be called before the layer is destroyed.
|
| - (void)resetClient;
|
|
|
| -// Called when a new frame is received.
|
| -- (void)gotNewFrame;
|
| -
|
| // Force a draw immediately (even if this means re-displaying a previously
|
| // displayed frame).
|
| - (void)setNeedsDisplayAndDisplayAndAck;
|
| @@ -149,4 +124,4 @@ class CompositingIOSurfaceLayerHelper {
|
| - (void)endPumpingFrames;
|
| @end
|
|
|
| -#endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_LAYER_MAC_H_
|
| +#endif // CONTENT_BROWSER_COMPOSITOR_IO_SURFACE_LAYER_MAC_H_
|
|
|