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

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

Issue 895853003: Update from https://crrev.com/314320 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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_display_output_surface.h ('k') | cc/test/data/yuv_stripes_offset.png » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "cc/surfaces/surface_display_output_surface.h"
6
7 #include "cc/output/compositor_frame.h"
8 #include "cc/output/compositor_frame_ack.h"
9 #include "cc/surfaces/display.h"
10 #include "cc/surfaces/onscreen_display_client.h"
11 #include "cc/surfaces/surface.h"
12 #include "cc/surfaces/surface_manager.h"
13
14 namespace cc {
15
16 SurfaceDisplayOutputSurface::SurfaceDisplayOutputSurface(
17 SurfaceManager* surface_manager,
18 SurfaceIdAllocator* allocator,
19 const scoped_refptr<ContextProvider>& context_provider)
20 : OutputSurface(context_provider, nullptr),
21 display_client_(NULL),
22 surface_manager_(surface_manager),
23 factory_(surface_manager, this),
24 allocator_(allocator) {
25 capabilities_.delegated_rendering = true;
26 capabilities_.max_frames_pending = 1;
27 capabilities_.can_force_reclaim_resources = true;
28 }
29
30 SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() {
31 client_ = NULL;
32 if (!surface_id_.is_null()) {
33 factory_.Destroy(surface_id_);
34 }
35 }
36
37 void SurfaceDisplayOutputSurface::ReceivedVSyncParameters(
38 base::TimeTicks timebase,
39 base::TimeDelta interval) {
40 CommitVSyncParameters(timebase, interval);
41 }
42
43 void SurfaceDisplayOutputSurface::SwapBuffers(CompositorFrame* frame) {
44 gfx::Size frame_size =
45 frame->delegated_frame_data->render_pass_list.back()->output_rect.size();
46 if (frame_size != display_size_) {
47 if (!surface_id_.is_null()) {
48 factory_.Destroy(surface_id_);
49 }
50 surface_id_ = allocator_->GenerateId();
51 factory_.Create(surface_id_);
52 display_size_ = frame_size;
53 }
54 display_client_->display()->SetSurfaceId(surface_id_,
55 frame->metadata.device_scale_factor);
56
57 scoped_ptr<CompositorFrame> frame_copy(new CompositorFrame());
58 frame->AssignTo(frame_copy.get());
59 factory_.SubmitFrame(
60 surface_id_, frame_copy.Pass(),
61 base::Bind(&SurfaceDisplayOutputSurface::SwapBuffersComplete,
62 base::Unretained(this)));
63
64 client_->DidSwapBuffers();
65 }
66
67 bool SurfaceDisplayOutputSurface::BindToClient(OutputSurfaceClient* client) {
68 DCHECK(client);
69 DCHECK(display_client_);
70 client_ = client;
71 // Avoid initializing GL context here, as this should be sharing the
72 // Display's context.
73 return display_client_->Initialize();
74 }
75
76 void SurfaceDisplayOutputSurface::ForceReclaimResources() {
77 if (!surface_id_.is_null()) {
78 scoped_ptr<CompositorFrame> empty_frame(new CompositorFrame());
79 empty_frame->delegated_frame_data.reset(new DelegatedFrameData);
80 factory_.SubmitFrame(surface_id_, empty_frame.Pass(),
81 SurfaceFactory::DrawCallback());
82 }
83 }
84
85 void SurfaceDisplayOutputSurface::ReturnResources(
86 const ReturnedResourceArray& resources) {
87 CompositorFrameAck ack;
88 ack.resources = resources;
89 if (client_)
90 client_->ReclaimResources(&ack);
91 }
92
93 void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) {
94 if (client_ && !display_client_->output_surface_lost())
95 client_->DidSwapBuffersComplete();
96 }
97
98 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_display_output_surface.h ('k') | cc/test/data/yuv_stripes_offset.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698