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

Side by Side Diff: cc/test/fake_output_surface.cc

Issue 2374183006: Remove GLFrameData from CompositorFrame. (Closed)
Patch Set: Rebase + fix includes. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/test/fake_output_surface.h" 5 #include "cc/test/fake_output_surface.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "cc/output/output_surface_client.h" 9 #include "cc/output/output_surface_client.h"
10 #include "cc/resources/returned_resource.h" 10 #include "cc/resources/returned_resource.h"
11 #include "cc/test/begin_frame_args_test.h" 11 #include "cc/test/begin_frame_args_test.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 FakeOutputSurface::FakeOutputSurface( 16 FakeOutputSurface::FakeOutputSurface(
17 scoped_refptr<ContextProvider> context_provider) 17 scoped_refptr<ContextProvider> context_provider)
18 : OutputSurface(std::move(context_provider)) {} 18 : OutputSurface(std::move(context_provider)) {}
19 19
20 FakeOutputSurface::FakeOutputSurface( 20 FakeOutputSurface::FakeOutputSurface(
21 std::unique_ptr<SoftwareOutputDevice> software_device) 21 std::unique_ptr<SoftwareOutputDevice> software_device)
22 : OutputSurface(std::move(software_device)) {} 22 : OutputSurface(std::move(software_device)) {}
23 23
24 FakeOutputSurface::~FakeOutputSurface() = default; 24 FakeOutputSurface::~FakeOutputSurface() = default;
25 25
26 void FakeOutputSurface::SwapBuffers(CompositorFrame frame) { 26 void FakeOutputSurface::SwapBuffers(OutputSurfaceFrame frame) {
27 ReturnResourcesHeldByParent(); 27 last_sent_frame_.reset(new OutputSurfaceFrame(std::move(frame)));
28
29 last_sent_frame_.reset(new CompositorFrame(std::move(frame)));
30 ++num_sent_frames_; 28 ++num_sent_frames_;
31 29
32 if (last_sent_frame_->delegated_frame_data) { 30 if (context_provider()) {
33 auto* frame_data = last_sent_frame_->delegated_frame_data.get(); 31 last_swap_rect_ = last_sent_frame_->sub_buffer_rect;
34 last_swap_rect_ = frame_data->render_pass_list.back()->damage_rect;
35 last_swap_rect_valid_ = true;
36 } else if (context_provider()) {
37 last_swap_rect_ = last_sent_frame_->gl_frame_data->sub_buffer_rect;
38 last_swap_rect_valid_ = true; 32 last_swap_rect_valid_ = true;
39 } else { 33 } else {
40 // Unknown for direct software frames. 34 // Unknown for direct software frames.
41 last_swap_rect_ = gfx::Rect(); 35 last_swap_rect_ = gfx::Rect();
42 last_swap_rect_valid_ = false; 36 last_swap_rect_valid_ = false;
43 } 37 }
44 38
45 if (last_sent_frame_->delegated_frame_data || !context_provider()) {
46 if (last_sent_frame_->delegated_frame_data) {
47 auto* frame_data = last_sent_frame_->delegated_frame_data.get();
48 resources_held_by_parent_.insert(resources_held_by_parent_.end(),
49 frame_data->resource_list.begin(),
50 frame_data->resource_list.end());
51 }
52 }
53
54 PostSwapBuffersComplete(); 39 PostSwapBuffersComplete();
55 } 40 }
56 41
57 void FakeOutputSurface::BindFramebuffer() { 42 void FakeOutputSurface::BindFramebuffer() {
58 context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, framebuffer_); 43 context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, framebuffer_);
59 } 44 }
60 45
61 uint32_t FakeOutputSurface::GetFramebufferCopyTextureFormat() { 46 uint32_t FakeOutputSurface::GetFramebufferCopyTextureFormat() {
62 if (framebuffer_) 47 if (framebuffer_)
63 return framebuffer_format_; 48 return framebuffer_format_;
(...skipping 24 matching lines...) Expand all
88 } 73 }
89 74
90 bool FakeOutputSurface::IsDisplayedAsOverlayPlane() const { 75 bool FakeOutputSurface::IsDisplayedAsOverlayPlane() const {
91 return false; 76 return false;
92 } 77 }
93 78
94 unsigned FakeOutputSurface::GetOverlayTextureId() const { 79 unsigned FakeOutputSurface::GetOverlayTextureId() const {
95 return 0; 80 return 0;
96 } 81 }
97 82
98 void FakeOutputSurface::ReturnResourcesHeldByParent() {
99 // Check |delegated_frame_data| because we shouldn't reclaim resources
100 // for the Display which does not swap delegated frames.
101 if (last_sent_frame_ && last_sent_frame_->delegated_frame_data) {
102 // Return the last frame's resources immediately.
103 ReturnedResourceArray resources;
104 for (const auto& resource : resources_held_by_parent_)
105 resources.push_back(resource.ToReturnedResource());
106 resources_held_by_parent_.clear();
107 client_->ReclaimResources(resources);
108 }
109 }
110
111 } // namespace cc 83 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698