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

Unified Diff: content/browser/compositor/browser_compositor_view_private_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: Rebase 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/compositor/browser_compositor_view_private_mac.h
diff --git a/content/browser/compositor/browser_compositor_view_private_mac.h b/content/browser/compositor/browser_compositor_view_private_mac.h
index c1b3fdbed1e3dbeb7278a32db7f89adee8cddee9..5b855ae85b6a48e7e781cb84018abd7cee04a17c 100644
--- a/content/browser/compositor/browser_compositor_view_private_mac.h
+++ b/content/browser/compositor/browser_compositor_view_private_mac.h
@@ -7,16 +7,71 @@
#include "content/browser/compositor/browser_compositor_view_mac.h"
+@class BrowserCompositorViewCocoa;
+
namespace content {
-class BrowserCompositorViewCocoaHelper;
-}
-// An NSView drawn by a ui::Compositor. This structure is expensive to create,
-// because it has a ui::Compositor. As a result, this structure may be recycled
-// across multiple BrowserCompositorViewMac objects.
-@interface BrowserCompositorViewCocoa : NSView {
+// BrowserCompositorViewCocoaClient is the interface through which
+// gfx::NativeWidget (aka NSView aka BrowserCompositorViewCocoa) calls back to
+// BrowserCompositorViewMacInternal.
+class BrowserCompositorViewCocoaClient {
+ public:
+ virtual void GotAcceleratedIOSurfaceFrame(
+ IOSurfaceID io_surface_id,
+ int output_surface_id,
+ const std::vector<ui::LatencyInfo>& latency_info,
+ gfx::Size pixel_size,
+ float scale_factor) = 0;
+
+ virtual void GotSoftwareFrame(
+ cc::SoftwareFrameData* frame_data,
+ float scale_factor,
+ SkCanvas* canvas) = 0;
+};
+
+// BrowserCompositorViewMacInternal owns a NSView and a ui::Compositor that
+// draws that view.
+class BrowserCompositorViewMacInternal
+ : public BrowserCompositorViewCocoaClient,
+ public CompositingIOSurfaceLayerClient {
+ public:
+ BrowserCompositorViewMacInternal();
+ virtual ~BrowserCompositorViewMacInternal();
+
+ void SetClient(BrowserCompositorViewMacClient* client);
+ void ResetClient();
+
+ ui::Compositor* compositor() const { return compositor_.get(); }
+
+ private:
+ // BrowserCompositorViewCocoaClient implementation:
+ virtual void GotAcceleratedIOSurfaceFrame(
+ IOSurfaceID io_surface_id,
+ int output_surface_id,
+ const std::vector<ui::LatencyInfo>& latency_info,
+ gfx::Size pixel_size,
+ float scale_factor) OVERRIDE;
+ virtual void GotSoftwareFrame(
+ cc::SoftwareFrameData* frame_data,
+ float scale_factor,
+ SkCanvas* canvas) OVERRIDE;
+
+ // CompositingIOSurfaceLayerClient implementation:
+ virtual void AcceleratedLayerDidDrawFrame(bool succeeded) OVERRIDE;
+
+ // The client of the BrowserCompositorViewMac that is using this as its
+ // internals.
+ BrowserCompositorViewMacClient* client_;
+
+ // The NSView drawn by the |compositor_|
+ base::scoped_nsobject<BrowserCompositorViewCocoa> cocoa_view_;
+
+ // The compositor drawing the contents of |cooca_view_|. Note that this must
+ // be declared after |cocoa_view_|, so that it be destroyed first (because it
+ // will reach into |cocoa_view_|).
scoped_ptr<ui::Compositor> compositor_;
+
// A flipped layer, which acts as the parent of the compositing and software
// layers. This layer is flipped so that the we don't need to recompute the
// origin for sub-layers when their position changes (this is impossible when
@@ -31,48 +86,21 @@ class BrowserCompositorViewCocoaHelper;
std::vector<ui::LatencyInfo> accelerated_latency_info_;
base::scoped_nsobject<SoftwareLayer> software_layer_;
+};
- content::BrowserCompositorViewMacClient* client_;
- scoped_ptr<content::BrowserCompositorViewCocoaHelper> helper_;
-}
-
-// Change the client and superview of the view. If this is set to NULL then
-// the compositor will be prepared to be recycled.
-- (void)setClient:(content::BrowserCompositorViewMacClient*)client;
-
-// This is called to destroy the underlying ui::Compositor, if it is known
-// that this will not be recycled again.
-- (void)destroyCompositor;
-
-// Access the underlying ui::Compositor for this view.
-- (ui::Compositor*)compositor;
-
-// Called when the accelerated or software layer draws its frame to the screen.
-- (void)layerDidDrawFrame;
-
-// Called when an error is encountered while drawing to the screen.
-- (void)gotAcceleratedLayerError;
-
-@end // BrowserCompositorViewCocoa
-
-namespace content {
-
-// This class implements the parts of BrowserCompositorViewCocoa that need to
-// be a C++ class and not an Objective C class.
-class BrowserCompositorViewCocoaHelper
- : public content::CompositingIOSurfaceLayerClient {
- public:
- BrowserCompositorViewCocoaHelper(BrowserCompositorViewCocoa* view)
- : view_(view) {}
- virtual ~BrowserCompositorViewCocoaHelper() {}
+} // namespace content
- private:
- // CompositingIOSurfaceLayerClient implementation:
- virtual void AcceleratedLayerDidDrawFrame(bool succeeded) OVERRIDE;
+// BrowserCompositorViewCocoa is the actual NSView to which the layers drawn
+// by the ui::Compositor are attached.
+@interface BrowserCompositorViewCocoa : NSView {
+ content::BrowserCompositorViewCocoaClient* client_;
+}
- BrowserCompositorViewCocoa* view_;
-};
+- (id)initWithClient:(content::BrowserCompositorViewCocoaClient*)client;
-} // namespace content
+// Mark that the client provided at initialization is no longer valid and may
+// not be called back into.
+- (void)resetClient;
+@end
#endif // CONTENT_BROWSER_COMPOSITOR_BROWSER_COMPOSITOR_VIEW_PRIVATE_MAC_H_

Powered by Google App Engine
This is Rietveld 408576698