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

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

Issue 2093113003: Clean up the RWHVMac to ui::Compositor interface (phase 1 of 2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove hack Created 4 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 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/IOSurface.h> 9 #include <IOSurface/IOSurface.h>
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 // someone (other than superview) has retained |cocoa_view_|. 408 // someone (other than superview) has retained |cocoa_view_|.
409 RenderWidgetHostImpl* render_widget_host_; 409 RenderWidgetHostImpl* render_widget_host_;
410 410
411 // Current text input type. 411 // Current text input type.
412 ui::TextInputType text_input_type_; 412 ui::TextInputType text_input_type_;
413 bool can_compose_inline_; 413 bool can_compose_inline_;
414 414
415 // The background CoreAnimation layer which is hosted by |cocoa_view_|. 415 // The background CoreAnimation layer which is hosted by |cocoa_view_|.
416 base::scoped_nsobject<CALayer> background_layer_; 416 base::scoped_nsobject<CALayer> background_layer_;
417 417
418 // The state of |delegated_frame_host_| and |browser_compositor_| to 418 // Delegated frame management and compositor interface.
419 // manage being visible, hidden, or occluded.
420 enum BrowserCompositorViewState {
421 // Effects:
422 // - |browser_compositor_| exists and |delegated_frame_host_| is
423 // visible.
424 // Happens when:
425 // - |render_widet_host_| is in the visible state (this includes when
426 // the tab isn't visible, but tab capture is enabled).
427 BrowserCompositorActive,
428 // Effects:
429 // - |browser_compositor_| exists, but |delegated_frame_host_| has
430 // been hidden.
431 // Happens when:
432 // - The |render_widget_host_| is hidden, but |cocoa_view_| is still in the
433 // NSWindow hierarchy.
434 // - This happens when |cocoa_view_| is hidden (minimized, on another
435 // occluded by other windows, etc). The |browser_compositor_| and
436 // its CALayers are kept around so that we will have content to show when
437 // we are un-occluded.
438 BrowserCompositorSuspended,
439 // Effects:
440 // - |browser_compositor_| has been destroyed and
441 // |delegated_frame_host_| has been hidden.
442 // Happens when:
443 // - The |render_widget_host_| is hidden or dead, and |cocoa_view_| is not
444 // attached to a NSWindow.
445 // - This happens for backgrounded tabs.
446 BrowserCompositorDestroyed,
447 };
448 BrowserCompositorViewState browser_compositor_state_;
449
450 // Delegated frame management and compositor.
451 std::unique_ptr<DelegatedFrameHost> delegated_frame_host_;
452 std::unique_ptr<ui::Layer> root_layer_;
453
454 // Container for ui::Compositor the CALayer tree drawn by it.
455 std::unique_ptr<BrowserCompositorMac> browser_compositor_; 419 std::unique_ptr<BrowserCompositorMac> browser_compositor_;
456 420
457 // Placeholder that is allocated while browser_compositor_ is NULL,
458 // indicating that a BrowserCompositorViewMac may be allocated. This is to
459 // help in recycling the internals of BrowserCompositorViewMac.
460 std::unique_ptr<BrowserCompositorMacPlaceholder>
461 browser_compositor_placeholder_;
462
463 // Set when the currently-displayed frame is the minimum scale. Used to 421 // Set when the currently-displayed frame is the minimum scale. Used to
464 // determine if pinch gestures need to be thresholded. 422 // determine if pinch gestures need to be thresholded.
465 bool page_at_minimum_scale_; 423 bool page_at_minimum_scale_;
466 424
467 NSWindow* pepper_fullscreen_window() const { 425 NSWindow* pepper_fullscreen_window() const {
468 return pepper_fullscreen_window_; 426 return pepper_fullscreen_window_;
469 } 427 }
470 428
471 CONTENT_EXPORT void release_pepper_fullscreen_window_for_testing(); 429 CONTENT_EXPORT void release_pepper_fullscreen_window_for_testing();
472 430
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 void OnBeginFrame(const cc::BeginFrameArgs& args) override; 472 void OnBeginFrame(const cc::BeginFrameArgs& args) override;
515 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override; 473 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override;
516 void OnBeginFrameSourcePausedChanged(bool paused) override; 474 void OnBeginFrameSourcePausedChanged(bool paused) override;
517 475
518 // AcceleratedWidgetMacNSView implementation. 476 // AcceleratedWidgetMacNSView implementation.
519 NSView* AcceleratedWidgetGetNSView() const override; 477 NSView* AcceleratedWidgetGetNSView() const override;
520 void AcceleratedWidgetGetVSyncParameters( 478 void AcceleratedWidgetGetVSyncParameters(
521 base::TimeTicks* timebase, base::TimeDelta* interval) const override; 479 base::TimeTicks* timebase, base::TimeDelta* interval) const override;
522 void AcceleratedWidgetSwapCompleted() override; 480 void AcceleratedWidgetSwapCompleted() override;
523 481
524 // Transition from being in the Suspended state to being in the Destroyed
525 // state, if appropriate (see BrowserCompositorViewState for details).
526 void DestroySuspendedBrowserCompositorViewIfNeeded();
527
528 // Exposed for testing. 482 // Exposed for testing.
529 cc::SurfaceId SurfaceIdForTesting() const override; 483 cc::SurfaceId SurfaceIdForTesting() const override;
530 484
531 private: 485 private:
532 friend class RenderWidgetHostViewMacTest; 486 friend class RenderWidgetHostViewMacTest;
533 487
534 // Returns whether this render view is a popup (autocomplete window). 488 // Returns whether this render view is a popup (autocomplete window).
535 bool IsPopup() const; 489 bool IsPopup() const;
536 490
537 // Shuts down the render_widget_host_. This is a separate function so we can 491 // Shuts down the render_widget_host_. This is a separate function so we can
538 // invoke it from the message loop. 492 // invoke it from the message loop.
539 void ShutdownHost(); 493 void ShutdownHost();
540 494
541 // Tear down all components of the browser compositor in an order that will
542 // ensure no dangling references.
543 void ShutdownBrowserCompositor();
544
545 // The state of the the browser compositor and delegated frame host. See
546 // BrowserCompositorViewState for details.
547 void EnsureBrowserCompositorView();
548 void SuspendBrowserCompositorView();
549 void DestroyBrowserCompositorView();
550
551 // IPC message handlers. 495 // IPC message handlers.
552 void OnGetRenderedTextCompleted(const std::string& text); 496 void OnGetRenderedTextCompleted(const std::string& text);
553 497
554 // Send updated vsync parameters to the renderer. 498 // Send updated vsync parameters to the renderer.
555 void SendVSyncParametersToRenderer(); 499 void SendVSyncParametersToRenderer();
556 500
557 // Dispatches a TTS session. 501 // Dispatches a TTS session.
558 void SpeakText(const std::string& text); 502 void SpeakText(const std::string& text);
559 503
560 // The associated view. This is weak and is inserted into the view hierarchy 504 // The associated view. This is weak and is inserted into the view hierarchy
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 559
616 // Factory used to safely scope delayed calls to ShutdownHost(). 560 // Factory used to safely scope delayed calls to ShutdownHost().
617 base::WeakPtrFactory<RenderWidgetHostViewMac> weak_factory_; 561 base::WeakPtrFactory<RenderWidgetHostViewMac> weak_factory_;
618 562
619 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac); 563 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMac);
620 }; 564 };
621 565
622 } // namespace content 566 } // namespace content
623 567
624 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_ 568 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698