Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2322)

Unified Diff: cc/test/fake_picture_cache.h

Issue 1982893002: [blimp] Add SkPicture caching support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git merge origin/master Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/test/fake_picture_cache.h
diff --git a/cc/test/fake_picture_cache.h b/cc/test/fake_picture_cache.h
new file mode 100644
index 0000000000000000000000000000000000000000..bf9771012895141d750de1d4210209d880f10f7a
--- /dev/null
+++ b/cc/test/fake_picture_cache.h
@@ -0,0 +1,66 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_TEST_FAKE_PICTURE_CACHE_H_
+#define CC_TEST_FAKE_PICTURE_CACHE_H_
+
+#include <map>
+#include <memory>
+
+#include "base/macros.h"
+#include "base/memory/ptr_util.h"
+#include "cc/proto/picture_cache.h"
+
+namespace cc {
+
+// FakePictureCacheModel provides a way for sharing a cache between an engine
+// and the client. When the FakeEnginePictureCache and the ClientPictureCache
+// point to the same FakePictureCacheModel, the calls to AddPicture on the
+// engine make an SkPicture available through GetPicture on the client.
+class FakePictureCacheModel {
+ public:
+ FakePictureCacheModel();
+ ~FakePictureCacheModel();
+
+ void AddPicture(const SkPicture* picture);
+
+ sk_sp<const SkPicture> GetPicture(uint32_t unique_id);
+
+ private:
+ std::map<uint32_t, sk_sp<const SkPicture>> pictures_;
+};
+
+class FakeEnginePictureCache : public EnginePictureCache {
+ public:
+ explicit FakeEnginePictureCache(FakePictureCacheModel* model);
+ ~FakeEnginePictureCache() override;
+
+ // EnginePictureCache implementation.
+ PictureCacheUpdate CalculateCacheUpdateAndFlush() override;
+ void MarkPictureForUnregistration(const SkPicture* picture) override;
+ void MarkPictureForRegistration(const SkPicture* picture) override;
+
+ private:
+ FakePictureCacheModel* model_;
+};
+
+class FakeClientPictureCache : public ClientPictureCache {
+ public:
+ explicit FakeClientPictureCache(FakePictureCacheModel* model);
+ ~FakeClientPictureCache() override;
+
+ // ClientPictureCache implementation.
+ sk_sp<const SkPicture> GetPicture(uint32_t unique_id) override;
+ void ApplyCacheUpdate(const PictureCacheUpdate& cache_update) override;
+ void Flush() override;
+ void MarkPictureForUnregistration(uint32_t engine_picture_id) override;
+ void MarkPictureForRegistration(uint32_t engine_picture_id) override;
+
+ private:
+ FakePictureCacheModel* model_;
+};
+
+} // namespace cc
+
+#endif // CC_TEST_FAKE_PICTURE_CACHE_H_

Powered by Google App Engine
This is Rietveld 408576698