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

Side by Side Diff: ui/ozone/platform/dri/dri_surface.cc

Issue 821023003: [Ozone-DRI] Listen for swap events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@async-swap
Patch Set: Added comment Created 5 years, 11 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
« no previous file with comments | « ui/ozone/platform/dri/crtc_controller.cc ('k') | ui/ozone/platform/dri/dri_surface_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/ozone/platform/dri/dri_surface.h" 5 #include "ui/ozone/platform/dri/dri_surface.h"
6 6
7 #include "base/bind_helpers.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
8 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
9 #include "third_party/skia/include/core/SkCanvas.h" 10 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "third_party/skia/include/core/SkSurface.h" 11 #include "third_party/skia/include/core/SkSurface.h"
11 #include "ui/gfx/geometry/rect.h" 12 #include "ui/gfx/geometry/rect.h"
12 #include "ui/gfx/skia_util.h" 13 #include "ui/gfx/skia_util.h"
13 #include "ui/ozone/platform/dri/dri_buffer.h" 14 #include "ui/ozone/platform/dri/dri_buffer.h"
14 #include "ui/ozone/platform/dri/dri_vsync_provider.h" 15 #include "ui/ozone/platform/dri/dri_vsync_provider.h"
15 #include "ui/ozone/platform/dri/dri_window_delegate_impl.h" 16 #include "ui/ozone/platform/dri/dri_window_delegate_impl.h"
16 #include "ui/ozone/platform/dri/dri_wrapper.h" 17 #include "ui/ozone/platform/dri/dri_wrapper.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 DCHECK(base::MessageLoopForUI::IsCurrent()); 67 DCHECK(base::MessageLoopForUI::IsCurrent());
67 DCHECK(buffers_[front_buffer_ ^ 1].get()); 68 DCHECK(buffers_[front_buffer_ ^ 1].get());
68 69
69 HardwareDisplayController* controller = window_delegate_->GetController(); 70 HardwareDisplayController* controller = window_delegate_->GetController();
70 if (!controller) 71 if (!controller)
71 return; 72 return;
72 73
73 controller->QueueOverlayPlane(OverlayPlane(buffers_[front_buffer_ ^ 1])); 74 controller->QueueOverlayPlane(OverlayPlane(buffers_[front_buffer_ ^ 1]));
74 75
75 UpdateNativeSurface(damage); 76 UpdateNativeSurface(damage);
76 controller->SchedulePageFlip(); 77 controller->SchedulePageFlip(base::Bind(&base::DoNothing));
77 controller->WaitForPageFlipEvent();
78 78
79 // Update our front buffer pointer. 79 // Update our front buffer pointer.
80 front_buffer_ ^= 1; 80 front_buffer_ ^= 1;
81 } 81 }
82 82
83 scoped_ptr<gfx::VSyncProvider> DriSurface::CreateVSyncProvider() { 83 scoped_ptr<gfx::VSyncProvider> DriSurface::CreateVSyncProvider() {
84 return scoped_ptr<gfx::VSyncProvider>(new DriVSyncProvider(window_delegate_)); 84 return scoped_ptr<gfx::VSyncProvider>(new DriVSyncProvider(window_delegate_));
85 } 85 }
86 86
87 void DriSurface::UpdateNativeSurface(const gfx::Rect& damage) { 87 void DriSurface::UpdateNativeSurface(const gfx::Rect& damage) {
88 SkCanvas* canvas = buffers_[front_buffer_ ^ 1]->GetCanvas(); 88 SkCanvas* canvas = buffers_[front_buffer_ ^ 1]->GetCanvas();
89 89
90 // The DriSurface is double buffered, so the current back buffer is 90 // The DriSurface is double buffered, so the current back buffer is
91 // missing the previous update. Expand damage region. 91 // missing the previous update. Expand damage region.
92 SkRect real_damage = RectToSkRect(UnionRects(damage, last_damage_)); 92 SkRect real_damage = RectToSkRect(UnionRects(damage, last_damage_));
93 93
94 // Copy damage region. 94 // Copy damage region.
95 skia::RefPtr<SkImage> image = skia::AdoptRef(surface_->newImageSnapshot()); 95 skia::RefPtr<SkImage> image = skia::AdoptRef(surface_->newImageSnapshot());
96 canvas->drawImageRect(image.get(), &real_damage, real_damage, NULL); 96 canvas->drawImageRect(image.get(), &real_damage, real_damage, NULL);
97 97
98 last_damage_ = damage; 98 last_damage_ = damage;
99 } 99 }
100 100
101 } // namespace ui 101 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/crtc_controller.cc ('k') | ui/ozone/platform/dri/dri_surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698