OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/headless/headless_surface_factory.h" | 5 #include "ui/ozone/platform/headless/headless_surface_factory.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/stl_util.h" | |
11 #include "base/threading/worker_pool.h" | 10 #include "base/threading/worker_pool.h" |
12 #include "third_party/skia/include/core/SkCanvas.h" | 11 #include "third_party/skia/include/core/SkCanvas.h" |
13 #include "third_party/skia/include/core/SkSurface.h" | 12 #include "third_party/skia/include/core/SkSurface.h" |
14 #include "ui/gfx/codec/png_codec.h" | 13 #include "ui/gfx/codec/png_codec.h" |
15 #include "ui/gfx/skia_util.h" | 14 #include "ui/gfx/skia_util.h" |
16 #include "ui/gfx/vsync_provider.h" | 15 #include "ui/gfx/vsync_provider.h" |
17 #include "ui/ozone/platform/headless/headless_window.h" | 16 #include "ui/ozone/platform/headless/headless_window.h" |
18 #include "ui/ozone/platform/headless/headless_window_manager.h" | 17 #include "ui/ozone/platform/headless/headless_window_manager.h" |
19 #include "ui/ozone/public/native_pixmap.h" | 18 #include "ui/ozone/public/native_pixmap.h" |
20 #include "ui/ozone/public/surface_ozone_canvas.h" | 19 #include "ui/ozone/public/surface_ozone_canvas.h" |
21 | 20 |
22 namespace ui { | 21 namespace ui { |
23 | 22 |
24 namespace { | 23 namespace { |
25 | 24 |
26 void WriteDataToFile(const base::FilePath& location, const SkBitmap& bitmap) { | 25 void WriteDataToFile(const base::FilePath& location, const SkBitmap& bitmap) { |
27 DCHECK(!location.empty()); | 26 DCHECK(!location.empty()); |
28 std::vector<unsigned char> png_data; | 27 std::vector<unsigned char> png_data; |
29 gfx::PNGCodec::FastEncodeBGRASkBitmap(bitmap, true, &png_data); | 28 gfx::PNGCodec::FastEncodeBGRASkBitmap(bitmap, true, &png_data); |
30 base::WriteFile(location, | 29 base::WriteFile(location, reinterpret_cast<const char*>(png_data.data()), |
31 reinterpret_cast<const char*>(vector_as_array(&png_data)), | |
32 png_data.size()); | 30 png_data.size()); |
33 } | 31 } |
34 | 32 |
35 // TODO(altimin): Find a proper way to capture rendering output. | 33 // TODO(altimin): Find a proper way to capture rendering output. |
36 class FileSurface : public SurfaceOzoneCanvas { | 34 class FileSurface : public SurfaceOzoneCanvas { |
37 public: | 35 public: |
38 FileSurface(const base::FilePath& location) : location_(location) {} | 36 FileSurface(const base::FilePath& location) : location_(location) {} |
39 ~FileSurface() override {} | 37 ~FileSurface() override {} |
40 | 38 |
41 // SurfaceOzoneCanvas overrides: | 39 // SurfaceOzoneCanvas overrides: |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 123 |
126 scoped_refptr<NativePixmap> HeadlessSurfaceFactory::CreateNativePixmap( | 124 scoped_refptr<NativePixmap> HeadlessSurfaceFactory::CreateNativePixmap( |
127 gfx::AcceleratedWidget widget, | 125 gfx::AcceleratedWidget widget, |
128 gfx::Size size, | 126 gfx::Size size, |
129 gfx::BufferFormat format, | 127 gfx::BufferFormat format, |
130 gfx::BufferUsage usage) { | 128 gfx::BufferUsage usage) { |
131 return new TestPixmap(format); | 129 return new TestPixmap(format); |
132 } | 130 } |
133 | 131 |
134 } // namespace ui | 132 } // namespace ui |
OLD | NEW |