Index: blimp/engine/renderer/blimp_engine_picture_cache.h |
diff --git a/blimp/engine/renderer/blimp_engine_picture_cache.h b/blimp/engine/renderer/blimp_engine_picture_cache.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..eb88e5420ba14460a0d2358444e4d96d83ba1f36 |
--- /dev/null |
+++ b/blimp/engine/renderer/blimp_engine_picture_cache.h |
@@ -0,0 +1,57 @@ |
+// 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 BLIMP_ENGINE_RENDERER_BLIMP_ENGINE_PICTURE_CACHE_H_ |
+#define BLIMP_ENGINE_RENDERER_BLIMP_ENGINE_PICTURE_CACHE_H_ |
+ |
+#include <map> |
+#include <memory> |
+#include <vector> |
+ |
+#include "base/macros.h" |
+#include "blimp/common/compositor/blimp_picture_cache_registry.h" |
+#include "cc/proto/picture_cache.h" |
+#include "third_party/skia/include/core/SkPicture.h" |
+ |
+class SkPixelSerializer; |
+ |
+namespace blimp { |
+namespace engine { |
+ |
+// BlimpEnginePictureCache provides functionality for caching SkPictures before |
+// they are sent from the engine to the client. The cache is cleared after |
+// every time it is flushed, but the expected state of what the client already |
+// has cached is tracked. It is required to update this cache when an SkPicture |
+// starts being used and when it is not longer in use by calling |
+// MarkPictureForRegistration and MarkPictureForUnregistration respectively. |
+class BlimpEnginePictureCache : public cc::EnginePictureCache { |
+ public: |
+ explicit BlimpEnginePictureCache(SkPixelSerializer* pixel_serializer); |
+ ~BlimpEnginePictureCache() override; |
+ |
+ // cc::EnginePictureCache implementation. |
+ void MarkPictureForUnregistration(const SkPicture* picture) override; |
+ void MarkPictureForRegistration(const SkPicture* picture) override; |
+ cc::PictureCacheUpdate CalculateCacheUpdateAndFlush() override; |
+ |
+ private: |
+ using PictureMap = std::map<uint32_t, cc::PictureData>; |
vmpstr
2016/06/01 00:10:56
You don't need the alias, just use the type direct
nyquist
2016/06/04 00:24:57
Done.
|
+ |
+ // A serializer that be used to pass in to SkPicture::serialize(...) for |
+ // serializing the SkPicture to a stream. |
+ SkPixelSerializer* pixel_serializer_; |
+ |
+ // The current cache of pictures. Cleared after every flush. |
+ PictureMap pictures_; |
+ |
+ // A ref-counted registry of SkPictures that are currently in use. |
+ BlimpPictureCacheRegistry registry_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(BlimpEnginePictureCache); |
+}; |
+ |
+} // namespace engine |
+} // namespace blimp |
+ |
+#endif // BLIMP_ENGINE_RENDERER_BLIMP_ENGINE_PICTURE_CACHE_H_ |