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

Unified Diff: content/browser/compositor/io_surface_layer_mac.h

Issue 490393002: Simplify IOSurface CoreAnimation code: Part 2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Without the extra bit Created 6 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/compositor/io_surface_layer_mac.h
diff --git a/content/browser/compositor/io_surface_layer_mac.h b/content/browser/compositor/io_surface_layer_mac.h
index 83a6e43640b3a752d2e6124bf1dea7bb2dda6dac..11cc0ac57857898c533c806554835e3a22f005af 100644
--- a/content/browser/compositor/io_surface_layer_mac.h
+++ b/content/browser/compositor/io_surface_layer_mac.h
@@ -2,10 +2,11 @@
// 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"
@@ -15,8 +16,7 @@
@class IOSurfaceLayer;
namespace content {
-class CompositingIOSurfaceMac;
-class CompositingIOSurfaceContext;
+class IOSurfaceLayerHelper;
// The interface through which the IOSurfaceLayer calls back into
// the structrue that created it (RenderWidgetHostViewMac or
@@ -36,58 +36,13 @@ class IOSurfaceLayerClient {
virtual void IOSurfaceLayerHitError() = 0;
};
-// 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 IOSurfaceLayer, rather than
-// vice versa.
-class IOSurfaceLayerHelper {
- public:
- IOSurfaceLayerHelper(IOSurfaceLayerClient* client,
- IOSurfaceLayer* layer);
- ~IOSurfaceLayerHelper();
-
- // Called when the IOSurfaceLayer gets a new frame.
- void GotNewFrame();
-
- // Called whenever -[IOSurfaceLayer setNeedsDisplay] is called.
- void SetNeedsDisplay();
-
- // Called whenever -[IOSurfaceLayer canDrawInCGLContext] is called,
- // to determine if a new frame should be drawn.
- bool CanDraw();
-
- // Called whenever -[IOSurfaceLayer 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();
-
- 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::IOSurfaceLayerClient* const client_;
+} // namespace content
- // The layer that owns this helper.
- IOSurfaceLayer* const layer_;
+// 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
@@ -104,35 +59,30 @@ class IOSurfaceLayerHelper {
// 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<IOSurfaceLayerHelper> timer_;
-};
+ // The IOSurface being drawn by this layer.
+ base::ScopedCFTypeRef<IOSurfaceRef> io_surface_;
-} // namespace content
+ // The size of the frame in pixels. This will be less or equal than the pixel
+ // size of |io_surface_|.
+ gfx::Size frame_pixel_size_;
-// The CoreAnimation layer for drawing accelerated content.
-@interface IOSurfaceLayer : CAOpenGLLayer {
- @private
- scoped_refptr<content::CompositingIOSurfaceMac> iosurface_;
- scoped_refptr<content::CompositingIOSurfaceContext> context_;
+ // 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_;
- scoped_ptr<content::IOSurfaceLayerHelper> helper_;
+ // The CGL renderer ID, captured at draw time.
+ GLint cgl_renderer_id_;
}
- (id)initWithClient:(content::IOSurfaceLayerClient*)client
withScaleFactor:(float)scale_factor;
-- (bool)gotFrameWithIOSurface:(IOSurfaceID)io_surface_id
+// Called when a new frame is received.
+- (void)gotFrameWithIOSurface:(IOSurfaceID)io_surface_id
withPixelSize:(gfx::Size)pixel_size
withScaleFactor:(float)scale_factor;
-// Context poison accessors.
-- (void)poisonContextAndSharegroup;
-- (bool)hasBeenPoisoned;
-
- (float)scaleFactor;
// The CGL renderer ID.
@@ -142,20 +92,14 @@ class IOSurfaceLayerHelper {
// 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;
-// Force a draw immediately, but only if one was requested.
-- (void)displayIfNeededAndAck;
-
// Mark a bracket in which new frames are being pumped in a restricted nested
// run loop.
- (void)beginPumpingFrames;
- (void)endPumpingFrames;
@end
-#endif // CONTENT_BROWSER_RENDERER_HOST_COMPOSITING_IOSURFACE_LAYER_MAC_H_
+#endif // CONTENT_BROWSER_COMPOSITOR_IO_SURFACE_LAYER_MAC_H_

Powered by Google App Engine
This is Rietveld 408576698