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 "content/browser/compositor/software_output_device_ozone.h" | 5 #include "content/browser/compositor/software_output_device_ozone.h" |
6 #include "ui/compositor/compositor.h" | 6 #include "ui/compositor/compositor.h" |
7 #include "ui/gfx/skia_util.h" | 7 #include "ui/gfx/skia_util.h" |
8 #include "ui/gfx/vsync_provider.h" | 8 #include "ui/gfx/vsync_provider.h" |
9 #include "ui/ozone/public/ozone_platform.h" | 9 #include "ui/ozone/public/ozone_platform.h" |
10 #include "ui/ozone/public/surface_factory_ozone.h" | 10 #include "ui/ozone/public/surface_factory_ozone.h" |
11 #include "ui/ozone/public/surface_ozone_canvas.h" | 11 #include "ui/ozone/public/surface_ozone_canvas.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
| 15 // static |
| 16 scoped_ptr<SoftwareOutputDeviceOzone> SoftwareOutputDeviceOzone::Create( |
| 17 ui::Compositor* compositor) { |
| 18 scoped_ptr<SoftwareOutputDeviceOzone> result( |
| 19 new SoftwareOutputDeviceOzone(compositor)); |
| 20 if (!result->surface_ozone_) |
| 21 return nullptr; |
| 22 return result; |
| 23 } |
| 24 |
15 SoftwareOutputDeviceOzone::SoftwareOutputDeviceOzone(ui::Compositor* compositor) | 25 SoftwareOutputDeviceOzone::SoftwareOutputDeviceOzone(ui::Compositor* compositor) |
16 : compositor_(compositor) { | 26 : compositor_(compositor) { |
17 ui::SurfaceFactoryOzone* factory = | 27 ui::SurfaceFactoryOzone* factory = |
18 ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone(); | 28 ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone(); |
19 | 29 |
20 surface_ozone_ = factory->CreateCanvasForWidget(compositor_->widget()); | 30 surface_ozone_ = factory->CreateCanvasForWidget(compositor_->widget()); |
21 | 31 |
22 if (!surface_ozone_) | 32 if (!surface_ozone_) { |
23 LOG(FATAL) << "Failed to initialize canvas"; | 33 LOG(ERROR) << "Failed to initialize canvas"; |
| 34 return; |
| 35 } |
24 | 36 |
25 vsync_provider_ = surface_ozone_->CreateVSyncProvider(); | 37 vsync_provider_ = surface_ozone_->CreateVSyncProvider(); |
26 } | 38 } |
27 | 39 |
28 SoftwareOutputDeviceOzone::~SoftwareOutputDeviceOzone() { | 40 SoftwareOutputDeviceOzone::~SoftwareOutputDeviceOzone() { |
29 } | 41 } |
30 | 42 |
31 void SoftwareOutputDeviceOzone::Resize(const gfx::Size& viewport_pixel_size, | 43 void SoftwareOutputDeviceOzone::Resize(const gfx::Size& viewport_pixel_size, |
32 float scale_factor) { | 44 float scale_factor) { |
33 scale_factor_ = scale_factor; | 45 scale_factor_ = scale_factor; |
(...skipping 15 matching lines...) Expand all Loading... |
49 return SoftwareOutputDevice::BeginPaint(damage_rect); | 61 return SoftwareOutputDevice::BeginPaint(damage_rect); |
50 } | 62 } |
51 | 63 |
52 void SoftwareOutputDeviceOzone::EndPaint() { | 64 void SoftwareOutputDeviceOzone::EndPaint() { |
53 SoftwareOutputDevice::EndPaint(); | 65 SoftwareOutputDevice::EndPaint(); |
54 | 66 |
55 surface_ozone_->PresentCanvas(damage_rect_); | 67 surface_ozone_->PresentCanvas(damage_rect_); |
56 } | 68 } |
57 | 69 |
58 } // namespace content | 70 } // namespace content |
OLD | NEW |