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" |
11 #include "third_party/skia/include/core/SkSurface.h" | 11 #include "third_party/skia/include/core/SkSurface.h" |
12 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
13 #include "ui/gfx/skia_util.h" | 13 #include "ui/gfx/skia_util.h" |
14 #include "ui/ozone/platform/drm/gpu/drm_buffer.h" | 14 #include "ui/ozone/platform/drm/gpu/drm_buffer.h" |
15 #include "ui/ozone/platform/drm/gpu/drm_device.h" | 15 #include "ui/ozone/platform/drm/gpu/drm_device.h" |
16 #include "ui/ozone/platform/drm/gpu/drm_vsync_provider.h" | 16 #include "ui/ozone/platform/drm/gpu/drm_vsync_provider.h" |
17 #include "ui/ozone/platform/drm/gpu/drm_window.h" | 17 #include "ui/ozone/platform/drm/gpu/drm_window.h" |
18 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" | 18 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" |
19 | 19 |
20 namespace ui { | 20 namespace ui { |
21 | 21 |
22 namespace { | 22 namespace { |
| 23 void EmptyPageFlipCallback(gfx::SwapResult result) { |
| 24 } |
23 | 25 |
24 scoped_refptr<DrmBuffer> AllocateBuffer(const scoped_refptr<DrmDevice>& drm, | 26 scoped_refptr<DrmBuffer> AllocateBuffer(const scoped_refptr<DrmDevice>& drm, |
25 const gfx::Size& size) { | 27 const gfx::Size& size) { |
26 scoped_refptr<DrmBuffer> buffer(new DrmBuffer(drm)); | 28 scoped_refptr<DrmBuffer> buffer(new DrmBuffer(drm)); |
27 SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height()); | 29 SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height()); |
28 | 30 |
29 bool initialized = | 31 bool initialized = |
30 buffer->Initialize(info, true /* should_register_framebuffer */); | 32 buffer->Initialize(info, true /* should_register_framebuffer */); |
31 DCHECK(initialized) << "Failed to create drm buffer."; | 33 DCHECK(initialized) << "Failed to create drm buffer."; |
32 | 34 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 66 |
65 void DrmSurface::PresentCanvas(const gfx::Rect& damage) { | 67 void DrmSurface::PresentCanvas(const gfx::Rect& damage) { |
66 DCHECK(base::MessageLoopForUI::IsCurrent()); | 68 DCHECK(base::MessageLoopForUI::IsCurrent()); |
67 | 69 |
68 DCHECK(buffers_[front_buffer_ ^ 1].get()); | 70 DCHECK(buffers_[front_buffer_ ^ 1].get()); |
69 window_delegate_->QueueOverlayPlane( | 71 window_delegate_->QueueOverlayPlane( |
70 OverlayPlane(buffers_[front_buffer_ ^ 1])); | 72 OverlayPlane(buffers_[front_buffer_ ^ 1])); |
71 | 73 |
72 UpdateNativeSurface(damage); | 74 UpdateNativeSurface(damage); |
73 window_delegate_->SchedulePageFlip(true /* is_sync */, | 75 window_delegate_->SchedulePageFlip(true /* is_sync */, |
74 base::Bind(&base::DoNothing)); | 76 base::Bind(&EmptyPageFlipCallback)); |
75 | 77 |
76 // Update our front buffer pointer. | 78 // Update our front buffer pointer. |
77 front_buffer_ ^= 1; | 79 front_buffer_ ^= 1; |
78 } | 80 } |
79 | 81 |
80 scoped_ptr<gfx::VSyncProvider> DrmSurface::CreateVSyncProvider() { | 82 scoped_ptr<gfx::VSyncProvider> DrmSurface::CreateVSyncProvider() { |
81 return make_scoped_ptr(new DrmVSyncProvider(window_delegate_)); | 83 return make_scoped_ptr(new DrmVSyncProvider(window_delegate_)); |
82 } | 84 } |
83 | 85 |
84 void DrmSurface::UpdateNativeSurface(const gfx::Rect& damage) { | 86 void DrmSurface::UpdateNativeSurface(const gfx::Rect& damage) { |
85 SkCanvas* canvas = buffers_[front_buffer_ ^ 1]->GetCanvas(); | 87 SkCanvas* canvas = buffers_[front_buffer_ ^ 1]->GetCanvas(); |
86 | 88 |
87 // The DrmSurface is double buffered, so the current back buffer is | 89 // The DrmSurface is double buffered, so the current back buffer is |
88 // missing the previous update. Expand damage region. | 90 // missing the previous update. Expand damage region. |
89 SkRect real_damage = RectToSkRect(UnionRects(damage, last_damage_)); | 91 SkRect real_damage = RectToSkRect(UnionRects(damage, last_damage_)); |
90 | 92 |
91 // Copy damage region. | 93 // Copy damage region. |
92 skia::RefPtr<SkImage> image = skia::AdoptRef(surface_->newImageSnapshot()); | 94 skia::RefPtr<SkImage> image = skia::AdoptRef(surface_->newImageSnapshot()); |
93 canvas->drawImageRect(image.get(), &real_damage, real_damage, NULL); | 95 canvas->drawImageRect(image.get(), &real_damage, real_damage, NULL); |
94 | 96 |
95 last_damage_ = damage; | 97 last_damage_ = damage; |
96 } | 98 } |
97 | 99 |
98 } // namespace ui | 100 } // namespace ui |
OLD | NEW |