Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / cc / tiles / image_decode_controller.h
bloba9f423e95097304f966a0f57310e54b8f37e1037
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/pixel_ref_utils.h"
13 #include "skia/ext/refptr.h"
14 #include "third_party/skia/include/core/SkPixelRef.h"
16 namespace cc {
18 class ImageDecodeController {
19 public:
20 ImageDecodeController();
21 ~ImageDecodeController();
23 scoped_refptr<ImageDecodeTask> GetTaskForPixelRef(
24 const skia::PositionPixelRef& pixel_ref,
25 int layer_id,
26 uint64_t prepare_tiles_id);
28 // Note that this function has to remain thread safe.
29 void DecodePixelRef(SkPixelRef* pixel_ref);
31 // TODO(vmpstr): This should go away once the controller is decoding images
32 // based on priority and memory.
33 void AddLayerUsedCount(int layer_id);
34 void SubtractLayerUsedCount(int layer_id);
36 void OnImageDecodeTaskCompleted(int layer_id,
37 SkPixelRef* pixel_ref,
38 bool was_canceled);
40 private:
41 scoped_refptr<ImageDecodeTask> CreateTaskForPixelRef(
42 SkPixelRef* pixel_ref,
43 int layer_id,
44 uint64_t prepare_tiles_id);
46 using PixelRefTaskMap =
47 base::hash_map<uint32_t, scoped_refptr<ImageDecodeTask>>;
48 using LayerPixelRefTaskMap = base::hash_map<int, PixelRefTaskMap>;
49 LayerPixelRefTaskMap image_decode_tasks_;
51 using LayerCountMap = base::hash_map<int, int>;
52 LayerCountMap used_layer_counts_;
55 } // namespace cc
57 #endif // CC_TILES_IMAGE_DECODE_CONTROLLER_H_