OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/snapshot/snapshot.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/callback.h" |
| 9 #include "base/task_runner_util.h" |
| 10 #include "ui/gfx/image/image.h" |
| 11 |
| 12 namespace ui { |
| 13 |
| 14 namespace { |
| 15 |
| 16 scoped_refptr<base::RefCountedMemory> EncodeImage(const gfx::Image& image) { |
| 17 return image.As1xPNGBytes(); |
| 18 } |
| 19 |
| 20 void EncodeImageAndSchedulePNGCallback( |
| 21 scoped_refptr<base::TaskRunner> background_task_runner, |
| 22 const GrabWindowSnapshotAsyncPNGCallback& callback, |
| 23 const gfx::Image& image) { |
| 24 base::PostTaskAndReplyWithResult(background_task_runner.get(), FROM_HERE, |
| 25 base::Bind(EncodeImage, image), callback); |
| 26 } |
| 27 |
| 28 } // namespace |
| 29 |
| 30 void GrabWindowSnapshotAsyncPNG( |
| 31 gfx::NativeWindow window, |
| 32 const gfx::Rect& source_rect, |
| 33 scoped_refptr<base::TaskRunner> background_task_runner, |
| 34 const GrabWindowSnapshotAsyncPNGCallback& callback) { |
| 35 GrabWindowSnapshotAsync( |
| 36 window, source_rect, |
| 37 base::Bind(EncodeImageAndSchedulePNGCallback, |
| 38 std::move(background_task_runner), callback)); |
| 39 } |
| 40 |
| 41 } // namespace ui |
OLD | NEW |