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

Side by Side Diff: cc/tiles/gpu_image_decode_controller.h

Issue 2130683002: [Experiment] purge-and-suspend Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_TILES_GPU_IMAGE_DECODE_CONTROLLER_H_ 5 #ifndef CC_TILES_GPU_IMAGE_DECODE_CONTROLLER_H_
6 #define CC_TILES_GPU_IMAGE_DECODE_CONTROLLER_H_ 6 #define CC_TILES_GPU_IMAGE_DECODE_CONTROLLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <unordered_map> 9 #include <unordered_map>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/containers/mru_cache.h" 12 #include "base/containers/mru_cache.h"
13 #include "base/memory/discardable_memory.h" 13 #include "base/memory/discardable_memory.h"
14 #include "base/memory/memory_pressure_listener.h"
14 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
15 #include "base/trace_event/memory_dump_provider.h" 16 #include "base/trace_event/memory_dump_provider.h"
16 #include "cc/base/cc_export.h" 17 #include "cc/base/cc_export.h"
17 #include "cc/resources/resource_format.h" 18 #include "cc/resources/resource_format.h"
18 #include "cc/tiles/image_decode_controller.h" 19 #include "cc/tiles/image_decode_controller.h"
19 #include "third_party/skia/include/core/SkRefCnt.h" 20 #include "third_party/skia/include/core/SkRefCnt.h"
20 21
21 class SkImageTextureData; 22 class SkImageTextureData;
22 23
23 namespace cc { 24 namespace cc {
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 // Returns true if the given ImageData can be used to draw the specified 295 // Returns true if the given ImageData can be used to draw the specified
295 // DrawImage. 296 // DrawImage.
296 bool IsCompatible(const ImageData* image_data, 297 bool IsCompatible(const ImageData* image_data,
297 const DrawImage& draw_image) const; 298 const DrawImage& draw_image) const;
298 299
299 // The following two functions also require the |context_| lock to be held. 300 // The following two functions also require the |context_| lock to be held.
300 void UploadImageIfNecessary(const DrawImage& draw_image, 301 void UploadImageIfNecessary(const DrawImage& draw_image,
301 ImageData* image_data); 302 ImageData* image_data);
302 void DeletePendingImages(); 303 void DeletePendingImages();
303 304
305 void OnMemoryPressure(
306 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
307
304 const ResourceFormat format_; 308 const ResourceFormat format_;
305 ContextProvider* context_; 309 ContextProvider* context_;
306 sk_sp<GrContextThreadSafeProxy> context_threadsafe_proxy_; 310 sk_sp<GrContextThreadSafeProxy> context_threadsafe_proxy_;
307 311
308 // All members below this point must only be accessed while holding |lock_|. 312 // All members below this point must only be accessed while holding |lock_|.
309 base::Lock lock_; 313 base::Lock lock_;
310 314
311 // |persistent_cache_| represents the long-lived cache, keeping a certain 315 // |persistent_cache_| represents the long-lived cache, keeping a certain
312 // budget of ImageDatas alive even when their ref count reaches zero. 316 // budget of ImageDatas alive even when their ref count reaches zero.
313 using PersistentCache = base::MRUCache<uint32_t, scoped_refptr<ImageData>>; 317 using PersistentCache = base::MRUCache<uint32_t, scoped_refptr<ImageData>>;
314 PersistentCache persistent_cache_; 318 PersistentCache persistent_cache_;
315 319
316 // |in_use_cache_| represents the in-use (short-lived) cache. Entries are 320 // |in_use_cache_| represents the in-use (short-lived) cache. Entries are
317 // cleaned up as soon as their ref count reaches zero. 321 // cleaned up as soon as their ref count reaches zero.
318 using InUseCache = std::unordered_map<InUseCacheKey, InUseCacheEntry>; 322 using InUseCache = std::unordered_map<InUseCacheKey, InUseCacheEntry>;
319 InUseCache in_use_cache_; 323 InUseCache in_use_cache_;
320 324
321 size_t cached_items_limit_; 325 size_t cached_items_limit_;
322 size_t cached_bytes_limit_; 326 size_t cached_bytes_limit_;
323 size_t bytes_used_; 327 size_t bytes_used_;
324 const size_t max_gpu_image_bytes_; 328 const size_t max_gpu_image_bytes_;
325 329
326 // We can't release GPU backed SkImages without holding the context lock, 330 // We can't release GPU backed SkImages without holding the context lock,
327 // so we add them to this list and defer deletion until the next time the lock 331 // so we add them to this list and defer deletion until the next time the lock
328 // is held. 332 // is held.
329 std::vector<sk_sp<SkImage>> images_pending_deletion_; 333 std::vector<sk_sp<SkImage>> images_pending_deletion_;
334
335 std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_;
330 }; 336 };
331 337
332 } // namespace cc 338 } // namespace cc
333 339
334 #endif // CC_TILES_GPU_IMAGE_DECODE_CONTROLLER_H_ 340 #endif // CC_TILES_GPU_IMAGE_DECODE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698