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

Unified Diff: content/common/gpu/image_transport_surface.cc

Issue 797843005: Add support to delay sending SwapbufferAck as needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use WeakptrFactory Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/gpu/image_transport_surface.h ('k') | ui/gl/gl_surface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/image_transport_surface.cc
diff --git a/content/common/gpu/image_transport_surface.cc b/content/common/gpu/image_transport_surface.cc
index f4c5a68cb218b02b354c2612ec7f3b18b4e89b63..f7000f626a86456e3a1dfc35dc2055cf28728fa8 100644
--- a/content/common/gpu/image_transport_surface.cc
+++ b/content/common/gpu/image_transport_surface.cc
@@ -187,7 +187,8 @@ PassThroughImageTransportSurface::PassThroughImageTransportSurface(
GpuCommandBufferStub* stub,
gfx::GLSurface* surface)
: GLSurfaceAdapter(surface),
- did_set_swap_interval_(false) {
+ did_set_swap_interval_(false),
+ weak_ptr_factory_(this) {
helper_.reset(new ImageTransportHelper(this,
manager,
stub,
@@ -213,21 +214,28 @@ bool PassThroughImageTransportSurface::SwapBuffers() {
// GetVsyncValues before SwapBuffers to work around Mali driver bug:
// crbug.com/223558.
SendVSyncUpdateIfAvailable();
- bool result = gfx::GLSurfaceAdapter::SwapBuffers();
- for (size_t i = 0; i < latency_info_.size(); i++) {
- latency_info_[i].AddLatencyNumber(
- ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0);
- }
-
- helper_->SwapBuffersCompleted(latency_info_);
- latency_info_.clear();
- return result;
+ // We use WeakPtr here to avoid manual management of life time of an instance
+ // of this class. Callback will not be called once the instance of this class
+ // is destroyed. However, this also means that the callback can be run on
+ // the calling thread only.
+ return gfx::GLSurfaceAdapter::SwapBuffersAsync(
+ base::Bind(&PassThroughImageTransportSurface::SwapBuffersCallBack,
+ weak_ptr_factory_.GetWeakPtr()));
}
bool PassThroughImageTransportSurface::PostSubBuffer(
int x, int y, int width, int height) {
SendVSyncUpdateIfAvailable();
- bool result = gfx::GLSurfaceAdapter::PostSubBuffer(x, y, width, height);
+ // We use WeakPtr here to avoid manual management of life time of an instance
+ // of this class. Callback will not be called once the instance of this class
+ // is destroyed. However, this also means that the callback can be run on
+ // the calling thread only.
+ return gfx::GLSurfaceAdapter::PostSubBufferAsync(x, y, width, height,
+ base::Bind(&PassThroughImageTransportSurface::SwapBuffersCallBack,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void PassThroughImageTransportSurface::SwapBuffersCallBack() {
for (size_t i = 0; i < latency_info_.size(); i++) {
latency_info_[i].AddLatencyNumber(
ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0);
@@ -235,7 +243,6 @@ bool PassThroughImageTransportSurface::PostSubBuffer(
helper_->SwapBuffersCompleted(latency_info_);
latency_info_.clear();
- return result;
}
bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) {
« no previous file with comments | « content/common/gpu/image_transport_surface.h ('k') | ui/gl/gl_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698