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

Side by Side Diff: content/common/gpu/image_transport_surface_overlay_mac.h

Issue 1845563005: Refactor content/common/gpu into gpu/ipc/service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Drop ref to deleted content_tests_gypi_values.content_unittests_ozone_sources Created 4 years, 8 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_
6 #define CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_
7
8 #include <list>
9 #include <vector>
10
11 #import "base/mac/scoped_nsobject.h"
12 #include "base/timer/timer.h"
13 #include "content/common/gpu/gpu_command_buffer_stub.h"
14 #include "content/common/gpu/image_transport_surface.h"
15 #include "ui/base/cocoa/remote_layer_api.h"
16 #include "ui/events/latency_info.h"
17 #include "ui/gl/gl_surface.h"
18 #include "ui/gl/gpu_switching_observer.h"
19
20 @class CAContext;
21 @class CALayer;
22
23 namespace content {
24
25 class CALayerTree;
26 class CALayerPartialDamageTree;
27
28 class ImageTransportSurfaceOverlayMac : public gfx::GLSurface,
29 public ui::GpuSwitchingObserver {
30 public:
31 ImageTransportSurfaceOverlayMac(GpuChannelManager* manager,
32 GpuCommandBufferStub* stub,
33 gpu::SurfaceHandle handle);
34
35 // GLSurface implementation
36 bool Initialize(gfx::GLSurface::Format format) override;
37 void Destroy() override;
38 bool Resize(const gfx::Size& size,
39 float scale_factor,
40 bool has_alpha) override;
41 bool IsOffscreen() override;
42 gfx::SwapResult SwapBuffers() override;
43 gfx::SwapResult PostSubBuffer(int x, int y, int width, int height) override;
44 bool SupportsPostSubBuffer() override;
45 gfx::Size GetSize() override;
46 void* GetHandle() override;
47 bool OnMakeCurrent(gfx::GLContext* context) override;
48 bool SetBackbufferAllocation(bool allocated) override;
49 bool ScheduleOverlayPlane(int z_order,
50 gfx::OverlayTransform transform,
51 gl::GLImage* image,
52 const gfx::Rect& bounds_rect,
53 const gfx::RectF& crop_rect) override;
54 bool ScheduleCALayer(gl::GLImage* contents_image,
55 const gfx::RectF& contents_rect,
56 float opacity,
57 unsigned background_color,
58 unsigned edge_aa_mask,
59 const gfx::RectF& rect,
60 bool is_clipped,
61 const gfx::RectF& clip_rect,
62 const gfx::Transform& transform,
63 int sorting_context_id) override;
64 bool IsSurfaceless() const override;
65
66 // ui::GpuSwitchingObserver implementation.
67 void OnGpuSwitched() override;
68
69 private:
70 class PendingSwap;
71 class OverlayPlane;
72
73 ~ImageTransportSurfaceOverlayMac() override;
74
75 void SetLatencyInfo(const std::vector<ui::LatencyInfo>& latency_info);
76 void BufferPresented(int32_t surface_id,
77 const base::TimeTicks& vsync_timebase,
78 const base::TimeDelta& vsync_interval);
79 void SendAcceleratedSurfaceBuffersSwapped(
80 int32_t surface_id,
81 CAContextID ca_context_id,
82 const gfx::ScopedRefCountedIOSurfaceMachPort& io_surface,
83 const gfx::Size& size,
84 float scale_factor,
85 std::vector<ui::LatencyInfo> latency_info);
86 gfx::SwapResult SwapBuffersInternal(const gfx::Rect& pixel_damage_rect);
87
88 // Returns true if the front of |pending_swaps_| has completed, or has timed
89 // out by |now|.
90 bool IsFirstPendingSwapReadyToDisplay(
91 const base::TimeTicks& now);
92 // Sets the CALayer contents to the IOSurface for the front of
93 // |pending_swaps_|, and removes it from the queue.
94 void DisplayFirstPendingSwapImmediately();
95 // Force that all of |pending_swaps_| displayed immediately, and the list be
96 // cleared.
97 void DisplayAndClearAllPendingSwaps();
98 // Callback issued during the next vsync period ofter a SwapBuffers call,
99 // to check if the swap is completed, and display the frame. Note that if
100 // another SwapBuffers happens before this callback, the pending swap will
101 // be tested at that time, too.
102 void CheckPendingSwapsCallback();
103 // Function to post the above callback. The argument |now| is passed as an
104 // argument to avoid redundant calls to base::TimeTicks::Now.
105 void PostCheckPendingSwapsCallbackIfNeeded(const base::TimeTicks& now);
106
107 // Return the time of |interval_fraction| of the way through the next
108 // vsync period that starts after |from|. If the vsync parameters are not
109 // valid then return |from|.
110 base::TimeTicks GetNextVSyncTimeAfter(
111 const base::TimeTicks& from, double interval_fraction);
112
113 GpuChannelManager* manager_;
114 base::WeakPtr<GpuCommandBufferStub> stub_;
115 gpu::SurfaceHandle handle_;
116 std::vector<ui::LatencyInfo> latency_info_;
117
118 bool use_remote_layer_api_;
119 base::scoped_nsobject<CAContext> ca_context_;
120 base::scoped_nsobject<CALayer> ca_root_layer_;
121
122 gfx::Size pixel_size_;
123 float scale_factor_;
124
125 // The renderer ID that all contexts made current to this surface should be
126 // targeting.
127 GLint gl_renderer_id_;
128
129 // Planes that have been scheduled, but have not had a subsequent SwapBuffers
130 // call made yet.
131 scoped_ptr<CALayerPartialDamageTree> pending_partial_damage_tree_;
132 scoped_ptr<CALayerTree> pending_ca_layer_tree_;
133
134 // A queue of all frames that have been created by SwapBuffersInternal but
135 // have not yet been displayed. This queue is checked at the beginning of
136 // every swap and also by a callback.
137 std::deque<linked_ptr<PendingSwap>> pending_swaps_;
138
139 // The planes that are currently being displayed on the screen.
140 scoped_ptr<CALayerPartialDamageTree> current_partial_damage_tree_;
141 scoped_ptr<CALayerTree> current_ca_layer_tree_;
142
143 // The time of the last swap was issued. If this is more than two vsyncs, then
144 // use the simpler non-smooth animation path.
145 base::TimeTicks last_swap_time_;
146
147 // The vsync information provided by the browser.
148 bool vsync_parameters_valid_;
149 base::TimeTicks vsync_timebase_;
150 base::TimeDelta vsync_interval_;
151
152 base::Timer display_pending_swap_timer_;
153 base::WeakPtrFactory<ImageTransportSurfaceOverlayMac> weak_factory_;
154 };
155
156 } // namespace content
157
158 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_
OLDNEW
« no previous file with comments | « content/common/gpu/image_transport_surface_mac.mm ('k') | content/common/gpu/image_transport_surface_overlay_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698