| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 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 #ifndef BLIMP_ENGINE_BROWSER_TESTS_BLIMP_CONTENTS_VIEW_READBACK_HELPER_H_ | |
| 6 #define BLIMP_ENGINE_BROWSER_TESTS_BLIMP_CONTENTS_VIEW_READBACK_HELPER_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/memory/weak_ptr.h" | |
| 10 #include "base/synchronization/waitable_event.h" | |
| 11 #include "blimp/client/public/contents/blimp_contents_view.h" | |
| 12 | |
| 13 namespace blimp { | |
| 14 | |
| 15 // A helper class to make grabbing a bitmap from a BlimpContentsView easier. | |
| 16 // This can be used in conjunction with a WaitableContentPump to pause test | |
| 17 // execution while waiting for the readback to finish. An example use would be: | |
| 18 // | |
| 19 // WaitableContentPump pump; | |
| 20 // BlimpContentsViewReadbackHelper helper; | |
| 21 // blimp_contents->GetView()->CopyCompositingSurface( | |
| 22 // helper.GetCallback(), true); | |
| 23 // pump.WaitFor(helper.event()); | |
| 24 // helper.bitmap(); | |
| 25 | |
| 26 class BlimpContentsViewReadbackHelper { | |
| 27 public: | |
| 28 BlimpContentsViewReadbackHelper(); | |
| 29 virtual ~BlimpContentsViewReadbackHelper(); | |
| 30 | |
| 31 client::BlimpContentsView::ReadbackRequestCallback GetCallback(); | |
| 32 SkBitmap* GetBitmap() const; | |
| 33 | |
| 34 base::WaitableEvent* event() { return &event_; } | |
| 35 | |
| 36 private: | |
| 37 void OnReadbackComplete(std::unique_ptr<SkBitmap> bitmap); | |
| 38 | |
| 39 base::WaitableEvent event_; | |
| 40 std::unique_ptr<SkBitmap> bitmap_; | |
| 41 | |
| 42 base::WeakPtrFactory<BlimpContentsViewReadbackHelper> weak_ptr_factory_; | |
| 43 | |
| 44 DISALLOW_COPY_AND_ASSIGN(BlimpContentsViewReadbackHelper); | |
| 45 }; | |
| 46 | |
| 47 } // namespace blimp | |
| 48 | |
| 49 #endif // BLIMP_ENGINE_BROWSER_TESTS_BLIMP_CONTENTS_VIEW_READBACK_HELPER_H_ | |
| OLD | NEW |