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_CACHE_H_ | 5 #ifndef CC_TILES_IMAGE_DECODE_CACHE_H_ |
6 #define CC_TILES_IMAGE_DECODE_CACHE_H_ | 6 #define CC_TILES_IMAGE_DECODE_CACHE_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" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 // Fill in an TileTask which will decode the given image when run. In | 55 // Fill in an TileTask which will decode the given image when run. In |
56 // case the image is already cached, fills in nullptr. Returns true if the | 56 // case the image is already cached, fills in nullptr. Returns true if the |
57 // image needs to be unreffed when the caller is finished with it. | 57 // image needs to be unreffed when the caller is finished with it. |
58 // | 58 // |
59 // This is called by the tile manager (on the compositor thread) when creating | 59 // This is called by the tile manager (on the compositor thread) when creating |
60 // a raster task. | 60 // a raster task. |
61 virtual bool GetTaskForImageAndRef(const DrawImage& image, | 61 virtual bool GetTaskForImageAndRef(const DrawImage& image, |
62 const TracingInfo& tracing_info, | 62 const TracingInfo& tracing_info, |
63 scoped_refptr<TileTask>* task) = 0; | 63 scoped_refptr<TileTask>* task) = 0; |
64 // Similar to GetTaskForImageAndRef, except that it returns tasks that are not | |
65 // meant to be run as part of raster. That is, this is part of a predecode | |
66 // API. Note that this should only return a task responsible for decoding (and | |
67 // not uploading), since it will be run on a worker thread which may not have | |
68 // the right GPU context for upload. | |
69 virtual bool GetOutOfRasterDecodeTaskForImageAndRef( | |
70 const DrawImage& image, | |
71 scoped_refptr<TileTask>* task) = 0; | |
72 | |
73 // Unrefs an image. When the tile is finished, this should be called for every | 64 // Unrefs an image. When the tile is finished, this should be called for every |
74 // GetTaskForImageAndRef call that returned true. | 65 // GetTaskForImageAndRef call that returned true. |
75 virtual void UnrefImage(const DrawImage& image) = 0; | 66 virtual void UnrefImage(const DrawImage& image) = 0; |
76 | 67 |
77 // Returns a decoded draw image. This may cause a decode if the image was not | 68 // Returns a decoded draw image. This may cause a decode if the image was not |
78 // predecoded. | 69 // predecoded. |
79 // | 70 // |
80 // This is called by a raster task (on a worker thread) when an image is | 71 // This is called by a raster task (on a worker thread) when an image is |
81 // required. | 72 // required. |
82 virtual DecodedDrawImage GetDecodedImageForDraw(const DrawImage& image) = 0; | 73 virtual DecodedDrawImage GetDecodedImageForDraw(const DrawImage& image) = 0; |
83 // Unrefs an image. This should be called for every GetDecodedImageForDraw | 74 // Unrefs an image. This should be called for every GetDecodedImageForDraw |
84 // when the draw with the image is finished. | 75 // when the draw with the image is finished. |
85 virtual void DrawWithImageFinished(const DrawImage& image, | 76 virtual void DrawWithImageFinished(const DrawImage& image, |
86 const DecodedDrawImage& decoded_image) = 0; | 77 const DecodedDrawImage& decoded_image) = 0; |
87 | 78 |
88 // This function informs the cache that now is a good time to clean up | 79 // This function informs the cache that now is a good time to clean up |
89 // memory. This is called periodically from the compositor thread. | 80 // memory. This is called periodically from the compositor thread. |
90 virtual void ReduceCacheUsage() = 0; | 81 virtual void ReduceCacheUsage() = 0; |
91 | 82 |
92 // This function informs the cache that we are hidden and should not be | 83 // This function informs the cache that we are hidden and should not be |
93 // retaining cached resources longer than needed. | 84 // retaining cached resources longer than needed. |
94 virtual void SetShouldAggressivelyFreeResources( | 85 virtual void SetShouldAggressivelyFreeResources( |
95 bool aggressively_free_resources) = 0; | 86 bool aggressively_free_resources) = 0; |
96 }; | 87 }; |
97 | 88 |
98 } // namespace cc | 89 } // namespace cc |
99 | 90 |
100 #endif // CC_TILES_IMAGE_DECODE_CACHE_H_ | 91 #endif // CC_TILES_IMAGE_DECODE_CACHE_H_ |
OLD | NEW |