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

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: Add SwapBufferCallBack in Helper. 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
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..6d7f4a420928169eba9cd1770dadd4d74df706ce 100644
--- a/content/common/gpu/image_transport_surface.cc
+++ b/content/common/gpu/image_transport_surface.cc
@@ -119,9 +119,14 @@ void ImageTransportHelper::SendUpdateVSyncParameters(
interval));
}
-void ImageTransportHelper::SwapBuffersCompleted(
- const std::vector<ui::LatencyInfo>& latency_info) {
- stub_->SwapBuffersCompleted(latency_info);
+void ImageTransportHelper::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);
+ }
+
+ stub_->SwapBuffersCompleted(latency_info_);
+ latency_info_.clear();
}
void ImageTransportHelper::SetPreemptByFlag(
@@ -179,7 +184,8 @@ void ImageTransportHelper::Resize(gfx::Size size, float scale_factor) {
void ImageTransportHelper::SetLatencyInfo(
const std::vector<ui::LatencyInfo>& latency_info) {
- surface_->SetLatencyInfo(latency_info);
piman 2014/12/22 20:53:15 Why this change? I don't understand... It will bre
kalyank 2014/12/23 09:12:32 ImageTransportSurfaceAndroid inherits base::Suppor
kalyank 2014/12/23 11:22:42 Added ImageTransportHelperAndroid, which will be u
+ for (size_t i = 0; i < latency_info.size(); i++)
+ latency_info_.push_back(latency_info[i]);
}
PassThroughImageTransportSurface::PassThroughImageTransportSurface(
@@ -205,37 +211,32 @@ void PassThroughImageTransportSurface::Destroy() {
void PassThroughImageTransportSurface::SetLatencyInfo(
const std::vector<ui::LatencyInfo>& latency_info) {
- for (size_t i = 0; i < latency_info.size(); i++)
- latency_info_.push_back(latency_info[i]);
+ helper_->SetLatencyInfo(latency_info);
}
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
+ // GPUMainThread only.
+ return gfx::GLSurfaceAdapter::SwapBuffersAsync(
+ base::Bind(&ImageTransportHelper::SwapBuffersCallBack,
+ helper_->AsWeakPtr()));
}
bool PassThroughImageTransportSurface::PostSubBuffer(
int x, int y, int width, int height) {
SendVSyncUpdateIfAvailable();
- bool result = gfx::GLSurfaceAdapter::PostSubBuffer(x, y, width, height);
- 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
+ // GPUMainThread only.
+ return gfx::GLSurfaceAdapter::PostSubBufferAsync(x, y, width, height,
+ base::Bind(&ImageTransportHelper::SwapBuffersCallBack,
+ helper_->AsWeakPtr()));
}
bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) {

Powered by Google App Engine
This is Rietveld 408576698