OLD | NEW |
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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "third_party/skia/include/core/SkCanvas.h" | 9 #include "third_party/skia/include/core/SkCanvas.h" |
10 #include "third_party/skia/include/core/SkSurface.h" | 10 #include "third_party/skia/include/core/SkSurface.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 buffers_[i] = AllocateBuffer(dri_, mode_size); | 64 buffers_[i] = AllocateBuffer(dri_, mode_size); |
65 } | 65 } |
66 | 66 |
67 void DriSurface::PresentCanvas(const gfx::Rect& damage) { | 67 void DriSurface::PresentCanvas(const gfx::Rect& damage) { |
68 DCHECK(base::MessageLoopForUI::IsCurrent()); | 68 DCHECK(base::MessageLoopForUI::IsCurrent()); |
69 DCHECK(buffers_[front_buffer_ ^ 1]); | 69 DCHECK(buffers_[front_buffer_ ^ 1]); |
70 | 70 |
71 if (!controller_) | 71 if (!controller_) |
72 return; | 72 return; |
73 | 73 |
74 controller_->QueueOverlayPlane(OverlayPlane(buffers_[front_buffer_ ^ 1])); | 74 std::vector<OverlayPlane> planes( |
| 75 1, OverlayPlane(buffers_[front_buffer_ ^ 1])); |
75 | 76 |
76 UpdateNativeSurface(damage); | 77 UpdateNativeSurface(damage); |
77 controller_->SchedulePageFlip(); | 78 controller_->SchedulePageFlip(planes); |
78 controller_->WaitForPageFlipEvent(); | 79 controller_->WaitForPageFlipEvent(); |
79 | 80 |
80 // Update our front buffer pointer. | 81 // Update our front buffer pointer. |
81 front_buffer_ ^= 1; | 82 front_buffer_ ^= 1; |
82 } | 83 } |
83 | 84 |
84 scoped_ptr<gfx::VSyncProvider> DriSurface::CreateVSyncProvider() { | 85 scoped_ptr<gfx::VSyncProvider> DriSurface::CreateVSyncProvider() { |
85 return scoped_ptr<gfx::VSyncProvider>(new DriVSyncProvider(controller_)); | 86 return scoped_ptr<gfx::VSyncProvider>(new DriVSyncProvider(controller_)); |
86 } | 87 } |
87 | 88 |
88 void DriSurface::UpdateNativeSurface(const gfx::Rect& damage) { | 89 void DriSurface::UpdateNativeSurface(const gfx::Rect& damage) { |
89 SkCanvas* canvas = buffers_[front_buffer_ ^ 1]->GetCanvas(); | 90 SkCanvas* canvas = buffers_[front_buffer_ ^ 1]->GetCanvas(); |
90 | 91 |
91 // The DriSurface is double buffered, so the current back buffer is | 92 // The DriSurface is double buffered, so the current back buffer is |
92 // missing the previous update. Expand damage region. | 93 // missing the previous update. Expand damage region. |
93 SkRect real_damage = RectToSkRect(UnionRects(damage, last_damage_)); | 94 SkRect real_damage = RectToSkRect(UnionRects(damage, last_damage_)); |
94 | 95 |
95 // Copy damage region. | 96 // Copy damage region. |
96 skia::RefPtr<SkImage> image = skia::AdoptRef(surface_->newImageSnapshot()); | 97 skia::RefPtr<SkImage> image = skia::AdoptRef(surface_->newImageSnapshot()); |
97 image->draw(canvas, &real_damage, real_damage, NULL); | 98 image->draw(canvas, &real_damage, real_damage, NULL); |
98 | 99 |
99 last_damage_ = damage; | 100 last_damage_ = damage; |
100 } | 101 } |
101 | 102 |
102 } // namespace ui | 103 } // namespace ui |
OLD | NEW |