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

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

Issue 1985973002: Defer compositor context creation to the thread. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: contextfactory: . Created 4 years, 7 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/compositor_frame_ack.h" 9 #include "cc/output/compositor_frame_ack.h"
10 #include "cc/output/output_surface_client.h" 10 #include "cc/output/output_surface_client.h"
11 #include "cc/resources/returned_resource.h" 11 #include "cc/resources/returned_resource.h"
12 #include "cc/test/begin_frame_args_test.h" 12 #include "cc/test/begin_frame_args_test.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace cc { 15 namespace cc {
16 16
17 FakeOutputSurface::FakeOutputSurface( 17 FakeOutputSurface::FakeOutputSurface(
18 scoped_refptr<ContextProvider> context_provider, 18 std::unique_ptr<ContextProvider::Factory> compositor_context_factory,
19 scoped_refptr<ContextProvider> worker_context_provider, 19 scoped_refptr<ContextProvider> worker_context_provider,
20 bool delegated_rendering) 20 bool delegated_rendering)
21 : OutputSurface(context_provider, worker_context_provider), 21 : OutputSurface(std::move(compositor_context_factory),
22 std::move(worker_context_provider)),
22 client_(NULL), 23 client_(NULL),
23 num_sent_frames_(0), 24 num_sent_frames_(0),
24 has_external_stencil_test_(false), 25 has_external_stencil_test_(false),
25 suspended_for_recycle_(false), 26 suspended_for_recycle_(false),
26 framebuffer_(0), 27 framebuffer_(0),
27 overlay_candidate_validator_(nullptr) { 28 overlay_candidate_validator_(nullptr) {
28 capabilities_.delegated_rendering = delegated_rendering; 29 capabilities_.delegated_rendering = delegated_rendering;
29 } 30 }
30 31
31 FakeOutputSurface::FakeOutputSurface( 32 FakeOutputSurface::FakeOutputSurface(
32 scoped_refptr<ContextProvider> context_provider, 33 std::unique_ptr<ContextProvider::Factory> compositor_context_factory,
33 bool delegated_rendering) 34 bool delegated_rendering)
34 : OutputSurface(context_provider), 35 : OutputSurface(std::move(compositor_context_factory)),
35 client_(NULL), 36 client_(NULL),
36 num_sent_frames_(0), 37 num_sent_frames_(0),
37 has_external_stencil_test_(false), 38 has_external_stencil_test_(false),
38 suspended_for_recycle_(false), 39 suspended_for_recycle_(false),
39 framebuffer_(0), 40 framebuffer_(0),
40 overlay_candidate_validator_(nullptr) { 41 overlay_candidate_validator_(nullptr) {
41 capabilities_.delegated_rendering = delegated_rendering; 42 capabilities_.delegated_rendering = delegated_rendering;
42 } 43 }
43 44
44 FakeOutputSurface::FakeOutputSurface( 45 FakeOutputSurface::FakeOutputSurface(
45 std::unique_ptr<SoftwareOutputDevice> software_device, 46 std::unique_ptr<SoftwareOutputDevice> software_device,
46 bool delegated_rendering) 47 bool delegated_rendering)
47 : OutputSurface(std::move(software_device)), 48 : OutputSurface(std::move(software_device)),
48 client_(NULL), 49 client_(NULL),
49 num_sent_frames_(0), 50 num_sent_frames_(0),
50 has_external_stencil_test_(false), 51 has_external_stencil_test_(false),
51 suspended_for_recycle_(false), 52 suspended_for_recycle_(false),
52 framebuffer_(0), 53 framebuffer_(0),
53 overlay_candidate_validator_(nullptr) { 54 overlay_candidate_validator_(nullptr) {
54 capabilities_.delegated_rendering = delegated_rendering; 55 capabilities_.delegated_rendering = delegated_rendering;
55 } 56 }
56 57
57 FakeOutputSurface::FakeOutputSurface( 58 FakeOutputSurface::FakeOutputSurface(
58 scoped_refptr<ContextProvider> context_provider, 59 std::unique_ptr<ContextProvider::Factory> compositor_context_factory,
59 std::unique_ptr<SoftwareOutputDevice> software_device, 60 std::unique_ptr<SoftwareOutputDevice> software_device,
60 bool delegated_rendering) 61 bool delegated_rendering)
61 : OutputSurface(context_provider, std::move(software_device)), 62 : OutputSurface(std::move(compositor_context_factory),
63 std::move(software_device)),
62 client_(NULL), 64 client_(NULL),
63 num_sent_frames_(0), 65 num_sent_frames_(0),
64 has_external_stencil_test_(false), 66 has_external_stencil_test_(false),
65 suspended_for_recycle_(false), 67 suspended_for_recycle_(false),
66 framebuffer_(0), 68 framebuffer_(0),
67 overlay_candidate_validator_(nullptr) { 69 overlay_candidate_validator_(nullptr) {
68 capabilities_.delegated_rendering = delegated_rendering; 70 capabilities_.delegated_rendering = delegated_rendering;
69 } 71 }
70 72
71 FakeOutputSurface::~FakeOutputSurface() {} 73 FakeOutputSurface::~FakeOutputSurface() {}
(...skipping 13 matching lines...) Expand all
85 } else { 87 } else {
86 last_swap_rect_ = frame->gl_frame_data->sub_buffer_rect; 88 last_swap_rect_ = frame->gl_frame_data->sub_buffer_rect;
87 frame->AssignTo(&last_sent_frame_); 89 frame->AssignTo(&last_sent_frame_);
88 ++num_sent_frames_; 90 ++num_sent_frames_;
89 } 91 }
90 PostSwapBuffersComplete(); 92 PostSwapBuffersComplete();
91 client_->DidSwapBuffers(); 93 client_->DidSwapBuffers();
92 } 94 }
93 95
94 void FakeOutputSurface::BindFramebuffer() { 96 void FakeOutputSurface::BindFramebuffer() {
95 if (framebuffer_) 97 if (framebuffer_) {
96 context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 98 compositor_context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER,
97 framebuffer_); 99 framebuffer_);
98 else 100 } else {
99 OutputSurface::BindFramebuffer(); 101 OutputSurface::BindFramebuffer();
102 }
100 } 103 }
101 104
102 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) { 105 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) {
103 if (OutputSurface::BindToClient(client)) { 106 if (OutputSurface::BindToClient(client)) {
104 client_ = client; 107 client_ = client;
105 if (memory_policy_to_set_at_bind_) { 108 if (memory_policy_to_set_at_bind_) {
106 client_->SetMemoryPolicy(*memory_policy_to_set_at_bind_.get()); 109 client_->SetMemoryPolicy(*memory_policy_to_set_at_bind_.get());
107 memory_policy_to_set_at_bind_ = nullptr; 110 memory_policy_to_set_at_bind_ = nullptr;
108 } 111 }
109 return true; 112 return true;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 const { 146 const {
144 return overlay_candidate_validator_; 147 return overlay_candidate_validator_;
145 } 148 }
146 149
147 void FakeOutputSurface::SetMemoryPolicyToSetAtBind( 150 void FakeOutputSurface::SetMemoryPolicyToSetAtBind(
148 std::unique_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) { 151 std::unique_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) {
149 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind); 152 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind);
150 } 153 }
151 154
152 } // namespace cc 155 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698