[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / cc / tiles / image_decode_controller.h
blobcbd5af162c0cbf29d82328cba832fbb6bfa9c283
1 // Copyright 2015 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.
5 #ifndef CC_TILES_IMAGE_DECODE_CONTROLLER_H_
6 #define CC_TILES_IMAGE_DECODE_CONTROLLER_H_
8 #include "base/containers/hash_tables.h"
9 #include "base/memory/ref_counted.h"
10 #include "cc/base/cc_export.h"
11 #include "cc/raster/tile_task_runner.h"
12 #include "skia/ext/discardable_image_utils.h"
13 #include "skia/ext/refptr.h"
15 namespace cc {
17 class ImageDecodeController {
18 public:
19 ImageDecodeController();
20 ~ImageDecodeController();
22 scoped_refptr<ImageDecodeTask> GetTaskForImage(
23 const skia::PositionImage& image,
24 int layer_id,
25 uint64_t prepare_tiles_id);
27 // Note that this function has to remain thread safe.
28 void DecodeImage(const SkImage* image);
30 // TODO(vmpstr): This should go away once the controller is decoding images
31 // based on priority and memory.
32 void AddLayerUsedCount(int layer_id);
33 void SubtractLayerUsedCount(int layer_id);
35 void OnImageDecodeTaskCompleted(int layer_id,
36 const SkImage* image,
37 bool was_canceled);
39 private:
40 scoped_refptr<ImageDecodeTask> CreateTaskForImage(const SkImage* image,
41 int layer_id,
42 uint64_t prepare_tiles_id);
44 using ImageTaskMap = base::hash_map<uint32_t, scoped_refptr<ImageDecodeTask>>;
45 using LayerImageTaskMap = base::hash_map<int, ImageTaskMap>;
46 LayerImageTaskMap image_decode_tasks_;
48 using LayerCountMap = base::hash_map<int, int>;
49 LayerCountMap used_layer_counts_;
52 } // namespace cc
54 #endif // CC_TILES_IMAGE_DECODE_CONTROLLER_H_