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

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

Issue 472663004: Revert of Remove code used by --disable-delegated-renderer on Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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/render_widget_host_view_mac.h
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.h b/content/browser/renderer_host/render_widget_host_view_mac.h
index f0bfe1b10ac677d4d863b2b1f277cd065f2fe964..235b1419355b24449320581db5b3afe4b698f4e7 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.h
+++ b/content/browser/renderer_host/render_widget_host_view_mac.h
@@ -37,6 +37,8 @@
namespace content {
class BrowserCompositorviewMac;
+class CompositingIOSurfaceMac;
+class CompositingIOSurfaceContext;
class RenderWidgetHostViewMac;
class RenderWidgetHostViewMacEditCommandHelper;
class WebContents;
@@ -47,8 +49,10 @@
class Layer;
}
+@class CompositingIOSurfaceLayer;
@class FullscreenWindowManager;
@protocol RenderWidgetHostViewMacDelegate;
+@class SoftwareLayer;
@class ToolTip;
@protocol RenderWidgetHostViewMacOwner
@@ -150,6 +154,14 @@
// Event monitor for scroll wheel end event.
id endWheelMonitor_;
+
+ // OpenGL Support:
+
+ // recursive globalFrameDidChange protection:
+ BOOL handlingGlobalFrameDidChange_;
+
+ // The scale factor of the display this view is in.
+ float deviceScaleFactor_;
// If true then escape key down events are suppressed until the first escape
// key up event. (The up event is suppressed as well). This is used by the
@@ -207,6 +219,7 @@
public DelegatedFrameHostClient,
public BrowserCompositorViewMacClient,
public IPC::Sender,
+ public SoftwareFrameManagerClient,
public CompositingIOSurfaceLayerClient,
public gfx::DisplayObserver {
public:
@@ -328,6 +341,11 @@
// IPC::Sender implementation.
virtual bool Send(IPC::Message* message) OVERRIDE;
+ // SoftwareFrameManagerClient implementation:
+ virtual void SoftwareFrameWasFreed(
+ uint32 output_surface_id, unsigned frame_id) OVERRIDE;
+ virtual void ReleaseReferencesToSoftwareFrame() OVERRIDE;
+
virtual SkColorType PreferredReadbackFormat() OVERRIDE;
// CompositingIOSurfaceLayerClient implementation.
@@ -352,6 +370,18 @@
void PluginImeCompositionCompleted(const base::string16& text, int plugin_id);
const std::string& selected_text() const { return selected_text_; }
+
+ // Update the IOSurface to be drawn and call setNeedsDisplay on
+ // |cocoa_view_|.
+ void CompositorSwapBuffers(IOSurfaceID surface_handle,
+ const gfx::Rect& damage_rect,
+ const gfx::Size& surface_size,
+ float scale_factor,
+ const std::vector<ui::LatencyInfo>& latency_info);
+
+ // Called when a GPU error is detected. Posts a task to destroy all
+ // compositing state.
+ void GotAcceleratedCompositingError();
// Returns true and stores first rectangle for character range if the
// requested |range| is already cached, otherwise returns false.
@@ -393,6 +423,27 @@
// The background CoreAnimation layer which is hosted by |cocoa_view_|.
base::scoped_nsobject<CALayer> background_layer_;
+ // 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
+ // using remote layers, as their size change cannot be synchronized with the
+ // window). This indirection is needed because flipping hosted layers (like
+ // |background_layer_|) leads to unpredictable behavior.
+ base::scoped_nsobject<CALayer> flipped_layer_;
+
+ // The CoreAnimation layer hosted by the GPU process.
+ base::scoped_nsobject<CALayerHost> remote_layer_host_;
+
+ // The CoreAnimation layer for software compositing. This should be NULL
+ // when software compositing is not in use.
+ base::scoped_nsobject<SoftwareLayer> software_layer_;
+
+ // Accelerated compositing structures. These may be dynamically created and
+ // destroyed together in Create/DestroyCompositedIOSurfaceAndLayer.
+ base::scoped_nsobject<CompositingIOSurfaceLayer> compositing_iosurface_layer_;
+ scoped_refptr<CompositingIOSurfaceMac> compositing_iosurface_;
+ scoped_refptr<CompositingIOSurfaceContext> compositing_iosurface_context_;
+
// Delegated frame management and compositior.
scoped_ptr<DelegatedFrameHost> delegated_frame_host_;
scoped_ptr<ui::Layer> root_layer_;
@@ -406,6 +457,13 @@
scoped_ptr<BrowserCompositorViewPlaceholderMac>
browser_compositor_view_placeholder_;
+ // This holds the current software compositing framebuffer, if any.
+ scoped_ptr<SoftwareFrameManager> software_frame_manager_;
+
+ // Latency info to send back when the next frame appears on the
+ // screen.
+ std::vector<ui::LatencyInfo> pending_latency_info_;
+
NSWindow* pepper_fullscreen_window() const {
return pepper_fullscreen_window_;
}
@@ -416,6 +474,10 @@
return fullscreen_parent_host_view_;
}
+ RenderWidgetHostViewFrameSubscriber* frame_subscriber() const {
+ return frame_subscriber_.get();
+ }
+
int window_number() const;
// The scale factor for the screen that the view is currently on.
@@ -427,7 +489,23 @@
// Ensure that the display link is associated with the correct display.
void UpdateDisplayLink();
+ // The scale factor of the backing store. Note that this is updated based on
+ // ViewScaleFactor with some delay.
+ float backing_store_scale_factor_;
+
+ void AddPendingLatencyInfo(
+ const std::vector<ui::LatencyInfo>& latency_info);
+ void SendPendingLatencyInfoToHost();
+
+ void SendPendingSwapAck();
+
void PauseForPendingResizeOrRepaintsAndDraw();
+
+ // The geometric arrangement of the layers depends on cocoa_view's size, the
+ // compositing IOSurface's rounded size, and the software frame size. Update
+ // all of them using this function when any of those parameters changes. Also
+ // update the scale factor of the layers.
+ void LayoutLayers();
// DelegatedFrameHostClient implementation.
virtual ui::Compositor* GetCompositor() const OVERRIDE;
@@ -453,6 +531,18 @@
private:
friend class RenderWidgetHostViewMacTest;
+ struct PendingSwapAck {
+ PendingSwapAck(int32 route_id, int gpu_host_id, int32 renderer_id)
+ : route_id(route_id),
+ gpu_host_id(gpu_host_id),
+ renderer_id(renderer_id) {}
+ int32 route_id;
+ int gpu_host_id;
+ int32 renderer_id;
+ };
+ scoped_ptr<PendingSwapAck> pending_swap_ack_;
+ void AddPendingSwapAck(int32 route_id, int gpu_host_id, int32 renderer_id);
+
// Returns whether this render view is a popup (autocomplete window).
bool IsPopup() const;
@@ -466,11 +556,36 @@
void EnsureBrowserCompositorView();
void DestroyBrowserCompositorView();
+
+ void EnsureSoftwareLayer();
+ void DestroySoftwareLayer();
+
+ bool EnsureCompositedIOSurface() WARN_UNUSED_RESULT;
+ void EnsureCompositedIOSurfaceLayer();
+ enum DestroyCompositedIOSurfaceLayerBehavior {
+ kLeaveLayerInHierarchy,
+ kRemoveLayerFromHierarchy,
+ };
+ void DestroyCompositedIOSurfaceLayer(
+ DestroyCompositedIOSurfaceLayerBehavior destroy_layer_behavior);
+ void DestroyCompositedIOSurfaceAndLayer();
+
+ void DestroyCompositingStateOnError();
+
+ // Called when a GPU SwapBuffers is received.
+ void GotAcceleratedFrame();
+
+ // Called when a software DIB is received.
+ void GotSoftwareFrame();
// IPC message handlers.
void OnPluginFocusChanged(bool focused, int plugin_id);
void OnStartPluginIme();
void OnGetRenderedTextCompleted(const std::string& text);
+
+ // Convert |rect| from the views coordinate (upper-left origin) into
+ // the OpenGL coordinate (lower-left origin) and scale for HiDPI displays.
+ gfx::Rect GetScaledOpenGLPixelRect(const gfx::Rect& rect);
// Send updated vsync parameters to the renderer.
void SendVSyncParametersToRenderer();
@@ -522,6 +637,11 @@
// The current caret bounds.
gfx::Rect caret_rect_;
+ // Subscriber that listens to frame presentation events.
+ scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_;
+
+ base::WeakPtrFactory<RenderWidgetHostViewMac>
+ software_frame_weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac);
};

Powered by Google App Engine
This is Rietveld 408576698