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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.h

Issue 684343002: Mac: Use Mavericks occlusion APIs for power savings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate review feedback Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 #include <IOSurface/IOSurfaceAPI.h> 9 #include <IOSurface/IOSurfaceAPI.h>
10 #include <list> 10 #include <list>
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 // someone (other than superview) has retained |cocoa_view_|. 370 // someone (other than superview) has retained |cocoa_view_|.
371 RenderWidgetHostImpl* render_widget_host_; 371 RenderWidgetHostImpl* render_widget_host_;
372 372
373 // Current text input type. 373 // Current text input type.
374 ui::TextInputType text_input_type_; 374 ui::TextInputType text_input_type_;
375 bool can_compose_inline_; 375 bool can_compose_inline_;
376 376
377 // The background CoreAnimation layer which is hosted by |cocoa_view_|. 377 // The background CoreAnimation layer which is hosted by |cocoa_view_|.
378 base::scoped_nsobject<CALayer> background_layer_; 378 base::scoped_nsobject<CALayer> background_layer_;
379 379
380 // The state of |delegated_frame_host_| and |browser_compositor_view_| to
381 // manage being visible, hidden, or occluded.
382 enum BrowserCompositorViewState {
383 // Effects:
384 // - |browser_compositor_view_| exists and |delegated_frame_host_| is
385 // visible.
386 // Happens when:
387 // - |render_widet_host_| is in the visible state (this includes when
388 // the tab isn't visible, but tab capture is enabled).
389 BrowserCompositorActive,
390 // Effects:
391 // - |browser_compositor_view_| exists, but |delegated_frame_host_| has
392 // been hidden.
393 // Happens when:
394 // - The |render_widget_host_| is hidden, but |cocoa_view_| is still in the
395 // NSWindow hierarchy.
396 // - This happens when |cocoa_view_| is hidden (minimized, on another
397 // occluded by other windows, etc). The |browser_compositor_view_| and
398 // its CALayers are kept around so that we will have content to show when
399 // we are un-occluded.
400 BrowserCompositorSuspended,
401 // Effects:
402 // - |browser_compositor_view_| has been destroyed and
403 // |delegated_frame_host_| has been hidden.
404 // Happens when:
405 // - The |render_widget_host_| is hidden or dead, and |cocoa_view_| is not
406 // attached to a NSWindow.
407 // - This happens for backgrounded tabs.
408 BrowserCompositorDestroyed,
409 };
410 BrowserCompositorViewState browser_compositor_state_;
411
380 // Delegated frame management and compositior. 412 // Delegated frame management and compositior.
381 scoped_ptr<DelegatedFrameHost> delegated_frame_host_; 413 scoped_ptr<DelegatedFrameHost> delegated_frame_host_;
382 scoped_ptr<ui::Layer> root_layer_; 414 scoped_ptr<ui::Layer> root_layer_;
383 415
384 // Container for the NSView drawn by the browser compositor. 416 // Container for the CALayer tree drawn by the browser compositor.
385 scoped_ptr<BrowserCompositorViewMac> browser_compositor_view_; 417 scoped_ptr<BrowserCompositorViewMac> browser_compositor_view_;
386 418
387 // Placeholder that is allocated while browser_compositor_view_ is NULL, 419 // Placeholder that is allocated while browser_compositor_view_ is NULL,
388 // indicating that a BrowserCompositorViewMac may be allocated. This is to 420 // indicating that a BrowserCompositorViewMac may be allocated. This is to
389 // help in recycling the internals of BrowserCompositorViewMac. 421 // help in recycling the internals of BrowserCompositorViewMac.
390 scoped_ptr<BrowserCompositorViewPlaceholderMac> 422 scoped_ptr<BrowserCompositorViewPlaceholderMac>
391 browser_compositor_view_placeholder_; 423 browser_compositor_view_placeholder_;
392 424
393 NSWindow* pepper_fullscreen_window() const { 425 NSWindow* pepper_fullscreen_window() const {
394 return pepper_fullscreen_window_; 426 return pepper_fullscreen_window_;
(...skipping 27 matching lines...) Expand all
422 gfx::Size DesiredFrameSize() override; 454 gfx::Size DesiredFrameSize() override;
423 float CurrentDeviceScaleFactor() override; 455 float CurrentDeviceScaleFactor() override;
424 gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) override; 456 gfx::Size ConvertViewSizeToPixel(const gfx::Size& size) override;
425 DelegatedFrameHost* GetDelegatedFrameHost() const override; 457 DelegatedFrameHost* GetDelegatedFrameHost() const override;
426 458
427 // BrowserCompositorViewMacClient implementation. 459 // BrowserCompositorViewMacClient implementation.
428 bool BrowserCompositorViewShouldAckImmediately() const override; 460 bool BrowserCompositorViewShouldAckImmediately() const override;
429 void BrowserCompositorViewFrameSwapped( 461 void BrowserCompositorViewFrameSwapped(
430 const std::vector<ui::LatencyInfo>& latency_info) override; 462 const std::vector<ui::LatencyInfo>& latency_info) override;
431 463
464 // Transition from being in the Suspended state to being in the Destroyed
465 // state, if appropriate (see BrowserCompositorViewState for details).
466 void DestroySuspendedBrowserCompositorViewIfNeeded();
467
432 private: 468 private:
433 friend class RenderWidgetHostViewMacTest; 469 friend class RenderWidgetHostViewMacTest;
434 470
435 // Returns whether this render view is a popup (autocomplete window). 471 // Returns whether this render view is a popup (autocomplete window).
436 bool IsPopup() const; 472 bool IsPopup() const;
437 473
438 // Shuts down the render_widget_host_. This is a separate function so we can 474 // Shuts down the render_widget_host_. This is a separate function so we can
439 // invoke it from the message loop. 475 // invoke it from the message loop.
440 void ShutdownHost(); 476 void ShutdownHost();
441 477
442 // Tear down all components of the browser compositor in an order that will 478 // Tear down all components of the browser compositor in an order that will
443 // ensure no dangling references. 479 // ensure no dangling references.
444 void ShutdownBrowserCompositor(); 480 void ShutdownBrowserCompositor();
445 481
482 // The state of the the browser compositor and delegated frame host. See
483 // BrowserCompositorViewState for details.
446 void EnsureBrowserCompositorView(); 484 void EnsureBrowserCompositorView();
485 void SuspendBrowserCompositorView();
447 void DestroyBrowserCompositorView(); 486 void DestroyBrowserCompositorView();
448 487
449 // IPC message handlers. 488 // IPC message handlers.
450 void OnPluginFocusChanged(bool focused, int plugin_id); 489 void OnPluginFocusChanged(bool focused, int plugin_id);
451 void OnStartPluginIme(); 490 void OnStartPluginIme();
452 void OnGetRenderedTextCompleted(const std::string& text); 491 void OnGetRenderedTextCompleted(const std::string& text);
453 492
454 // Send updated vsync parameters to the renderer. 493 // Send updated vsync parameters to the renderer.
455 void SendVSyncParametersToRenderer(); 494 void SendVSyncParametersToRenderer();
456 495
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 546
508 // The current caret bounds. 547 // The current caret bounds.
509 gfx::Rect caret_rect_; 548 gfx::Rect caret_rect_;
510 549
511 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); 550 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac);
512 }; 551 };
513 552
514 } // namespace content 553 } // namespace content
515 554
516 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ 555 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_
OLDNEW
« no previous file with comments | « base/mac/sdk_forward_declarations.mm ('k') | content/browser/renderer_host/render_widget_host_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698