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

Side by Side Diff: cc/playback/discardable_image_map.h

Issue 2748263002: Move cc::DisplayItemList and related classes into cc/paint/ (Closed)
Patch Set: Merge branch 'master' into ccpaint Created 3 years, 9 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
« no previous file with comments | « cc/playback/decoded_draw_image.cc ('k') | cc/playback/discardable_image_map.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef CC_PLAYBACK_DISCARDABLE_IMAGE_MAP_H_
6 #define CC_PLAYBACK_DISCARDABLE_IMAGE_MAP_H_
7
8 #include <unordered_map>
9 #include <utility>
10 #include <vector>
11
12 #include "cc/base/cc_export.h"
13 #include "cc/base/rtree.h"
14 #include "cc/playback/draw_image.h"
15 #include "cc/playback/image_id.h"
16 #include "third_party/skia/include/core/SkCanvas.h"
17 #include "third_party/skia/include/core/SkRefCnt.h"
18 #include "ui/gfx/geometry/rect.h"
19 #include "ui/gfx/geometry/size.h"
20
21 namespace cc {
22
23 // Helper function to apply the matrix to the rect and return the result.
24 SkRect MapRect(const SkMatrix& matrix, const SkRect& src);
25
26 // This class is used for generating discardable images data (see DrawImage
27 // for the type of data it stores). It allows the client to query a particular
28 // rect and get back a list of DrawImages in that rect.
29 class CC_EXPORT DiscardableImageMap {
30 public:
31 class CC_EXPORT ScopedMetadataGenerator {
32 public:
33 ScopedMetadataGenerator(DiscardableImageMap* image_map,
34 const gfx::Size& bounds);
35 ~ScopedMetadataGenerator();
36
37 SkCanvas* canvas() { return metadata_canvas_.get(); }
38
39 private:
40 DiscardableImageMap* image_map_;
41 std::unique_ptr<SkCanvas> metadata_canvas_;
42 };
43
44 DiscardableImageMap();
45 ~DiscardableImageMap();
46
47 bool empty() const { return all_images_.empty(); }
48 void GetDiscardableImagesInRect(const gfx::Rect& rect,
49 float contents_scale,
50 std::vector<DrawImage>* images) const;
51 gfx::Rect GetRectForImage(ImageId image_id) const;
52
53 private:
54 friend class ScopedMetadataGenerator;
55 friend class DiscardableImageMapTest;
56
57 std::unique_ptr<SkCanvas> BeginGeneratingMetadata(const gfx::Size& bounds);
58 void EndGeneratingMetadata();
59
60 std::vector<std::pair<DrawImage, gfx::Rect>> all_images_;
61 std::unordered_map<ImageId, gfx::Rect> image_id_to_rect_;
62
63 RTree images_rtree_;
64 };
65
66 } // namespace cc
67
68 #endif // CC_PLAYBACK_DISCARDABLE_IMAGE_MAP_H_
OLDNEW
« no previous file with comments | « cc/playback/decoded_draw_image.cc ('k') | cc/playback/discardable_image_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698