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

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

Issue 2096493002: Make cc::CompositorFrames movable [Part 1 of 2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix reflector Created 4 years, 6 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 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 capabilities_.adjust_deadline_for_parent = true; 53 capabilities_.adjust_deadline_for_parent = true;
54 capabilities_.can_force_reclaim_resources = true; 54 capabilities_.can_force_reclaim_resources = true;
55 } 55 }
56 56
57 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() { 57 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() {
58 DCHECK(thread_checker_.CalledOnValidThread()); 58 DCHECK(thread_checker_.CalledOnValidThread());
59 if (HasClient()) 59 if (HasClient())
60 DetachFromClient(); 60 DetachFromClient();
61 } 61 }
62 62
63 void SurfaceDisplayOutputSurface::SwapBuffers(CompositorFrame* frame) { 63 void SurfaceDisplayOutputSurface::SwapBuffers(
64 std::unique_ptr<CompositorFrame> frame) {
64 gfx::Size frame_size = 65 gfx::Size frame_size =
65 frame->delegated_frame_data->render_pass_list.back()->output_rect.size(); 66 frame->delegated_frame_data->render_pass_list.back()->output_rect.size();
66 if (frame_size.IsEmpty() || frame_size != last_swap_frame_size_) { 67 if (frame_size.IsEmpty() || frame_size != last_swap_frame_size_) {
67 if (!delegated_surface_id_.is_null()) { 68 if (!delegated_surface_id_.is_null()) {
68 factory_.Destroy(delegated_surface_id_); 69 factory_.Destroy(delegated_surface_id_);
69 } 70 }
70 delegated_surface_id_ = surface_id_allocator_->GenerateId(); 71 delegated_surface_id_ = surface_id_allocator_->GenerateId();
71 factory_.Create(delegated_surface_id_); 72 factory_.Create(delegated_surface_id_);
72 last_swap_frame_size_ = frame_size; 73 last_swap_frame_size_ = frame_size;
73 } 74 }
74 display_->SetSurfaceId(delegated_surface_id_, 75 display_->SetSurfaceId(delegated_surface_id_,
75 frame->metadata.device_scale_factor); 76 frame->metadata.device_scale_factor);
76 77
77 client_->DidSwapBuffers(); 78 client_->DidSwapBuffers();
78 79
79 std::unique_ptr<CompositorFrame> frame_copy(new CompositorFrame());
80 frame->AssignTo(frame_copy.get());
81 factory_.SubmitCompositorFrame( 80 factory_.SubmitCompositorFrame(
82 delegated_surface_id_, std::move(frame_copy), 81 delegated_surface_id_, std::move(frame),
83 base::Bind(&SurfaceDisplayOutputSurface::SwapBuffersComplete, 82 base::Bind(&SurfaceDisplayOutputSurface::SwapBuffersComplete,
84 base::Unretained(this))); 83 base::Unretained(this)));
85 } 84 }
86 85
87 bool SurfaceDisplayOutputSurface::BindToClient(OutputSurfaceClient* client) { 86 bool SurfaceDisplayOutputSurface::BindToClient(OutputSurfaceClient* client) {
88 DCHECK(thread_checker_.CalledOnValidThread()); 87 DCHECK(thread_checker_.CalledOnValidThread());
89 88
90 surface_manager_->RegisterSurfaceFactoryClient( 89 surface_manager_->RegisterSurfaceFactoryClient(
91 surface_id_allocator_->id_namespace(), this); 90 surface_id_allocator_->id_namespace(), this);
92 91
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 SetMemoryPolicy(policy); 158 SetMemoryPolicy(policy);
160 } 159 }
161 160
162 void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) { 161 void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) {
163 // TODO(danakj): Why the lost check? 162 // TODO(danakj): Why the lost check?
164 if (!output_surface_lost_) 163 if (!output_surface_lost_)
165 client_->DidSwapBuffersComplete(); 164 client_->DidSwapBuffersComplete();
166 } 165 }
167 166
168 } // namespace cc 167 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698