| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PLAYBACK_DISPLAY_ITEM_LIST_H_ | 5 #ifndef CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ |
| 6 #define CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ | 6 #define CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
| 17 #include "cc/base/cc_export.h" | 17 #include "cc/base/cc_export.h" |
| 18 #include "cc/base/contiguous_container.h" | 18 #include "cc/base/contiguous_container.h" |
| 19 #include "cc/base/rtree.h" | 19 #include "cc/base/rtree.h" |
| 20 #include "cc/paint/paint_canvas.h" |
| 21 #include "cc/paint/paint_record.h" |
| 20 #include "cc/playback/discardable_image_map.h" | 22 #include "cc/playback/discardable_image_map.h" |
| 21 #include "cc/playback/display_item.h" | 23 #include "cc/playback/display_item.h" |
| 22 #include "cc/playback/display_item_list_settings.h" | 24 #include "cc/playback/display_item_list_settings.h" |
| 23 #include "third_party/skia/include/core/SkPicture.h" | |
| 24 #include "ui/gfx/color_space.h" | 25 #include "ui/gfx/color_space.h" |
| 25 #include "ui/gfx/geometry/rect.h" | 26 #include "ui/gfx/geometry/rect.h" |
| 26 #include "ui/gfx/geometry/rect_conversions.h" | 27 #include "ui/gfx/geometry/rect_conversions.h" |
| 27 | 28 |
| 28 class SkCanvas; | |
| 29 | |
| 30 namespace cc { | 29 namespace cc { |
| 31 class DisplayItem; | 30 class DisplayItem; |
| 32 | 31 |
| 33 class CC_EXPORT DisplayItemList | 32 class CC_EXPORT DisplayItemList |
| 34 : public base::RefCountedThreadSafe<DisplayItemList> { | 33 : public base::RefCountedThreadSafe<DisplayItemList> { |
| 35 public: | 34 public: |
| 36 // Creates a display item list. | 35 // Creates a display item list. |
| 37 static scoped_refptr<DisplayItemList> Create( | 36 static scoped_refptr<DisplayItemList> Create( |
| 38 const DisplayItemListSettings& settings); | 37 const DisplayItemListSettings& settings); |
| 39 | 38 |
| 40 // TODO(trchen): Deprecated. Apply clip and scale on the canvas instead. | 39 // TODO(trchen): Deprecated. Apply clip and scale on the canvas instead. |
| 41 void Raster(SkCanvas* canvas, | 40 void Raster(PaintCanvas* canvas, |
| 42 SkPicture::AbortCallback* callback, | 41 PaintRecord::AbortCallback* callback, |
| 43 const gfx::Rect& canvas_target_playback_rect, | 42 const gfx::Rect& canvas_target_playback_rect, |
| 44 float contents_scale) const; | 43 float contents_scale) const; |
| 45 | 44 |
| 46 void Raster(SkCanvas* canvas, SkPicture::AbortCallback* callback) const; | 45 void Raster(PaintCanvas* canvas, PaintRecord::AbortCallback* callback) const; |
| 47 | |
| 48 | 46 |
| 49 // Because processing happens in these CreateAndAppend functions, all the set | 47 // Because processing happens in these CreateAndAppend functions, all the set |
| 50 // up for the item should be done via the args, which is why the return type | 48 // up for the item should be done via the args, which is why the return type |
| 51 // needs to be const, to prevent set-after-processing mistakes. | 49 // needs to be const, to prevent set-after-processing mistakes. |
| 52 | 50 |
| 53 // Most paired begin item types default to an empty visual rect, which will | 51 // Most paired begin item types default to an empty visual rect, which will |
| 54 // subsequently be grown as needed to encompass any contained items that draw | 52 // subsequently be grown as needed to encompass any contained items that draw |
| 55 // content, such as drawing or filter items. | 53 // content, such as drawing or filter items. |
| 56 template <typename DisplayItemType, typename... Args> | 54 template <typename DisplayItemType, typename... Args> |
| 57 const DisplayItemType& CreateAndAppendPairedBeginItem(Args&&... args) { | 55 const DisplayItemType& CreateAndAppendPairedBeginItem(Args&&... args) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 const DisplayItemType& CreateAndAppendDrawingItem( | 111 const DisplayItemType& CreateAndAppendDrawingItem( |
| 114 const gfx::Rect& visual_rect, | 112 const gfx::Rect& visual_rect, |
| 115 Args&&... args) { | 113 Args&&... args) { |
| 116 inputs_.visual_rects.push_back(visual_rect); | 114 inputs_.visual_rects.push_back(visual_rect); |
| 117 GrowCurrentBeginItemVisualRect(visual_rect); | 115 GrowCurrentBeginItemVisualRect(visual_rect); |
| 118 | 116 |
| 119 return AllocateAndConstruct<DisplayItemType>(std::forward<Args>(args)...); | 117 return AllocateAndConstruct<DisplayItemType>(std::forward<Args>(args)...); |
| 120 } | 118 } |
| 121 | 119 |
| 122 // Called after all items are appended, to process the items and, if | 120 // Called after all items are appended, to process the items and, if |
| 123 // applicable, create an internally cached SkPicture. | 121 // applicable, create an internally cached PaintRecord. |
| 124 void Finalize(); | 122 void Finalize(); |
| 125 | 123 |
| 126 void SetIsSuitableForGpuRasterization(bool is_suitable) { | 124 void SetIsSuitableForGpuRasterization(bool is_suitable) { |
| 127 inputs_.all_items_are_suitable_for_gpu_rasterization = is_suitable; | 125 inputs_.all_items_are_suitable_for_gpu_rasterization = is_suitable; |
| 128 } | 126 } |
| 129 bool IsSuitableForGpuRasterization() const; | 127 bool IsSuitableForGpuRasterization() const; |
| 130 | 128 |
| 131 void SetImpliedColorSpace(const gfx::ColorSpace& implied_color_space) { | 129 void SetImpliedColorSpace(const gfx::ColorSpace& implied_color_space) { |
| 132 inputs_.implied_color_space_specified = true; | 130 inputs_.implied_color_space_specified = true; |
| 133 inputs_.implied_color_space = implied_color_space; | 131 inputs_.implied_color_space = implied_color_space; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 Inputs inputs_; | 216 Inputs inputs_; |
| 219 | 217 |
| 220 friend class base::RefCountedThreadSafe<DisplayItemList>; | 218 friend class base::RefCountedThreadSafe<DisplayItemList>; |
| 221 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); | 219 FRIEND_TEST_ALL_PREFIXES(DisplayItemListTest, ApproximateMemoryUsage); |
| 222 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); | 220 DISALLOW_COPY_AND_ASSIGN(DisplayItemList); |
| 223 }; | 221 }; |
| 224 | 222 |
| 225 } // namespace cc | 223 } // namespace cc |
| 226 | 224 |
| 227 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ | 225 #endif // CC_PLAYBACK_DISPLAY_ITEM_LIST_H_ |
| OLD | NEW |