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

Side by Side Diff: cc/surfaces/surface_display_output_surface.cc

Issue 2103333002: Revert of Make cc::CompositorFrames movable [Part 2 of 2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « cc/surfaces/surface_aggregator_unittest.cc ('k') | cc/surfaces/surface_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "cc/surfaces/surface_display_output_surface.h" 5 #include "cc/surfaces/surface_display_output_surface.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "cc/output/compositor_frame.h" 8 #include "cc/output/compositor_frame.h"
9 #include "cc/output/compositor_frame_ack.h" 9 #include "cc/output/compositor_frame_ack.h"
10 #include "cc/surfaces/display.h" 10 #include "cc/surfaces/display.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 delegated_surface_id_ = surface_id_allocator_->GenerateId(); 70 delegated_surface_id_ = surface_id_allocator_->GenerateId();
71 factory_.Create(delegated_surface_id_); 71 factory_.Create(delegated_surface_id_);
72 last_swap_frame_size_ = frame_size; 72 last_swap_frame_size_ = frame_size;
73 } 73 }
74 display_->SetSurfaceId(delegated_surface_id_, 74 display_->SetSurfaceId(delegated_surface_id_,
75 frame.metadata.device_scale_factor); 75 frame.metadata.device_scale_factor);
76 76
77 client_->DidSwapBuffers(); 77 client_->DidSwapBuffers();
78 78
79 std::unique_ptr<CompositorFrame> frame_copy(new CompositorFrame);
80 *frame_copy = std::move(frame);
79 factory_.SubmitCompositorFrame( 81 factory_.SubmitCompositorFrame(
80 delegated_surface_id_, std::move(frame), 82 delegated_surface_id_, std::move(frame_copy),
81 base::Bind(&SurfaceDisplayOutputSurface::SwapBuffersComplete, 83 base::Bind(&SurfaceDisplayOutputSurface::SwapBuffersComplete,
82 base::Unretained(this))); 84 base::Unretained(this)));
83 } 85 }
84 86
85 bool SurfaceDisplayOutputSurface::BindToClient(OutputSurfaceClient* client) { 87 bool SurfaceDisplayOutputSurface::BindToClient(OutputSurfaceClient* client) {
86 DCHECK(thread_checker_.CalledOnValidThread()); 88 DCHECK(thread_checker_.CalledOnValidThread());
87 89
88 surface_manager_->RegisterSurfaceFactoryClient( 90 surface_manager_->RegisterSurfaceFactoryClient(
89 surface_id_allocator_->id_namespace(), this); 91 surface_id_allocator_->id_namespace(), this);
90 92
91 if (!OutputSurface::BindToClient(client)) 93 if (!OutputSurface::BindToClient(client))
92 return false; 94 return false;
93 95
94 // We want the Display's output surface to hear about lost context, and since 96 // We want the Display's output surface to hear about lost context, and since
95 // this shares a context with it, we should not be listening for lost context 97 // this shares a context with it, we should not be listening for lost context
96 // callbacks on the context here. 98 // callbacks on the context here.
97 if (context_provider()) 99 if (context_provider())
98 context_provider()->SetLostContextCallback(base::Closure()); 100 context_provider()->SetLostContextCallback(base::Closure());
99 101
100 // Avoid initializing GL context here, as this should be sharing the 102 // Avoid initializing GL context here, as this should be sharing the
101 // Display's context. 103 // Display's context.
102 display_->Initialize(this); 104 display_->Initialize(this);
103 return true; 105 return true;
104 } 106 }
105 107
106 void SurfaceDisplayOutputSurface::ForceReclaimResources() { 108 void SurfaceDisplayOutputSurface::ForceReclaimResources() {
107 if (!delegated_surface_id_.is_null()) { 109 if (!delegated_surface_id_.is_null()) {
108 factory_.SubmitCompositorFrame(delegated_surface_id_, CompositorFrame(), 110 factory_.SubmitCompositorFrame(delegated_surface_id_, nullptr,
109 SurfaceFactory::DrawCallback()); 111 SurfaceFactory::DrawCallback());
110 } 112 }
111 } 113 }
112 114
113 void SurfaceDisplayOutputSurface::DetachFromClient() { 115 void SurfaceDisplayOutputSurface::DetachFromClient() {
114 DCHECK(HasClient()); 116 DCHECK(HasClient());
115 // Unregister the SurfaceFactoryClient here instead of the dtor so that only 117 // Unregister the SurfaceFactoryClient here instead of the dtor so that only
116 // one client is alive for this namespace at any given time. 118 // one client is alive for this namespace at any given time.
117 surface_manager_->UnregisterSurfaceFactoryClient( 119 surface_manager_->UnregisterSurfaceFactoryClient(
118 surface_id_allocator_->id_namespace()); 120 surface_id_allocator_->id_namespace());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 SetMemoryPolicy(policy); 159 SetMemoryPolicy(policy);
158 } 160 }
159 161
160 void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) { 162 void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) {
161 // TODO(danakj): Why the lost check? 163 // TODO(danakj): Why the lost check?
162 if (!output_surface_lost_) 164 if (!output_surface_lost_)
163 client_->DidSwapBuffersComplete(); 165 client_->DidSwapBuffersComplete();
164 } 166 }
165 167
166 } // namespace cc 168 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_aggregator_unittest.cc ('k') | cc/surfaces/surface_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698