| 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/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/dri/dri_buffer.h" | 14 #include "ui/ozone/platform/dri/dri_buffer.h" |
| 15 #include "ui/ozone/platform/dri/dri_vsync_provider.h" | 15 #include "ui/ozone/platform/dri/dri_vsync_provider.h" |
| 16 #include "ui/ozone/platform/dri/dri_window_delegate_impl.h" | 16 #include "ui/ozone/platform/dri/dri_window_delegate_impl.h" |
| 17 #include "ui/ozone/platform/dri/dri_wrapper.h" | 17 #include "ui/ozone/platform/dri/drm_device.h" |
| 18 #include "ui/ozone/platform/dri/hardware_display_controller.h" | 18 #include "ui/ozone/platform/dri/hardware_display_controller.h" |
| 19 | 19 |
| 20 namespace ui { | 20 namespace ui { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 scoped_refptr<DriBuffer> AllocateBuffer(const scoped_refptr<DriWrapper>& dri, | 24 scoped_refptr<DriBuffer> AllocateBuffer(const scoped_refptr<DrmDevice>& drm, |
| 25 const gfx::Size& size) { | 25 const gfx::Size& size) { |
| 26 scoped_refptr<DriBuffer> buffer(new DriBuffer(dri)); | 26 scoped_refptr<DriBuffer> buffer(new DriBuffer(drm)); |
| 27 SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height()); | 27 SkImageInfo info = SkImageInfo::MakeN32Premul(size.width(), size.height()); |
| 28 | 28 |
| 29 bool initialized = | 29 bool initialized = |
| 30 buffer->Initialize(info, true /* should_register_framebuffer */); | 30 buffer->Initialize(info, true /* should_register_framebuffer */); |
| 31 DCHECK(initialized) << "Failed to create drm buffer."; | 31 DCHECK(initialized) << "Failed to create drm buffer."; |
| 32 | 32 |
| 33 return buffer; | 33 return buffer; |
| 34 } | 34 } |
| 35 | 35 |
| 36 } // namespace | 36 } // namespace |
| (...skipping 14 matching lines...) Expand all Loading... |
| 51 viewport_size.width(), viewport_size.height(), kOpaque_SkAlphaType); | 51 viewport_size.width(), viewport_size.height(), kOpaque_SkAlphaType); |
| 52 surface_ = skia::AdoptRef(SkSurface::NewRaster(info)); | 52 surface_ = skia::AdoptRef(SkSurface::NewRaster(info)); |
| 53 | 53 |
| 54 HardwareDisplayController* controller = window_delegate_->GetController(); | 54 HardwareDisplayController* controller = window_delegate_->GetController(); |
| 55 if (!controller) | 55 if (!controller) |
| 56 return; | 56 return; |
| 57 | 57 |
| 58 // For the display buffers use the mode size since a |viewport_size| smaller | 58 // For the display buffers use the mode size since a |viewport_size| smaller |
| 59 // than the display size will not scanout. | 59 // than the display size will not scanout. |
| 60 for (size_t i = 0; i < arraysize(buffers_); ++i) | 60 for (size_t i = 0; i < arraysize(buffers_); ++i) |
| 61 buffers_[i] = AllocateBuffer(controller->GetAllocationDriWrapper(), | 61 buffers_[i] = AllocateBuffer(controller->GetAllocationDrmDevice(), |
| 62 controller->GetModeSize()); | 62 controller->GetModeSize()); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void DriSurface::PresentCanvas(const gfx::Rect& damage) { | 65 void DriSurface::PresentCanvas(const gfx::Rect& damage) { |
| 66 DCHECK(base::MessageLoopForUI::IsCurrent()); | 66 DCHECK(base::MessageLoopForUI::IsCurrent()); |
| 67 | 67 |
| 68 HardwareDisplayController* controller = window_delegate_->GetController(); | 68 HardwareDisplayController* controller = window_delegate_->GetController(); |
| 69 if (!controller) | 69 if (!controller) |
| 70 return; | 70 return; |
| 71 | 71 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 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 |
| OLD | NEW |