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

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

Issue 394883007: Mac: Shift more code into C++ classes from ObjC classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@flip_fix
Patch Set: Touch-ups Created 6 years, 5 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_layer_mac.h
diff --git a/content/browser/renderer_host/compositing_iosurface_layer_mac.h b/content/browser/renderer_host/compositing_iosurface_layer_mac.h
index 91033144f64e42f57b58ca914b43a4d508b05d12..8efe292e93236acea048d54d1729f86cebe4ab63 100644
--- a/content/browser/renderer_host/compositing_iosurface_layer_mac.h
+++ b/content/browser/renderer_host/compositing_iosurface_layer_mac.h
@@ -11,43 +11,85 @@
#include "base/memory/ref_counted.h"
#include "base/timer/timer.h"
+@class CompositingIOSurfaceLayer;
+
namespace content {
class CompositingIOSurfaceMac;
class CompositingIOSurfaceContext;
-class CompositingIOSurfaceLayerHelper;
+// The interface through which the CompositingIOSurfaceLayer calls back into
+// the structrue that created it (RenderWidgetHostViewMac or
+// BrowserCompositorViewMac).
class CompositingIOSurfaceLayerClient {
public:
virtual void AcceleratedLayerDidDrawFrame(bool succeeded) = 0;
};
+// CompositingIOSurfaceLayerHelper provides C++ functionality needed for the
+// CompositingIOSurfaceLayer class, and does most of the heavy lifting for the
+// class.
+// TODO(ccameron): This class should own CompositingIOSurfaceLayer, rather than
+// vice versa.
+class CompositingIOSurfaceLayerHelper {
+ public:
+ CompositingIOSurfaceLayerHelper(CompositingIOSurfaceLayerClient* client,
+ CompositingIOSurfaceLayer* layer);
+ ~CompositingIOSurfaceLayerHelper();
+
+ // Called when the CompositingIOSurfaceLayer gets a new frame.
+ void GotNewFrame();
+
+ // Called when -[CompositingIOSurfaceLayer canDrawInCGLContext] is called,
+ // and is passed the result that will be returned. This manages transitioning
+ // the layer in and out of asynchronous mode, and some logging.
+ void CanDrawCalled(bool needs_display);
+
+ // Called whenever -[CompositingIOSurfaceLayer drawInCGLContext] draws a
+ // frame, or when we need to ack a frame that (due to the vagaries of
+ // CoreAnimation) happens not to have drawn.
+ void AckPendingFrame(bool success);
+
+ // Immediately draw a frame (disregarding vsync) and ensure that the frame is
+ // acknowledged.
+ void ImmediatelyForceDisplayAndAck();
+
+ private:
+ void TimerFired();
+
+ // The client that the owning layer was created with.
+ content::CompositingIOSurfaceLayerClient* client_;
miu 2014/07/16 22:31:55 nit: Please make const since client_ is never modi
ccameron 2014/07/17 02:30:02 Done.
+
+ // The layer that owns this helper.
+ CompositingIOSurfaceLayer* layer_;
miu 2014/07/16 22:31:55 ditto: pointer should be const.
ccameron 2014/07/17 02:30:02 Done.
+
+ // This is set when a frame is received, and un-set when the frame is drawn.
+ bool has_pending_frame_;
+
+ // Incremented every time that this layer is asked to draw but does not have
+ // new content to draw.
+ uint64 did_not_draw_counter_;
+
+ // 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_;
+};
+
} // namespace content
// The CoreAnimation layer for drawing accelerated content.
@interface CompositingIOSurfaceLayer : CAOpenGLLayer {
@private
- content::CompositingIOSurfaceLayerClient* client_;
scoped_refptr<content::CompositingIOSurfaceMac> iosurface_;
scoped_refptr<content::CompositingIOSurfaceContext> context_;
- // 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.
scoped_ptr<content::CompositingIOSurfaceLayerHelper> helper_;
- scoped_ptr<base::DelayTimer<content::CompositingIOSurfaceLayerHelper>> timer_;
// 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
// that cause setNeedsDisplay to be called on the layer.
BOOL needs_display_;
miu 2014/07/16 22:31:55 IMHO, this state should be moved into the helper c
ccameron 2014/07/17 02:30:02 Moved.
-
- // This is set when a frame is received, and un-set when the frame is drawn.
- BOOL has_pending_frame_;
-
- // Incremented every time that this layer is asked to draw but does not have
- // new content to draw.
- uint64 did_not_draw_counter_;
}
- (content::CompositingIOSurfaceMac*)iosurface;
@@ -58,7 +100,8 @@ class CompositingIOSurfaceLayerClient {
withScaleFactor:(float)scale_factor
withClient:(content::CompositingIOSurfaceLayerClient*)client;
-// Mark that the client is no longer valid and cannot be called back into.
+// 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.

Powered by Google App Engine
This is Rietveld 408576698