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

Unified Diff: ash/laser/laser_pointer_view.cc

Issue 2765393004: ash: Map/unmap GMB for each laser pointer update. (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/laser/laser_pointer_view.cc
diff --git a/ash/laser/laser_pointer_view.cc b/ash/laser/laser_pointer_view.cc
index d567506ef0ace5cd4a0bf9c863dea651d0e14a59..c634cc5611ce291f5a8fc0abb9fbd8abccf8182e 100644
--- a/ash/laser/laser_pointer_view.cc
+++ b/ash/laser/laser_pointer_view.cc
@@ -243,11 +243,7 @@ LaserPointerView::LaserPointerView(base::TimeDelta life_duration,
.device_scale_factor();
}
-LaserPointerView::~LaserPointerView() {
- // Make sure GPU memory buffer is unmapped before being destroyed.
- if (gpu_memory_buffer_)
- gpu_memory_buffer_->Unmap();
-}
+LaserPointerView::~LaserPointerView() {}
void LaserPointerView::Stop() {
buffer_damage_rect_.Union(GetBoundingBox());
@@ -470,13 +466,6 @@ void LaserPointerView::UpdateBuffer() {
return;
}
- // Map buffer and keep it mapped until destroyed.
- bool rv = gpu_memory_buffer_->Map();
- if (!rv) {
- LOG(ERROR) << "Failed to map GPU memory buffer";
- return;
- }
-
// Make sure the first update rectangle covers the whole buffer.
update_rect = gfx::Rect(screen_bounds.size());
}
@@ -486,6 +475,12 @@ void LaserPointerView::UpdateBuffer() {
if (update_rect.IsEmpty())
return;
+ // Map buffer for writing.
+ if (!gpu_memory_buffer_->Map()) {
+ LOG(ERROR) << "Failed to map GPU memory buffer";
+ return;
+ }
+
// Create a temporary canvas for update rectangle.
gfx::Canvas canvas(update_rect.size(), scale_factor_, false);
@@ -572,6 +567,9 @@ void LaserPointerView::UpdateBuffer() {
data + pixel_rect.y() * stride + pixel_rect.x() * 4, stride, 0, 0);
}
+ // Unmap to flush writes to buffer.
+ gpu_memory_buffer_->Unmap();
+
// Update surface damage rectangle.
surface_damage_rect_.Union(update_rect);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698