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

Unified Diff: blimp/engine/renderer/blimp_engine_picture_cache.h

Issue 1982893002: [blimp] Add SkPicture caching support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments from kmarshall 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: 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..6118216d4f4e0d9ad09dec2109398edf2ec9ff30
--- /dev/null
+++ b/blimp/engine/renderer/blimp_engine_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 BLIMP_ENGINE_RENDERER_BLIMP_ENGINE_PICTURE_CACHE_H_
+#define BLIMP_ENGINE_RENDERER_BLIMP_ENGINE_PICTURE_CACHE_H_
+
+#include <memory>
+#include <unordered_map>
+#include <vector>
+
+#include "base/macros.h"
+#include "blimp/common/compositor/reference_tracker.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 which happens when CalculateCacheUpdateAndFlush()
+// is called. 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.
+// The lifetime of a cache matches the lifetime of a specific compositor.
+// All interaction with this class should happen on the main thread.
+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:
+ // Serializes the SkPicture and adds it to |pictures_|.
+ void SerializePictureAndAddToCache(const SkPicture* picture);
Kevin M 2016/06/21 21:35:04 You used "Put()" in BlobCache. How about "Put()" h
nyquist 2016/06/24 11:11:15 Done.
+
+ // Returns whether |pictures_| currently contains the |picture|.
+ bool CacheContainsPicture(const SkPicture* picture) const;
Kevin M 2016/06/21 21:35:04 "Cache" and "Picture" are both implied. How about
nyquist 2016/06/24 11:11:15 Removed the whole method now.
+
+ // 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. Used for temporarily storing pictures until
+ // the next call to CalculateCacheUpdateAndFlush(), at which point this map
+ // is cleared.
+ std::unordered_map<uint32_t, cc::PictureData> pictures_;
+
+ // The reference tracker maintains the reference count of used SkPictures.
+ ReferenceTracker reference_tracker_;
+
+ DISALLOW_COPY_AND_ASSIGN(BlimpEnginePictureCache);
+};
+
+} // namespace engine
+} // namespace blimp
+
+#endif // BLIMP_ENGINE_RENDERER_BLIMP_ENGINE_PICTURE_CACHE_H_

Powered by Google App Engine
This is Rietveld 408576698