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

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

Issue 1890903002: cc: Simplify Task and its derived classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_tile_task_runner
Patch Set: nits Created 4 years, 8 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 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;
15 class Task; 14 class Task;
16 15
17 // ImageDecodeController is responsible for generating decode tasks, decoding 16 // ImageDecodeController is responsible for generating decode tasks, decoding
18 // 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
19 // when requested. 18 // when requested.
20 19
21 // ImageDecodeController is responsible for the following things: 20 // ImageDecodeController is responsible for the following things:
22 // 1. Given a DrawImage, it can return an ImageDecodeTask which when run will 21 // 1. Given a DrawImage, it can return an Task which when run will decode and
23 // decode and cache the resulting image. If the image does not need a task to 22 // cache the resulting image. If the image does not need a task to be
24 // be decoded, then nullptr will be returned. The return value of the 23 // decoded, then nullptr will be returned. The return value of the function
25 // function indicates whether the image was or is going to be locked, so an 24 // indicates whether the image was or is going to be locked, so an unlock
26 // unlock will be required. 25 // will be required.
27 // 2. Given a cache key and a DrawImage, it can decode the image and store it in 26 // 2. Given a cache key and a DrawImage, it can decode the image and store it in
28 // the cache. Note that it is important that this function is only accessed 27 // the cache. Note that it is important that this function is only accessed
29 // via an image decode task. 28 // via an image decode task.
30 // 3. Given a DrawImage, it can return a DecodedDrawImage, which represented the 29 // 3. Given a DrawImage, it can return a DecodedDrawImage, which represented the
31 // decoded version of the image. Note that if the image is not in the cache 30 // decoded version of the image. Note that if the image is not in the cache
32 // and it needs to be scaled/decoded, then this decode will happen as part of 31 // and it needs to be scaled/decoded, then this decode will happen as part of
33 // getting the image. As such, this should only be accessed from a raster 32 // getting the image. As such, this should only be accessed from a raster
34 // thread. 33 // thread.
35 class CC_EXPORT ImageDecodeController { 34 class CC_EXPORT ImageDecodeController {
36 public: 35 public:
37 virtual ~ImageDecodeController() {} 36 virtual ~ImageDecodeController() {}
38 37
39 // Fill in an ImageDecodeTask which will decode the given image when run. In 38 // TODO(prashant.n): Update this comment properly to reflect upload and decode
39 // tasks.
40 // Fill in an Task which will decode the given image when run. In
40 // case the image is already cached, fills in nullptr. Returns true if the 41 // case the image is already cached, fills in nullptr. Returns true if the
41 // image needs to be unreffed when the caller is finished with it. 42 // image needs to be unreffed when the caller is finished with it.
42 // 43 //
43 // This is called by the tile manager (on the compositor thread) when creating 44 // This is called by the tile manager (on the compositor thread) when creating
44 // a raster task. 45 // a raster task.
45 virtual bool GetTaskForImageAndRef(const DrawImage& image, 46 virtual bool GetTaskForImageAndRef(const DrawImage& image,
46 uint64_t prepare_tiles_id, 47 uint64_t prepare_tiles_id,
47 scoped_refptr<ImageDecodeTask>* task) = 0; 48 scoped_refptr<Task>* task) = 0;
48 // Unrefs an image. When the tile is finished, this should be called for every 49 // Unrefs an image. When the tile is finished, this should be called for every
49 // GetTaskForImageAndRef call that returned true. 50 // GetTaskForImageAndRef call that returned true.
50 virtual void UnrefImage(const DrawImage& image) = 0; 51 virtual void UnrefImage(const DrawImage& image) = 0;
51 52
52 // Returns a decoded draw image. This may cause a decode if the image was not 53 // Returns a decoded draw image. This may cause a decode if the image was not
53 // predecoded. 54 // predecoded.
54 // 55 //
55 // This is called by a raster task (on a worker thread) when an image is 56 // This is called by a raster task (on a worker thread) when an image is
56 // required. 57 // required.
57 virtual DecodedDrawImage GetDecodedImageForDraw(const DrawImage& image) = 0; 58 virtual DecodedDrawImage GetDecodedImageForDraw(const DrawImage& image) = 0;
(...skipping 13 matching lines...) Expand all
71 72
72 // These functions process completion of image decode/upload tasks on origin 73 // These functions process completion of image decode/upload tasks on origin
73 // thread (i.e. on the compositor thread called by the tile manager). 74 // thread (i.e. on the compositor thread called by the tile manager).
74 virtual void ImageDecodeTaskCompleted(Task* task) = 0; 75 virtual void ImageDecodeTaskCompleted(Task* task) = 0;
75 virtual void ImageUploadTaskCompleted(Task* task) = 0; 76 virtual void ImageUploadTaskCompleted(Task* task) = 0;
76 }; 77 };
77 78
78 } // namespace cc 79 } // namespace cc
79 80
80 #endif // CC_TILES_IMAGE_DECODE_CONTROLLER_H_ 81 #endif // CC_TILES_IMAGE_DECODE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698