OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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_IMAGE_DECODE_CONTROLLER_H_ | 5 #ifndef CC_TILES_IMAGE_DECODE_CONTROLLER_H_ |
6 #define CC_TILES_IMAGE_DECODE_CONTROLLER_H_ | 6 #define CC_TILES_IMAGE_DECODE_CONTROLLER_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "cc/playback/decoded_draw_image.h" | 9 #include "cc/playback/decoded_draw_image.h" |
10 #include "cc/playback/draw_image.h" | 10 #include "cc/playback/draw_image.h" |
11 | 11 |
12 namespace cc { | 12 namespace cc { |
13 | 13 |
14 class ImageDecodeTask; | 14 class Task; |
15 | 15 |
16 // ImageDecodeController is responsible for generating decode tasks, decoding | 16 // ImageDecodeController is responsible for generating decode tasks, decoding |
17 // images, storing images in cache, and being able to return the decoded images | 17 // images, storing images in cache, and being able to return the decoded images |
18 // when requested. | 18 // when requested. |
19 | 19 |
20 // ImageDecodeController is responsible for the following things: | 20 // ImageDecodeController is responsible for the following things: |
21 // 1. Given a DrawImage, it can return an ImageDecodeTask which when run will | 21 // 1. Given a DrawImage, it can return an ImageDecodeTask which when run will |
22 // decode and cache the resulting image. If the image does not need a task to | 22 // decode and cache the resulting image. If the image does not need a task to |
23 // be decoded, then nullptr will be returned. The return value of the | 23 // be decoded, then nullptr will be returned. The return value of the |
24 // function indicates whether the image was or is going to be locked, so an | 24 // function indicates whether the image was or is going to be locked, so an |
(...skipping 11 matching lines...) Expand all Loading... |
36 virtual ~ImageDecodeController() {} | 36 virtual ~ImageDecodeController() {} |
37 | 37 |
38 // Fill in an ImageDecodeTask which will decode the given image when run. In | 38 // Fill in an ImageDecodeTask which will decode the given image when run. In |
39 // case the image is already cached, fills in nullptr. Returns true if the | 39 // case the image is already cached, fills in nullptr. Returns true if the |
40 // image needs to be unreffed when the caller is finished with it. | 40 // image needs to be unreffed when the caller is finished with it. |
41 // | 41 // |
42 // This is called by the tile manager (on the compositor thread) when creating | 42 // This is called by the tile manager (on the compositor thread) when creating |
43 // a raster task. | 43 // a raster task. |
44 virtual bool GetTaskForImageAndRef(const DrawImage& image, | 44 virtual bool GetTaskForImageAndRef(const DrawImage& image, |
45 uint64_t prepare_tiles_id, | 45 uint64_t prepare_tiles_id, |
46 scoped_refptr<ImageDecodeTask>* task) = 0; | 46 scoped_refptr<Task>* task) = 0; |
47 // Unrefs an image. When the tile is finished, this should be called for every | 47 // Unrefs an image. When the tile is finished, this should be called for every |
48 // GetTaskForImageAndRef call that returned true. | 48 // GetTaskForImageAndRef call that returned true. |
49 virtual void UnrefImage(const DrawImage& image) = 0; | 49 virtual void UnrefImage(const DrawImage& image) = 0; |
50 | 50 |
51 // Returns a decoded draw image. This may cause a decode if the image was not | 51 // Returns a decoded draw image. This may cause a decode if the image was not |
52 // predecoded. | 52 // predecoded. |
53 // | 53 // |
54 // This is called by a raster task (on a worker thread) when an image is | 54 // This is called by a raster task (on a worker thread) when an image is |
55 // required. | 55 // required. |
56 virtual DecodedDrawImage GetDecodedImageForDraw(const DrawImage& image) = 0; | 56 virtual DecodedDrawImage GetDecodedImageForDraw(const DrawImage& image) = 0; |
57 // Unrefs an image. This should be called for every GetDecodedImageForDraw | 57 // Unrefs an image. This should be called for every GetDecodedImageForDraw |
58 // when the draw with the image is finished. | 58 // when the draw with the image is finished. |
59 virtual void DrawWithImageFinished(const DrawImage& image, | 59 virtual void DrawWithImageFinished(const DrawImage& image, |
60 const DecodedDrawImage& decoded_image) = 0; | 60 const DecodedDrawImage& decoded_image) = 0; |
61 | 61 |
62 // This function informs the controller that now is a good time to clean up | 62 // This function informs the controller that now is a good time to clean up |
63 // memory. This is called periodically from the compositor thread. | 63 // memory. This is called periodically from the compositor thread. |
64 virtual void ReduceCacheUsage() = 0; | 64 virtual void ReduceCacheUsage() = 0; |
65 }; | 65 }; |
66 | 66 |
67 } // namespace cc | 67 } // namespace cc |
68 | 68 |
69 #endif // CC_TILES_IMAGE_DECODE_CONTROLLER_H_ | 69 #endif // CC_TILES_IMAGE_DECODE_CONTROLLER_H_ |
OLD | NEW |