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

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

Issue 885443002: Roll Chrome into Mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase to ToT mojo 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/test/fake_output_surface.h ('k') | cc/test/fake_picture_layer_tiling_client.cc » ('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 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 scoped_refptr<ContextProvider> context_provider,
19 bool delegated_rendering) 19 bool delegated_rendering)
20 : OutputSurface(context_provider), 20 : OutputSurface(context_provider),
21 client_(NULL), 21 client_(NULL),
22 num_sent_frames_(0), 22 num_sent_frames_(0),
23 has_external_stencil_test_(false) { 23 has_external_stencil_test_(false),
24 framebuffer_(0) {
24 if (delegated_rendering) { 25 if (delegated_rendering) {
25 capabilities_.delegated_rendering = true; 26 capabilities_.delegated_rendering = true;
26 capabilities_.max_frames_pending = 1; 27 capabilities_.max_frames_pending = 1;
27 } 28 }
28 } 29 }
29 30
30 FakeOutputSurface::FakeOutputSurface( 31 FakeOutputSurface::FakeOutputSurface(
31 scoped_ptr<SoftwareOutputDevice> software_device, 32 scoped_ptr<SoftwareOutputDevice> software_device,
32 bool delegated_rendering) 33 bool delegated_rendering)
33 : OutputSurface(software_device.Pass()), 34 : OutputSurface(software_device.Pass()),
34 client_(NULL), 35 client_(NULL),
35 num_sent_frames_(0), 36 num_sent_frames_(0),
36 has_external_stencil_test_(false) { 37 has_external_stencil_test_(false),
38 framebuffer_(0) {
37 if (delegated_rendering) { 39 if (delegated_rendering) {
38 capabilities_.delegated_rendering = true; 40 capabilities_.delegated_rendering = true;
39 capabilities_.max_frames_pending = 1; 41 capabilities_.max_frames_pending = 1;
40 } 42 }
41 } 43 }
42 44
43 FakeOutputSurface::FakeOutputSurface( 45 FakeOutputSurface::FakeOutputSurface(
44 scoped_refptr<ContextProvider> context_provider, 46 scoped_refptr<ContextProvider> context_provider,
45 scoped_ptr<SoftwareOutputDevice> software_device, 47 scoped_ptr<SoftwareOutputDevice> software_device,
46 bool delegated_rendering) 48 bool delegated_rendering)
47 : OutputSurface(context_provider, software_device.Pass()), 49 : OutputSurface(context_provider, software_device.Pass()),
48 client_(NULL), 50 client_(NULL),
49 num_sent_frames_(0), 51 num_sent_frames_(0),
50 has_external_stencil_test_(false) { 52 has_external_stencil_test_(false),
53 framebuffer_(0) {
51 if (delegated_rendering) { 54 if (delegated_rendering) {
52 capabilities_.delegated_rendering = true; 55 capabilities_.delegated_rendering = true;
53 capabilities_.max_frames_pending = 1; 56 capabilities_.max_frames_pending = 1;
54 } 57 }
55 } 58 }
56 59
57 FakeOutputSurface::~FakeOutputSurface() {} 60 FakeOutputSurface::~FakeOutputSurface() {}
58 61
59 void FakeOutputSurface::SwapBuffers(CompositorFrame* frame) { 62 void FakeOutputSurface::SwapBuffers(CompositorFrame* frame) {
60 if (frame->software_frame_data || frame->delegated_frame_data || 63 if (frame->software_frame_data || frame->delegated_frame_data ||
(...skipping 10 matching lines...) Expand all
71 ++num_sent_frames_; 74 ++num_sent_frames_;
72 } else { 75 } else {
73 last_swap_rect_ = frame->gl_frame_data->sub_buffer_rect; 76 last_swap_rect_ = frame->gl_frame_data->sub_buffer_rect;
74 frame->AssignTo(&last_sent_frame_); 77 frame->AssignTo(&last_sent_frame_);
75 ++num_sent_frames_; 78 ++num_sent_frames_;
76 } 79 }
77 PostSwapBuffersComplete(); 80 PostSwapBuffersComplete();
78 client_->DidSwapBuffers(); 81 client_->DidSwapBuffers();
79 } 82 }
80 83
84 void FakeOutputSurface::BindFramebuffer() {
85 if (framebuffer_)
86 context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER,
87 framebuffer_);
88 else
89 OutputSurface::BindFramebuffer();
90 }
91
81 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) { 92 bool FakeOutputSurface::BindToClient(OutputSurfaceClient* client) {
82 if (OutputSurface::BindToClient(client)) { 93 if (OutputSurface::BindToClient(client)) {
83 client_ = client; 94 client_ = client;
84 if (memory_policy_to_set_at_bind_) { 95 if (memory_policy_to_set_at_bind_) {
85 client_->SetMemoryPolicy(*memory_policy_to_set_at_bind_.get()); 96 client_->SetMemoryPolicy(*memory_policy_to_set_at_bind_.get());
86 memory_policy_to_set_at_bind_ = nullptr; 97 memory_policy_to_set_at_bind_ = nullptr;
87 } 98 }
88 return true; 99 return true;
89 } else { 100 } else {
90 return false; 101 return false;
(...skipping 22 matching lines...) Expand all
113 bool FakeOutputSurface::HasExternalStencilTest() const { 124 bool FakeOutputSurface::HasExternalStencilTest() const {
114 return has_external_stencil_test_; 125 return has_external_stencil_test_;
115 } 126 }
116 127
117 void FakeOutputSurface::SetMemoryPolicyToSetAtBind( 128 void FakeOutputSurface::SetMemoryPolicyToSetAtBind(
118 scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) { 129 scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) {
119 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind); 130 memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind);
120 } 131 }
121 132
122 } // namespace cc 133 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_output_surface.h ('k') | cc/test/fake_picture_layer_tiling_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698