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

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

Issue 511923004: Simplify IOSurface CoreAnimation code: Part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use accessors 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 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 #include "content/browser/renderer_host/render_widget_host_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 #include <OpenGL/gl.h> 8 #include <OpenGL/gl.h>
9 #include <QuartzCore/QuartzCore.h> 9 #include <QuartzCore/QuartzCore.h>
10 10
(...skipping 12 matching lines...) Expand all
23 #include "base/metrics/histogram.h" 23 #include "base/metrics/histogram.h"
24 #include "base/strings/string_util.h" 24 #include "base/strings/string_util.h"
25 #include "base/strings/stringprintf.h" 25 #include "base/strings/stringprintf.h"
26 #include "base/strings/sys_string_conversions.h" 26 #include "base/strings/sys_string_conversions.h"
27 #include "base/strings/utf_string_conversions.h" 27 #include "base/strings/utf_string_conversions.h"
28 #include "base/sys_info.h" 28 #include "base/sys_info.h"
29 #import "content/browser/accessibility/browser_accessibility_cocoa.h" 29 #import "content/browser/accessibility/browser_accessibility_cocoa.h"
30 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" 30 #include "content/browser/accessibility/browser_accessibility_manager_mac.h"
31 #import "content/browser/cocoa/system_hotkey_helper_mac.h" 31 #import "content/browser/cocoa/system_hotkey_helper_mac.h"
32 #import "content/browser/cocoa/system_hotkey_map.h" 32 #import "content/browser/cocoa/system_hotkey_map.h"
33 #include "content/browser/compositor/io_surface_layer_mac.h"
33 #include "content/browser/compositor/resize_lock.h" 34 #include "content/browser/compositor/resize_lock.h"
35 #include "content/browser/compositor/software_layer_mac.h"
34 #include "content/browser/frame_host/frame_tree.h" 36 #include "content/browser/frame_host/frame_tree.h"
35 #include "content/browser/frame_host/frame_tree_node.h" 37 #include "content/browser/frame_host/frame_tree_node.h"
36 #include "content/browser/frame_host/render_frame_host_impl.h" 38 #include "content/browser/frame_host/render_frame_host_impl.h"
37 #include "content/browser/gpu/compositor_util.h" 39 #include "content/browser/gpu/compositor_util.h"
38 #include "content/browser/renderer_host/compositing_iosurface_context_mac.h"
39 #include "content/browser/renderer_host/compositing_iosurface_layer_mac.h"
40 #include "content/browser/renderer_host/compositing_iosurface_mac.h"
41 #include "content/browser/renderer_host/render_widget_helper.h" 40 #include "content/browser/renderer_host/render_widget_helper.h"
42 #include "content/browser/renderer_host/render_view_host_impl.h" 41 #include "content/browser/renderer_host/render_view_host_impl.h"
43 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he lper.h" 42 #import "content/browser/renderer_host/render_widget_host_view_mac_dictionary_he lper.h"
44 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h" 43 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h"
45 #import "content/browser/renderer_host/software_layer_mac.h"
46 #import "content/browser/renderer_host/text_input_client_mac.h" 44 #import "content/browser/renderer_host/text_input_client_mac.h"
47 #include "content/common/accessibility_messages.h" 45 #include "content/common/accessibility_messages.h"
48 #include "content/common/edit_command.h" 46 #include "content/common/edit_command.h"
49 #include "content/common/gpu/gpu_messages.h" 47 #include "content/common/gpu/gpu_messages.h"
50 #include "content/common/gpu/surface_handle_types_mac.h" 48 #include "content/common/gpu/surface_handle_types_mac.h"
51 #include "content/common/input_messages.h" 49 #include "content/common/input_messages.h"
52 #include "content/common/view_messages.h" 50 #include "content/common/view_messages.h"
53 #include "content/common/webplugin_geometry.h" 51 #include "content/common/webplugin_geometry.h"
54 #include "content/public/browser/browser_thread.h" 52 #include "content/public/browser/browser_thread.h"
55 #include "content/public/browser/native_web_keyboard_event.h" 53 #include "content/public/browser/native_web_keyboard_event.h"
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 443
446 DelegatedFrameHost* RenderWidgetHostViewMac::GetDelegatedFrameHost() const { 444 DelegatedFrameHost* RenderWidgetHostViewMac::GetDelegatedFrameHost() const {
447 return delegated_frame_host_.get(); 445 return delegated_frame_host_.get();
448 } 446 }
449 447
450 //////////////////////////////////////////////////////////////////////////////// 448 ////////////////////////////////////////////////////////////////////////////////
451 // BrowserCompositorViewMacClient, public: 449 // BrowserCompositorViewMacClient, public:
452 450
453 bool RenderWidgetHostViewMac::BrowserCompositorViewShouldAckImmediately() 451 bool RenderWidgetHostViewMac::BrowserCompositorViewShouldAckImmediately()
454 const { 452 const {
455 // The logic for delegated and non-delegated rendering is the same. 453 // If vsync is disabled, then always draw and ack frames immediately.
456 return AcceleratedLayerShouldAckImmediately(); 454 static bool is_vsync_disabled =
455 base::CommandLine::ForCurrentProcess()->HasSwitch(
456 switches::kDisableGpuVsync);
457 if (is_vsync_disabled)
458 return true;
459
460 // If the window is occluded, then this frame's display call may be severely
461 // throttled. This is a good thing, unless tab capture may be active, because
462 // the broadcast will be inappropriately throttled.
463 // http://crbug.com/350410
464
465 // If tab capture isn't active then only ack frames when we draw them.
466 if (delegated_frame_host_ && !delegated_frame_host_->HasFrameSubscriber())
467 return false;
468
469 NSWindow* window = [cocoa_view_ window];
470 // If the view isn't even in the heirarchy then frames will never be drawn,
471 // so ack them immediately.
472 if (!window)
473 return true;
474
475 // Check the window occlusion API.
476 if ([window respondsToSelector:@selector(occlusionState)]) {
477 if ([window occlusionState] & NSWindowOcclusionStateVisible) {
478 // If the window is visible then it is safe to wait until frames are
479 // drawn to ack them.
480 return false;
481 } else {
482 // If the window is occluded then frames may never be drawn, so ack them
483 // immediately.
484 return true;
485 }
486 }
487
488 // If the window occlusion API is not present then ack frames when we draw
489 // them.
490 return false;
457 } 491 }
458 492
459 void RenderWidgetHostViewMac::BrowserCompositorViewFrameSwapped( 493 void RenderWidgetHostViewMac::BrowserCompositorViewFrameSwapped(
460 const std::vector<ui::LatencyInfo>& all_latency_info) { 494 const std::vector<ui::LatencyInfo>& all_latency_info) {
461 if (!render_widget_host_) 495 if (!render_widget_host_)
462 return; 496 return;
463 for (auto latency_info : all_latency_info) { 497 for (auto latency_info : all_latency_info) {
464 latency_info.AddLatencyNumber( 498 latency_info.AddLatencyNumber(
465 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0); 499 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0);
466 render_widget_host_->FrameSwapped(latency_info); 500 render_widget_host_->FrameSwapped(latency_info);
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 render_widget_host_->PauseForPendingResizeOrRepaints(); 1621 render_widget_host_->PauseForPendingResizeOrRepaints();
1588 if (browser_compositor_view_) 1622 if (browser_compositor_view_)
1589 browser_compositor_view_->EndPumpingFrames(); 1623 browser_compositor_view_->EndPumpingFrames();
1590 } 1624 }
1591 1625
1592 SkColorType RenderWidgetHostViewMac::PreferredReadbackFormat() { 1626 SkColorType RenderWidgetHostViewMac::PreferredReadbackFormat() {
1593 return kN32_SkColorType; 1627 return kN32_SkColorType;
1594 } 1628 }
1595 1629
1596 //////////////////////////////////////////////////////////////////////////////// 1630 ////////////////////////////////////////////////////////////////////////////////
1597 // CompositingIOSurfaceLayerClient, public:
1598
1599 bool RenderWidgetHostViewMac::AcceleratedLayerShouldAckImmediately() const {
1600 // If vsync is disabled, then always draw and ack frames immediately.
1601 static bool is_vsync_disabled =
1602 base::CommandLine::ForCurrentProcess()->HasSwitch(
1603 switches::kDisableGpuVsync);
1604 if (is_vsync_disabled)
1605 return true;
1606
1607 // If the window is occluded, then this frame's display call may be severely
1608 // throttled. This is a good thing, unless tab capture may be active, because
1609 // the broadcast will be inappropriately throttled.
1610 // http://crbug.com/350410
1611
1612 // If tab capture isn't active then only ack frames when we draw them.
1613 if (delegated_frame_host_ && !delegated_frame_host_->HasFrameSubscriber())
1614 return false;
1615
1616 NSWindow* window = [cocoa_view_ window];
1617 // If the view isn't even in the heirarchy then frames will never be drawn,
1618 // so ack them immediately.
1619 if (!window)
1620 return true;
1621
1622 // Check the window occlusion API.
1623 if ([window respondsToSelector:@selector(occlusionState)]) {
1624 if ([window occlusionState] & NSWindowOcclusionStateVisible) {
1625 // If the window is visible then it is safe to wait until frames are
1626 // drawn to ack them.
1627 return false;
1628 } else {
1629 // If the window is occluded then frames may never be drawn, so ack them
1630 // immediately.
1631 return true;
1632 }
1633 }
1634
1635 // If the window occlusion API is not present then ack frames when we draw
1636 // them.
1637 return false;
1638 }
1639
1640 void RenderWidgetHostViewMac::AcceleratedLayerDidDrawFrame() {
1641 }
1642
1643 void RenderWidgetHostViewMac::AcceleratedLayerHitError() {
1644 }
1645
1646 ////////////////////////////////////////////////////////////////////////////////
1647 // gfx::DisplayObserver, public: 1631 // gfx::DisplayObserver, public:
1648 1632
1649 void RenderWidgetHostViewMac::OnDisplayAdded(const gfx::Display& display) { 1633 void RenderWidgetHostViewMac::OnDisplayAdded(const gfx::Display& display) {
1650 } 1634 }
1651 1635
1652 void RenderWidgetHostViewMac::OnDisplayRemoved(const gfx::Display& display) { 1636 void RenderWidgetHostViewMac::OnDisplayRemoved(const gfx::Display& display) {
1653 } 1637 }
1654 1638
1655 void RenderWidgetHostViewMac::OnDisplayMetricsChanged( 1639 void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
1656 const gfx::Display& display, uint32_t metrics) { 1640 const gfx::Display& display, uint32_t metrics) {
(...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after
3348 3332
3349 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3333 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3350 // regions that are not draggable. (See ControlRegionView in 3334 // regions that are not draggable. (See ControlRegionView in
3351 // native_app_window_cocoa.mm). This requires the render host view to be 3335 // native_app_window_cocoa.mm). This requires the render host view to be
3352 // draggable by default. 3336 // draggable by default.
3353 - (BOOL)mouseDownCanMoveWindow { 3337 - (BOOL)mouseDownCanMoveWindow {
3354 return YES; 3338 return YES;
3355 } 3339 }
3356 3340
3357 @end 3341 @end
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.h ('k') | content/browser/renderer_host/software_layer_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698