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

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

Issue 1273563002: Mac Overlays: Add GPU back-pressure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use default fences Created 5 years, 4 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 2015 The Chromium Authors. All rights reserved. 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 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_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ 5 #ifndef CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_
6 #define CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ 6 #define CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_
7 7
8 #include <deque>
9
10 #include "base/memory/linked_ptr.h"
8 #import "base/mac/scoped_nsobject.h" 11 #import "base/mac/scoped_nsobject.h"
9 #include "content/common/gpu/gpu_command_buffer_stub.h" 12 #include "content/common/gpu/gpu_command_buffer_stub.h"
10 #include "content/common/gpu/image_transport_surface.h" 13 #include "content/common/gpu/image_transport_surface.h"
14 #include "ui/accelerated_widget_mac/display_link_mac.h"
11 #include "ui/gl/gl_surface.h" 15 #include "ui/gl/gl_surface.h"
12 16
13 @class CAContext; 17 @class CAContext;
14 @class CALayer; 18 @class CALayer;
15 19
16 namespace content { 20 namespace content {
17 21
18 class ImageTransportSurfaceOverlayMac : public gfx::GLSurface, 22 class ImageTransportSurfaceOverlayMac : public gfx::GLSurface,
19 public ImageTransportSurface { 23 public ImageTransportSurface {
20 public: 24 public:
(...skipping 19 matching lines...) Expand all
40 bool IsSurfaceless() const override; 44 bool IsSurfaceless() const override;
41 45
42 // ImageTransportSurface implementation 46 // ImageTransportSurface implementation
43 void OnBufferPresented( 47 void OnBufferPresented(
44 const AcceleratedSurfaceMsg_BufferPresented_Params& params) override; 48 const AcceleratedSurfaceMsg_BufferPresented_Params& params) override;
45 void OnResize(gfx::Size pixel_size, float scale_factor) override; 49 void OnResize(gfx::Size pixel_size, float scale_factor) override;
46 void SetLatencyInfo(const std::vector<ui::LatencyInfo>&) override; 50 void SetLatencyInfo(const std::vector<ui::LatencyInfo>&) override;
47 void WakeUpGpu() override; 51 void WakeUpGpu() override;
48 52
49 private: 53 private:
54 class PendingSwap;
55
50 ~ImageTransportSurfaceOverlayMac() override; 56 ~ImageTransportSurfaceOverlayMac() override;
57
58 gfx::SwapResult SwapBuffersInternal(const gfx::Rect& pixel_damage_rect);
59
60 // Returns true if the front of |pending_swaps_| has completed, or has timed
61 // out by |now|.
62 bool IsFirstPendingSwapReadyToDisplay(
63 const base::TimeTicks& now);
64 // Sets the CALayer contents to the IOSurface for the front of
65 // |pending_swaps_|, and removes it from the queue.
66 void DisplayFirstPendingSwapImmediately();
67 // Force that all of |pending_swaps_| displayed immediately, and the list be
68 // cleared.
69 void FinishAllPendingSwaps();
70 // Callback issued during the next vsync period ofter a SwapBuffers call,
71 // to check if the swap is completed, and display the frame. Note that if
72 // another SwapBuffers happens before this callback, the pending swap will
73 // be tested at that time, too.
74 void CheckPendingSwapsCallback();
75 // Function to post the above callback. The argument |now| is passed as an
76 // argument to avoid redundant calls to base::TimeTicks::Now.
77 void PostCheckPendingSwapsCallbackIfNeeded(const base::TimeTicks& now);
78
51 scoped_ptr<ImageTransportHelper> helper_; 79 scoped_ptr<ImageTransportHelper> helper_;
52 base::scoped_nsobject<CAContext> ca_context_; 80 base::scoped_nsobject<CAContext> ca_context_;
53 base::scoped_nsobject<CALayer> layer_; 81 base::scoped_nsobject<CALayer> layer_;
54 82
55 // A phony NSView handle used to identify this.
56 gfx::AcceleratedWidget widget_;
57
58 gfx::Size pixel_size_; 83 gfx::Size pixel_size_;
59 float scale_factor_; 84 float scale_factor_;
60 std::vector<ui::LatencyInfo> latency_info_; 85 std::vector<ui::LatencyInfo> latency_info_;
61 86
62 // Weak pointer to the image provided when ScheduleOverlayPlane is called. Is 87 // Weak pointer to the image provided when ScheduleOverlayPlane is called. Is
63 // consumed and reset when SwapBuffers is called. For now, only one overlay 88 // consumed and reset when SwapBuffers is called. For now, only one overlay
64 // plane is supported. 89 // plane is supported.
65 gfx::GLImage* pending_overlay_image_; 90 gfx::GLImage* pending_overlay_image_;
91
92 // A queue of all frames that have been created by SwapBuffersInternal but
93 // have not yet been displayed. This queue is checked at the beginning of
94 // every swap and also by a callback.
95 std::deque<linked_ptr<PendingSwap>> pending_swaps_;
96
97 // The display link used to compute the time for callbacks.
98 scoped_refptr<ui::DisplayLinkMac> display_link_mac_;
99
100 // True if there is a pending call to CheckPendingSwapsCallback posted.
101 bool has_pending_callback_;
102
103 base::WeakPtrFactory<ImageTransportSurfaceOverlayMac> weak_factory_;
66 }; 104 };
67 105
68 } // namespace content 106 } // namespace content
69 107
70 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_ 108 #endif // CONTENT_COMMON_GPU_IMAGE_TRANSPORT_SURFACE_OVERLAY_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698