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

Unified Diff: services/ui/ws/frame_generator.h

Issue 2400723003: Mus+Ash: Use standard cc mechanism for surface lifetime. (Closed)
Patch Set: Only add window observer if we're adding the dependency for the first time Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: services/ui/ws/frame_generator.h
diff --git a/services/ui/ws/frame_generator.h b/services/ui/ws/frame_generator.h
index af50d539b2eff6c4603e6950afe9914e3288ca05..f954fcd19bda5548517a7b40e02dc4a42c97c8dd 100644
--- a/services/ui/ws/frame_generator.h
+++ b/services/ui/ws/frame_generator.h
@@ -6,10 +6,15 @@
#define SERVICES_UI_WS_FRAME_GENERATOR_H_
#include <memory>
+#include <unordered_map>
#include "base/macros.h"
#include "base/timer/timer.h"
#include "cc/surfaces/frame_sink_id.h"
+#include "cc/surfaces/local_frame_id.h"
+#include "cc/surfaces/surface_sequence.h"
+#include "cc/surfaces/surface_sequence_generator.h"
+#include "services/ui/ws/server_window_observer.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/native_widget_types.h"
@@ -17,6 +22,7 @@ namespace cc {
class CompositorFrame;
class CopyOutputRequest;
class RenderPass;
+class SurfaceId;
}
namespace gpu {
@@ -39,14 +45,15 @@ class FrameGeneratorTest;
class FrameGeneratorDelegate;
class ServerWindow;
+class ServerWindowSurface;
// Responsible for redrawing the display in response to the redraw requests by
// submitting CompositorFrames to the owned CompositorFrameSink.
-class FrameGenerator {
+class FrameGenerator : public ServerWindowObserver {
public:
FrameGenerator(FrameGeneratorDelegate* delegate,
scoped_refptr<DisplayCompositor> display_compositor);
- virtual ~FrameGenerator();
+ ~FrameGenerator() override;
void OnGpuChannelEstablished(scoped_refptr<gpu::GpuChannelHost> gpu_channel);
@@ -74,8 +81,7 @@ class FrameGenerator {
void DidDraw();
// Generates the CompositorFrame for the current |dirty_rect_|.
- cc::CompositorFrame GenerateCompositorFrame(
- const gfx::Rect& output_rect) const;
+ cc::CompositorFrame GenerateCompositorFrame(const gfx::Rect& output_rect);
// DrawWindowTree recursively visits ServerWindows, creating a SurfaceDrawQuad
// for each that lacks one.
@@ -83,11 +89,26 @@ class FrameGenerator {
ServerWindow* window,
const gfx::Vector2d& parent_to_root_origin_offset,
float opacity,
- bool* may_contain_video) const;
+ bool* may_contain_video);
+
+ // Adds a reference to the current cc::Surface of the provided
+ // |window_surface|. If an existing reference is held with a different
+ // LocalFrameId then release that reference first.
rjkroege 2016/10/07 19:34:50 the arg is surface. not window_surface? Something
Fady Samuel 2016/10/07 20:31:33 Done.
+ void AddOrUpdateSurfaceReference(ServerWindowSurface* surface);
rjkroege 2016/10/07 19:34:50 can you say why/when we should call this?
Fady Samuel 2016/10/07 20:31:33 Done.
+
+ // Releases any retained references for the provided FrameSink.
+ void ReleaseFrameSinkReference(const cc::FrameSinkId& frame_sink_id);
+
+ // Releases all retained references to surfaces.
+ void ReleaseAllSurfaceReferences();
+
+ // ServerWindowObserver implementation.
+ void OnWindowDestroying(ServerWindow* window) override;
FrameGeneratorDelegate* delegate_;
scoped_refptr<DisplayCompositor> display_compositor_;
cc::FrameSinkId frame_sink_id_;
+ cc::SurfaceSequenceGenerator surface_sequence_generator_;
scoped_refptr<gpu::GpuChannelHost> gpu_channel_;
std::unique_ptr<surfaces::CompositorFrameSink> compositor_frame_sink_;
@@ -99,6 +120,12 @@ class FrameGenerator {
base::Timer draw_timer_;
bool frame_pending_ = false;
bool may_contain_video_ = false;
+ struct SurfaceDependency {
+ cc::LocalFrameId local_frame_id;
+ cc::SurfaceSequence sequence;
+ };
+ std::unordered_map<cc::FrameSinkId, SurfaceDependency, cc::FrameSinkIdHash>
+ dependencies_;
base::WeakPtrFactory<FrameGenerator> weak_factory_;

Powered by Google App Engine
This is Rietveld 408576698