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

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

Issue 2402173002: cc: Get rid of PostSwapBuffersComplete. (Closed)
Patch Set: postswap: . 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/pixel_test_output_surface.h" 5 #include "cc/test/pixel_test_output_surface.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h"
10 #include "base/threading/thread_task_runner_handle.h"
9 #include "cc/output/output_surface_client.h" 11 #include "cc/output/output_surface_client.h"
10 #include "cc/output/output_surface_frame.h" 12 #include "cc/output/output_surface_frame.h"
11 #include "gpu/command_buffer/client/gles2_interface.h" 13 #include "gpu/command_buffer/client/gles2_interface.h"
12 #include "third_party/khronos/GLES2/gl2.h" 14 #include "third_party/khronos/GLES2/gl2.h"
13 #include "ui/gfx/transform.h" 15 #include "ui/gfx/transform.h"
14 16
15 namespace cc { 17 namespace cc {
16 18
17 PixelTestOutputSurface::PixelTestOutputSurface( 19 PixelTestOutputSurface::PixelTestOutputSurface(
18 scoped_refptr<ContextProvider> context_provider, 20 scoped_refptr<ContextProvider> context_provider,
19 bool flipped_output_surface) 21 bool flipped_output_surface)
20 : OutputSurface(std::move(context_provider)), 22 : OutputSurface(std::move(context_provider)), weak_ptr_factory_(this) {
21 external_stencil_test_(false) {
22 capabilities_.flipped_output_surface = flipped_output_surface; 23 capabilities_.flipped_output_surface = flipped_output_surface;
23 } 24 }
24 25
25 PixelTestOutputSurface::PixelTestOutputSurface( 26 PixelTestOutputSurface::PixelTestOutputSurface(
26 std::unique_ptr<SoftwareOutputDevice> software_device) 27 std::unique_ptr<SoftwareOutputDevice> software_device)
27 : OutputSurface(std::move(software_device)), 28 : OutputSurface(std::move(software_device)), weak_ptr_factory_(this) {}
28 external_stencil_test_(false) {}
29 29
30 PixelTestOutputSurface::~PixelTestOutputSurface() = default; 30 PixelTestOutputSurface::~PixelTestOutputSurface() = default;
31 31
32 void PixelTestOutputSurface::EnsureBackbuffer() {} 32 void PixelTestOutputSurface::EnsureBackbuffer() {}
33 33
34 void PixelTestOutputSurface::DiscardBackbuffer() {} 34 void PixelTestOutputSurface::DiscardBackbuffer() {}
35 35
36 void PixelTestOutputSurface::BindFramebuffer() { 36 void PixelTestOutputSurface::BindFramebuffer() {
37 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); 37 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0);
38 } 38 }
39 39
40 void PixelTestOutputSurface::Reshape(const gfx::Size& size, 40 void PixelTestOutputSurface::Reshape(const gfx::Size& size,
41 float scale_factor, 41 float scale_factor,
42 const gfx::ColorSpace& color_space, 42 const gfx::ColorSpace& color_space,
43 bool has_alpha) { 43 bool has_alpha) {
44 gfx::Size expanded_size(size.width() + surface_expansion_size_.width(), 44 gfx::Size expanded_size(size.width() + surface_expansion_size_.width(),
45 size.height() + surface_expansion_size_.height()); 45 size.height() + surface_expansion_size_.height());
46 OutputSurface::Reshape(expanded_size, scale_factor, color_space, has_alpha); 46 OutputSurface::Reshape(expanded_size, scale_factor, color_space, has_alpha);
47 } 47 }
48 48
49 bool PixelTestOutputSurface::HasExternalStencilTest() const { 49 bool PixelTestOutputSurface::HasExternalStencilTest() const {
50 return external_stencil_test_; 50 return external_stencil_test_;
51 } 51 }
52 52
53 void PixelTestOutputSurface::ApplyExternalStencil() {} 53 void PixelTestOutputSurface::ApplyExternalStencil() {}
54 54
55 void PixelTestOutputSurface::SwapBuffers(OutputSurfaceFrame frame) { 55 void PixelTestOutputSurface::SwapBuffers(OutputSurfaceFrame frame) {
56 PostSwapBuffersComplete(); 56 base::ThreadTaskRunnerHandle::Get()->PostTask(
57 FROM_HERE, base::Bind(&PixelTestOutputSurface::SwapBuffersCallback,
58 weak_ptr_factory_.GetWeakPtr()));
59 }
60
61 void PixelTestOutputSurface::SwapBuffersCallback() {
62 client_->DidSwapBuffersComplete();
57 } 63 }
58 64
59 OverlayCandidateValidator* 65 OverlayCandidateValidator*
60 PixelTestOutputSurface::GetOverlayCandidateValidator() const { 66 PixelTestOutputSurface::GetOverlayCandidateValidator() const {
61 return nullptr; 67 return nullptr;
62 } 68 }
63 69
64 bool PixelTestOutputSurface::IsDisplayedAsOverlayPlane() const { 70 bool PixelTestOutputSurface::IsDisplayedAsOverlayPlane() const {
65 return false; 71 return false;
66 } 72 }
67 73
68 unsigned PixelTestOutputSurface::GetOverlayTextureId() const { 74 unsigned PixelTestOutputSurface::GetOverlayTextureId() const {
69 return 0; 75 return 0;
70 } 76 }
71 77
72 bool PixelTestOutputSurface::SurfaceIsSuspendForRecycle() const { 78 bool PixelTestOutputSurface::SurfaceIsSuspendForRecycle() const {
73 return false; 79 return false;
74 } 80 }
75 81
76 uint32_t PixelTestOutputSurface::GetFramebufferCopyTextureFormat() { 82 uint32_t PixelTestOutputSurface::GetFramebufferCopyTextureFormat() {
77 // This format will work if the |context_provider| has an RGB or RGBA 83 // This format will work if the |context_provider| has an RGB or RGBA
78 // framebuffer. For now assume tests do not want/care about alpha in 84 // framebuffer. For now assume tests do not want/care about alpha in
79 // the root render pass. 85 // the root render pass.
80 return GL_RGB; 86 return GL_RGB;
81 } 87 }
82 88
83 } // namespace cc 89 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698