OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/compositor/browser_compositor_view_mac.h" | 5 #include "content/browser/compositor/browser_compositor_view_mac.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "content/browser/compositor/browser_compositor_view_private_mac.h" | 9 #include "content/browser/compositor/browser_compositor_view_private_mac.h" |
10 #include "content/common/gpu/surface_handle_types_mac.h" | |
11 | 10 |
12 //////////////////////////////////////////////////////////////////////////////// | 11 //////////////////////////////////////////////////////////////////////////////// |
13 // BrowserCompositorViewMac | 12 // BrowserCompositorViewMac |
14 | 13 |
15 namespace content { | 14 namespace content { |
16 namespace { | 15 namespace { |
17 | 16 |
18 // The number of placeholder objects allocated. If this reaches zero, then | 17 // The number of placeholder objects allocated. If this reaches zero, then |
19 // the BrowserCompositorViewMacInternal being held on to for recycling, | 18 // the BrowserCompositorViewMacInternal being held on to for recycling, |
20 // |g_recyclable_internal_view|, will be freed. | 19 // |g_recyclable_internal_view|, will be freed. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 72 } |
74 | 73 |
75 // static | 74 // static |
76 void BrowserCompositorViewMac::GotAcceleratedFrame( | 75 void BrowserCompositorViewMac::GotAcceleratedFrame( |
77 gfx::AcceleratedWidget widget, | 76 gfx::AcceleratedWidget widget, |
78 uint64 surface_handle, int surface_id, | 77 uint64 surface_handle, int surface_id, |
79 const std::vector<ui::LatencyInfo>& latency_info, | 78 const std::vector<ui::LatencyInfo>& latency_info, |
80 gfx::Size pixel_size, float scale_factor) { | 79 gfx::Size pixel_size, float scale_factor) { |
81 BrowserCompositorViewMacInternal* internal_view = | 80 BrowserCompositorViewMacInternal* internal_view = |
82 BrowserCompositorViewMacInternal::FromAcceleratedWidget(widget); | 81 BrowserCompositorViewMacInternal::FromAcceleratedWidget(widget); |
83 if (!internal_view) | 82 if (internal_view) { |
84 return; | 83 internal_view->GotAcceleratedFrame( |
85 IOSurfaceID io_surface_id = IOSurfaceIDFromSurfaceHandle(surface_handle); | 84 surface_handle, surface_id, latency_info, pixel_size, scale_factor); |
86 internal_view->GotAcceleratedIOSurfaceFrame( | 85 } |
87 io_surface_id, surface_id, latency_info, pixel_size, scale_factor); | |
88 } | 86 } |
89 | 87 |
90 // static | 88 // static |
91 void BrowserCompositorViewMac::GotSoftwareFrame( | 89 void BrowserCompositorViewMac::GotSoftwareFrame( |
92 gfx::AcceleratedWidget widget, | 90 gfx::AcceleratedWidget widget, |
93 cc::SoftwareFrameData* frame_data, float scale_factor, SkCanvas* canvas) { | 91 cc::SoftwareFrameData* frame_data, float scale_factor, SkCanvas* canvas) { |
94 BrowserCompositorViewMacInternal* internal_view = | 92 BrowserCompositorViewMacInternal* internal_view = |
95 BrowserCompositorViewMacInternal::FromAcceleratedWidget(widget); | 93 BrowserCompositorViewMacInternal::FromAcceleratedWidget(widget); |
96 if (!internal_view) | 94 if (internal_view) |
97 return; | 95 internal_view->GotSoftwareFrame(frame_data, scale_factor, canvas); |
98 internal_view->GotSoftwareFrame(frame_data, scale_factor, canvas); | |
99 } | 96 } |
100 | 97 |
101 //////////////////////////////////////////////////////////////////////////////// | 98 //////////////////////////////////////////////////////////////////////////////// |
102 // BrowserCompositorViewPlaceholderMac | 99 // BrowserCompositorViewPlaceholderMac |
103 | 100 |
104 BrowserCompositorViewPlaceholderMac::BrowserCompositorViewPlaceholderMac() { | 101 BrowserCompositorViewPlaceholderMac::BrowserCompositorViewPlaceholderMac() { |
105 g_placeholder_count += 1; | 102 g_placeholder_count += 1; |
106 } | 103 } |
107 | 104 |
108 BrowserCompositorViewPlaceholderMac::~BrowserCompositorViewPlaceholderMac() { | 105 BrowserCompositorViewPlaceholderMac::~BrowserCompositorViewPlaceholderMac() { |
109 DCHECK_GT(g_placeholder_count, 0u); | 106 DCHECK_GT(g_placeholder_count, 0u); |
110 g_placeholder_count -= 1; | 107 g_placeholder_count -= 1; |
111 | 108 |
112 // If there are no placeholders allocated, destroy the recyclable | 109 // If there are no placeholders allocated, destroy the recyclable |
113 // BrowserCompositorViewMacInternal. | 110 // BrowserCompositorViewMacInternal. |
114 if (!g_placeholder_count) | 111 if (!g_placeholder_count) |
115 g_recyclable_internal_view.Get().reset(); | 112 g_recyclable_internal_view.Get().reset(); |
116 } | 113 } |
117 | 114 |
118 } // namespace content | 115 } // namespace content |
OLD | NEW |