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

Side by Side Diff: gpu/ipc/service/pass_through_image_transport_surface.cc

Issue 1998723002: Move code in ui/gl/* from gfx:: to gl:: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "gpu/ipc/service/pass_through_image_transport_surface.h" 5 #include "gpu/ipc/service/pass_through_image_transport_surface.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "gpu/ipc/common/gpu_messages.h" 11 #include "gpu/ipc/common/gpu_messages.h"
12 #include "gpu/ipc/service/gpu_command_buffer_stub.h" 12 #include "gpu/ipc/service/gpu_command_buffer_stub.h"
13 #include "ui/gfx/vsync_provider.h" 13 #include "ui/gfx/vsync_provider.h"
14 #include "ui/gl/gl_context.h" 14 #include "ui/gl/gl_context.h"
15 #include "ui/gl/gl_switches.h" 15 #include "ui/gl/gl_switches.h"
16 16
17 namespace gpu { 17 namespace gpu {
18 18
19 PassThroughImageTransportSurface::PassThroughImageTransportSurface( 19 PassThroughImageTransportSurface::PassThroughImageTransportSurface(
20 GpuChannelManager* /* manager */, 20 GpuChannelManager* /* manager */,
21 GpuCommandBufferStub* stub, 21 GpuCommandBufferStub* stub,
22 gfx::GLSurface* surface) 22 gl::GLSurface* surface)
23 : GLSurfaceAdapter(surface), 23 : GLSurfaceAdapter(surface),
24 stub_(stub->AsWeakPtr()), 24 stub_(stub->AsWeakPtr()),
25 did_set_swap_interval_(false), 25 did_set_swap_interval_(false),
26 weak_ptr_factory_(this) {} 26 weak_ptr_factory_(this) {}
27 27
28 bool PassThroughImageTransportSurface::Initialize( 28 bool PassThroughImageTransportSurface::Initialize(
29 gfx::GLSurface::Format format) { 29 gl::GLSurface::Format format) {
30 // The surface is assumed to have already been initialized. 30 // The surface is assumed to have already been initialized.
31 if (!stub_.get() || !stub_->decoder()) 31 if (!stub_.get() || !stub_->decoder())
32 return false; 32 return false;
33 stub_->SetLatencyInfoCallback( 33 stub_->SetLatencyInfoCallback(
34 base::Bind(&PassThroughImageTransportSurface::SetLatencyInfo, 34 base::Bind(&PassThroughImageTransportSurface::SetLatencyInfo,
35 base::Unretained(this))); 35 base::Unretained(this)));
36 return true; 36 return true;
37 } 37 }
38 38
39 void PassThroughImageTransportSurface::Destroy() { 39 void PassThroughImageTransportSurface::Destroy() {
40 GLSurfaceAdapter::Destroy(); 40 GLSurfaceAdapter::Destroy();
41 } 41 }
42 42
43 gfx::SwapResult PassThroughImageTransportSurface::SwapBuffers() { 43 gfx::SwapResult PassThroughImageTransportSurface::SwapBuffers() {
44 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info = 44 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info =
45 StartSwapBuffers(); 45 StartSwapBuffers();
46 gfx::SwapResult result = gfx::GLSurfaceAdapter::SwapBuffers(); 46 gfx::SwapResult result = gl::GLSurfaceAdapter::SwapBuffers();
47 FinishSwapBuffers(std::move(latency_info), result); 47 FinishSwapBuffers(std::move(latency_info), result);
48 return result; 48 return result;
49 } 49 }
50 50
51 void PassThroughImageTransportSurface::SwapBuffersAsync( 51 void PassThroughImageTransportSurface::SwapBuffersAsync(
52 const GLSurface::SwapCompletionCallback& callback) { 52 const GLSurface::SwapCompletionCallback& callback) {
53 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info = 53 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info =
54 StartSwapBuffers(); 54 StartSwapBuffers();
55 55
56 // We use WeakPtr here to avoid manual management of life time of an instance 56 // We use WeakPtr here to avoid manual management of life time of an instance
57 // of this class. Callback will not be called once the instance of this class 57 // of this class. Callback will not be called once the instance of this class
58 // is destroyed. However, this also means that the callback can be run on 58 // is destroyed. However, this also means that the callback can be run on
59 // the calling thread only. 59 // the calling thread only.
60 gfx::GLSurfaceAdapter::SwapBuffersAsync(base::Bind( 60 gl::GLSurfaceAdapter::SwapBuffersAsync(base::Bind(
61 &PassThroughImageTransportSurface::FinishSwapBuffersAsync, 61 &PassThroughImageTransportSurface::FinishSwapBuffersAsync,
62 weak_ptr_factory_.GetWeakPtr(), base::Passed(&latency_info), callback)); 62 weak_ptr_factory_.GetWeakPtr(), base::Passed(&latency_info), callback));
63 } 63 }
64 64
65 gfx::SwapResult PassThroughImageTransportSurface::PostSubBuffer(int x, 65 gfx::SwapResult PassThroughImageTransportSurface::PostSubBuffer(int x,
66 int y, 66 int y,
67 int width, 67 int width,
68 int height) { 68 int height) {
69 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info = 69 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info =
70 StartSwapBuffers(); 70 StartSwapBuffers();
71 gfx::SwapResult result = 71 gfx::SwapResult result =
72 gfx::GLSurfaceAdapter::PostSubBuffer(x, y, width, height); 72 gl::GLSurfaceAdapter::PostSubBuffer(x, y, width, height);
73 FinishSwapBuffers(std::move(latency_info), result); 73 FinishSwapBuffers(std::move(latency_info), result);
74 return result; 74 return result;
75 } 75 }
76 76
77 void PassThroughImageTransportSurface::PostSubBufferAsync( 77 void PassThroughImageTransportSurface::PostSubBufferAsync(
78 int x, 78 int x,
79 int y, 79 int y,
80 int width, 80 int width,
81 int height, 81 int height,
82 const GLSurface::SwapCompletionCallback& callback) { 82 const GLSurface::SwapCompletionCallback& callback) {
83 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info = 83 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info =
84 StartSwapBuffers(); 84 StartSwapBuffers();
85 gfx::GLSurfaceAdapter::PostSubBufferAsync( 85 gl::GLSurfaceAdapter::PostSubBufferAsync(
86 x, y, width, height, 86 x, y, width, height,
87 base::Bind(&PassThroughImageTransportSurface::FinishSwapBuffersAsync, 87 base::Bind(&PassThroughImageTransportSurface::FinishSwapBuffersAsync,
88 weak_ptr_factory_.GetWeakPtr(), base::Passed(&latency_info), 88 weak_ptr_factory_.GetWeakPtr(), base::Passed(&latency_info),
89 callback)); 89 callback));
90 } 90 }
91 91
92 gfx::SwapResult PassThroughImageTransportSurface::CommitOverlayPlanes() { 92 gfx::SwapResult PassThroughImageTransportSurface::CommitOverlayPlanes() {
93 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info = 93 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info =
94 StartSwapBuffers(); 94 StartSwapBuffers();
95 gfx::SwapResult result = gfx::GLSurfaceAdapter::CommitOverlayPlanes(); 95 gfx::SwapResult result = gl::GLSurfaceAdapter::CommitOverlayPlanes();
96 FinishSwapBuffers(std::move(latency_info), result); 96 FinishSwapBuffers(std::move(latency_info), result);
97 return result; 97 return result;
98 } 98 }
99 99
100 void PassThroughImageTransportSurface::CommitOverlayPlanesAsync( 100 void PassThroughImageTransportSurface::CommitOverlayPlanesAsync(
101 const GLSurface::SwapCompletionCallback& callback) { 101 const GLSurface::SwapCompletionCallback& callback) {
102 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info = 102 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info =
103 StartSwapBuffers(); 103 StartSwapBuffers();
104 gfx::GLSurfaceAdapter::CommitOverlayPlanesAsync(base::Bind( 104 gl::GLSurfaceAdapter::CommitOverlayPlanesAsync(base::Bind(
105 &PassThroughImageTransportSurface::FinishSwapBuffersAsync, 105 &PassThroughImageTransportSurface::FinishSwapBuffersAsync,
106 weak_ptr_factory_.GetWeakPtr(), base::Passed(&latency_info), callback)); 106 weak_ptr_factory_.GetWeakPtr(), base::Passed(&latency_info), callback));
107 } 107 }
108 108
109 bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { 109 bool PassThroughImageTransportSurface::OnMakeCurrent(gl::GLContext* context) {
110 if (!did_set_swap_interval_) { 110 if (!did_set_swap_interval_) {
111 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 111 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
112 switches::kDisableGpuVsync)) 112 switches::kDisableGpuVsync))
113 context->ForceSwapIntervalZero(true); 113 context->ForceSwapIntervalZero(true);
114 else 114 else
115 context->SetSwapInterval(1); 115 context->SetSwapInterval(1);
116 did_set_swap_interval_ = true; 116 did_set_swap_interval_ = true;
117 } 117 }
118 return true; 118 return true;
119 } 119 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 176
177 void PassThroughImageTransportSurface::FinishSwapBuffersAsync( 177 void PassThroughImageTransportSurface::FinishSwapBuffersAsync(
178 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info, 178 std::unique_ptr<std::vector<ui::LatencyInfo>> latency_info,
179 GLSurface::SwapCompletionCallback callback, 179 GLSurface::SwapCompletionCallback callback,
180 gfx::SwapResult result) { 180 gfx::SwapResult result) {
181 FinishSwapBuffers(std::move(latency_info), result); 181 FinishSwapBuffers(std::move(latency_info), result);
182 callback.Run(result); 182 callback.Run(result);
183 } 183 }
184 184
185 } // namespace gpu 185 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/ipc/service/pass_through_image_transport_surface.h ('k') | gpu/ipc/service/stream_texture_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698