| 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/macros.h" | 10 #include "base/macros.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 void PresentCanvas(const gfx::Rect& damage) override { | 48 void PresentCanvas(const gfx::Rect& damage) override { |
| 49 if (location_.empty()) | 49 if (location_.empty()) |
| 50 return; | 50 return; |
| 51 SkBitmap bitmap; | 51 SkBitmap bitmap; |
| 52 bitmap.allocPixels(surface_->getCanvas()->imageInfo()); | 52 bitmap.allocPixels(surface_->getCanvas()->imageInfo()); |
| 53 | 53 |
| 54 // TODO(dnicoara) Use SkImage instead to potentially avoid a copy. | 54 // TODO(dnicoara) Use SkImage instead to potentially avoid a copy. |
| 55 // See crbug.com/361605 for details. | 55 // See crbug.com/361605 for details. |
| 56 if (surface_->getCanvas()->readPixels(bitmap, 0, 0)) { | 56 if (surface_->getCanvas()->readPixels(bitmap, 0, 0)) { |
| 57 base::PostTaskWithTraits( | 57 base::PostTaskWithTraits( |
| 58 FROM_HERE, base::TaskTraits() | 58 FROM_HERE, |
| 59 .WithShutdownBehavior( | 59 {base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, |
| 60 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) | |
| 61 .MayBlock(), | |
| 62 base::Bind(&WriteDataToFile, location_, bitmap)); | 60 base::Bind(&WriteDataToFile, location_, bitmap)); |
| 63 } | 61 } |
| 64 } | 62 } |
| 65 std::unique_ptr<gfx::VSyncProvider> CreateVSyncProvider() override { | 63 std::unique_ptr<gfx::VSyncProvider> CreateVSyncProvider() override { |
| 66 return nullptr; | 64 return nullptr; |
| 67 } | 65 } |
| 68 | 66 |
| 69 private: | 67 private: |
| 70 base::FilePath location_; | 68 base::FilePath location_; |
| 71 sk_sp<SkSurface> surface_; | 69 sk_sp<SkSurface> surface_; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 138 |
| 141 scoped_refptr<gfx::NativePixmap> HeadlessSurfaceFactory::CreateNativePixmap( | 139 scoped_refptr<gfx::NativePixmap> HeadlessSurfaceFactory::CreateNativePixmap( |
| 142 gfx::AcceleratedWidget widget, | 140 gfx::AcceleratedWidget widget, |
| 143 gfx::Size size, | 141 gfx::Size size, |
| 144 gfx::BufferFormat format, | 142 gfx::BufferFormat format, |
| 145 gfx::BufferUsage usage) { | 143 gfx::BufferUsage usage) { |
| 146 return new TestPixmap(format); | 144 return new TestPixmap(format); |
| 147 } | 145 } |
| 148 | 146 |
| 149 } // namespace ui | 147 } // namespace ui |
| OLD | NEW |