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/drm/gpu/drm_surface.h" | 5 #include "ui/ozone/platform/drm/gpu/drm_surface.h" |
6 | 6 |
7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 63 } |
64 | 64 |
65 void DrmSurface::PresentCanvas(const gfx::Rect& damage) { | 65 void DrmSurface::PresentCanvas(const gfx::Rect& damage) { |
66 DCHECK(base::MessageLoopForUI::IsCurrent()); | 66 DCHECK(base::MessageLoopForUI::IsCurrent()); |
67 | 67 |
68 DCHECK(buffers_[front_buffer_ ^ 1].get()); | 68 DCHECK(buffers_[front_buffer_ ^ 1].get()); |
69 window_delegate_->QueueOverlayPlane( | 69 window_delegate_->QueueOverlayPlane( |
70 OverlayPlane(buffers_[front_buffer_ ^ 1])); | 70 OverlayPlane(buffers_[front_buffer_ ^ 1])); |
71 | 71 |
72 UpdateNativeSurface(damage); | 72 UpdateNativeSurface(damage); |
73 window_delegate_->SchedulePageFlip(false /* is_sync */, | 73 window_delegate_->SchedulePageFlip(true /* is_sync */, |
74 base::Bind(&base::DoNothing)); | 74 base::Bind(&base::DoNothing)); |
75 | 75 |
76 // Update our front buffer pointer. | 76 // Update our front buffer pointer. |
77 front_buffer_ ^= 1; | 77 front_buffer_ ^= 1; |
78 } | 78 } |
79 | 79 |
80 scoped_ptr<gfx::VSyncProvider> DrmSurface::CreateVSyncProvider() { | 80 scoped_ptr<gfx::VSyncProvider> DrmSurface::CreateVSyncProvider() { |
81 return make_scoped_ptr(new DrmVSyncProvider(window_delegate_)); | 81 return make_scoped_ptr(new DrmVSyncProvider(window_delegate_)); |
82 } | 82 } |
83 | 83 |
84 void DrmSurface::UpdateNativeSurface(const gfx::Rect& damage) { | 84 void DrmSurface::UpdateNativeSurface(const gfx::Rect& damage) { |
85 SkCanvas* canvas = buffers_[front_buffer_ ^ 1]->GetCanvas(); | 85 SkCanvas* canvas = buffers_[front_buffer_ ^ 1]->GetCanvas(); |
86 | 86 |
87 // The DrmSurface is double buffered, so the current back buffer is | 87 // The DrmSurface is double buffered, so the current back buffer is |
88 // missing the previous update. Expand damage region. | 88 // missing the previous update. Expand damage region. |
89 SkRect real_damage = RectToSkRect(UnionRects(damage, last_damage_)); | 89 SkRect real_damage = RectToSkRect(UnionRects(damage, last_damage_)); |
90 | 90 |
91 // Copy damage region. | 91 // Copy damage region. |
92 skia::RefPtr<SkImage> image = skia::AdoptRef(surface_->newImageSnapshot()); | 92 skia::RefPtr<SkImage> image = skia::AdoptRef(surface_->newImageSnapshot()); |
93 canvas->drawImageRect(image.get(), &real_damage, real_damage, NULL); | 93 canvas->drawImageRect(image.get(), &real_damage, real_damage, NULL); |
94 | 94 |
95 last_damage_ = damage; | 95 last_damage_ = damage; |
96 } | 96 } |
97 | 97 |
98 } // namespace ui | 98 } // namespace ui |
OLD | NEW |