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 CC_TEST_FAKE_PICTURE_CACHE_H_ |
| 6 #define CC_TEST_FAKE_PICTURE_CACHE_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <memory> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" |
| 13 #include "cc/proto/picture_cache.h" |
| 14 |
| 15 namespace cc { |
| 16 |
| 17 // FakePictureCacheModel provides a way for sharing a cache between an engine |
| 18 // and the client. When the FakeEnginePictureCache and the ClientPictureCache |
| 19 // point to the same FakePictureCacheModel, the calls to AddPicture on the |
| 20 // engine make an SkPicture available through GetPicture on the client. |
| 21 class FakePictureCacheModel { |
| 22 public: |
| 23 FakePictureCacheModel(); |
| 24 ~FakePictureCacheModel(); |
| 25 |
| 26 void AddPicture(const SkPicture* picture); |
| 27 |
| 28 sk_sp<const SkPicture> GetPicture(uint32_t unique_id); |
| 29 |
| 30 private: |
| 31 std::map<uint32_t, sk_sp<const SkPicture>> pictures_; |
| 32 }; |
| 33 |
| 34 class FakeEnginePictureCache : public EnginePictureCache { |
| 35 public: |
| 36 explicit FakeEnginePictureCache(FakePictureCacheModel* model); |
| 37 ~FakeEnginePictureCache() override; |
| 38 |
| 39 // EnginePictureCache implementation. |
| 40 PictureCacheUpdate CalculateCacheUpdateAndFlush() override; |
| 41 void MarkPictureForUnregistration(const SkPicture* picture) override; |
| 42 void MarkPictureForRegistration(const SkPicture* picture) override; |
| 43 |
| 44 private: |
| 45 FakePictureCacheModel* model_; |
| 46 }; |
| 47 |
| 48 class FakeClientPictureCache : public ClientPictureCache { |
| 49 public: |
| 50 explicit FakeClientPictureCache(FakePictureCacheModel* model); |
| 51 ~FakeClientPictureCache() override; |
| 52 |
| 53 // ClientPictureCache implementation. |
| 54 sk_sp<const SkPicture> GetPicture(uint32_t unique_id) override; |
| 55 void ApplyCacheUpdate(const PictureCacheUpdate& cache_update) override; |
| 56 void Flush() override; |
| 57 void MarkPictureForUnregistration(uint32_t engine_picture_id) override; |
| 58 void MarkPictureForRegistration(uint32_t engine_picture_id) override; |
| 59 |
| 60 private: |
| 61 FakePictureCacheModel* model_; |
| 62 }; |
| 63 |
| 64 } // namespace cc |
| 65 |
| 66 #endif // CC_TEST_FAKE_PICTURE_CACHE_H_ |
OLD | NEW |