| 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_RECORDING_SOURCE_H_ | 5 #ifndef CC_PLAYBACK_RECORDING_SOURCE_H_ |
| 6 #define CC_PLAYBACK_RECORDING_SOURCE_H_ | 6 #define CC_PLAYBACK_RECORDING_SOURCE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "cc/base/cc_export.h" | 14 #include "cc/base/cc_export.h" |
| 15 #include "cc/base/invalidation_region.h" | 15 #include "cc/base/invalidation_region.h" |
| 16 #include "third_party/skia/include/core/SkColor.h" | 16 #include "third_party/skia/include/core/SkColor.h" |
| 17 #include "ui/gfx/geometry/rect.h" | 17 #include "ui/gfx/geometry/rect.h" |
| 18 #include "ui/gfx/geometry/size.h" | 18 #include "ui/gfx/geometry/size.h" |
| 19 | 19 |
| 20 namespace { |
| 21 |
| 22 #ifdef NDEBUG |
| 23 const bool kDefaultClearCanvasSetting = false; |
| 24 #else |
| 25 const bool kDefaultClearCanvasSetting = true; |
| 26 #endif |
| 27 |
| 28 } // namespace |
| 29 |
| 20 namespace cc { | 30 namespace cc { |
| 21 | 31 |
| 22 namespace proto { | |
| 23 class RecordingSource; | |
| 24 } // namespace proto | |
| 25 | |
| 26 class ClientPictureCache; | 32 class ClientPictureCache; |
| 27 class ContentLayerClient; | 33 class ContentLayerClient; |
| 28 class DisplayItemList; | 34 class DisplayItemList; |
| 29 class RasterSource; | 35 class RasterSource; |
| 30 class Region; | 36 class Region; |
| 31 | 37 |
| 38 struct PictureLayerData { |
| 39 PictureLayerData(); |
| 40 ~PictureLayerData(); |
| 41 |
| 42 gfx::Size size; |
| 43 int slow_down_raster_scale_factor_for_debug = 0; |
| 44 bool generate_discardable_images_metadata = false; |
| 45 bool requires_clear = false; |
| 46 bool is_solid_color = false; |
| 47 bool clear_canvas_with_debug_color = kDefaultClearCanvasSetting; |
| 48 SkColor solid_color = SK_ColorTRANSPARENT; |
| 49 SkColor background_color = SK_ColorTRANSPARENT; |
| 50 |
| 51 void reset() { |
| 52 slow_down_raster_scale_factor_for_debug = 0; |
| 53 generate_discardable_images_metadata = false; |
| 54 requires_clear = false; |
| 55 is_solid_color = false; |
| 56 clear_canvas_with_debug_color = kDefaultClearCanvasSetting; |
| 57 solid_color = SK_ColorTRANSPARENT; |
| 58 background_color = SK_ColorTRANSPARENT; |
| 59 } |
| 60 }; |
| 61 |
| 62 // Encapsulates all data received from the ContentLayerClient. |
| 63 struct ContentLayerClientData { |
| 64 ContentLayerClientData(); |
| 65 ContentLayerClientData(const ContentLayerClientData&); |
| 66 ~ContentLayerClientData(); |
| 67 |
| 68 gfx::Rect recorded_viewport; |
| 69 scoped_refptr<DisplayItemList> display_list; |
| 70 size_t painter_reported_memory_usage = 0; |
| 71 |
| 72 void reset() { painter_reported_memory_usage = 0; } |
| 73 }; |
| 74 |
| 75 namespace proto { |
| 76 class RecordingSource; |
| 77 } // namespace proto |
| 78 |
| 32 class CC_EXPORT RecordingSource { | 79 class CC_EXPORT RecordingSource { |
| 33 public: | 80 public: |
| 34 // TODO(schenney) Remove RECORD_WITH_SK_NULL_CANVAS when we no longer | 81 // TODO(schenney) Remove RECORD_WITH_SK_NULL_CANVAS when we no longer |
| 35 // support a non-Slimming Paint path. | 82 // support a non-Slimming Paint path. |
| 36 enum RecordingMode { | 83 enum RecordingMode { |
| 37 RECORD_NORMALLY, | 84 RECORD_NORMALLY, |
| 38 RECORD_WITH_SK_NULL_CANVAS, | 85 RECORD_WITH_SK_NULL_CANVAS, |
| 39 RECORD_WITH_PAINTING_DISABLED, | 86 RECORD_WITH_PAINTING_DISABLED, |
| 40 RECORD_WITH_CACHING_DISABLED, | 87 RECORD_WITH_CACHING_DISABLED, |
| 41 RECORD_WITH_CONSTRUCTION_DISABLED, | 88 RECORD_WITH_CONSTRUCTION_DISABLED, |
| 42 RECORD_WITH_SUBSEQUENCE_CACHING_DISABLED, | 89 RECORD_WITH_SUBSEQUENCE_CACHING_DISABLED, |
| 43 RECORDING_MODE_COUNT, // Must be the last entry. | 90 RECORDING_MODE_COUNT, // Must be the last entry. |
| 44 }; | 91 }; |
| 45 | 92 |
| 46 RecordingSource(); | 93 RecordingSource(const PictureLayerData& plp_data, |
| 94 const ContentLayerClientData& clc_data); |
| 47 virtual ~RecordingSource(); | 95 virtual ~RecordingSource(); |
| 48 | 96 |
| 49 void ToProtobuf(proto::RecordingSource* proto) const; | |
| 50 void FromProtobuf(const proto::RecordingSource& proto, | |
| 51 ClientPictureCache* client_picture_cache, | |
| 52 std::vector<uint32_t>* used_engine_picture_ids); | |
| 53 | |
| 54 bool UpdateAndExpandInvalidation(ContentLayerClient* painter, | |
| 55 Region* invalidation, | |
| 56 const gfx::Size& layer_size, | |
| 57 int frame_number, | |
| 58 RecordingMode recording_mode); | |
| 59 gfx::Size GetSize() const; | |
| 60 void SetEmptyBounds(); | |
| 61 void SetSlowdownRasterScaleFactor(int factor); | |
| 62 void SetGenerateDiscardableImagesMetadata(bool generate_metadata); | |
| 63 void SetBackgroundColor(SkColor background_color); | |
| 64 void SetRequiresClear(bool requires_clear); | |
| 65 | |
| 66 void SetNeedsDisplayRect(const gfx::Rect& layer_rect); | |
| 67 | |
| 68 // These functions are virtual for testing. | 97 // These functions are virtual for testing. |
| 69 virtual scoped_refptr<RasterSource> CreateRasterSource( | 98 virtual scoped_refptr<RasterSource> CreateRasterSource( |
| 70 bool can_use_lcd_text) const; | 99 bool can_use_lcd_text) const; |
| 71 virtual bool IsSuitableForGpuRasterization() const; | |
| 72 | |
| 73 gfx::Rect recorded_viewport() const { return recorded_viewport_; } | |
| 74 | |
| 75 const DisplayItemList* GetDisplayItemList(); | |
| 76 | 100 |
| 77 protected: | 101 protected: |
| 78 void Clear(); | |
| 79 | |
| 80 gfx::Rect recorded_viewport_; | 102 gfx::Rect recorded_viewport_; |
| 81 gfx::Size size_; | 103 gfx::Size size_; |
| 82 int slow_down_raster_scale_factor_for_debug_; | 104 int slow_down_raster_scale_factor_for_debug_; |
| 83 bool generate_discardable_images_metadata_; | 105 bool generate_discardable_images_metadata_; |
| 84 bool requires_clear_; | 106 bool requires_clear_; |
| 85 bool is_solid_color_; | 107 bool is_solid_color_; |
| 86 bool clear_canvas_with_debug_color_; | 108 bool clear_canvas_with_debug_color_; |
| 87 SkColor solid_color_; | 109 SkColor solid_color_; |
| 88 SkColor background_color_; | 110 SkColor background_color_; |
| 89 | 111 |
| 90 scoped_refptr<DisplayItemList> display_list_; | 112 scoped_refptr<DisplayItemList> display_list_; |
| 91 size_t painter_reported_memory_usage_; | 113 size_t painter_reported_memory_usage_; |
| 92 | 114 |
| 93 private: | 115 private: |
| 94 void UpdateInvalidationForNewViewport(const gfx::Rect& old_recorded_viewport, | |
| 95 const gfx::Rect& new_recorded_viewport, | |
| 96 Region* invalidation); | |
| 97 void FinishDisplayItemListUpdate(); | |
| 98 | |
| 99 friend class RasterSource; | 116 friend class RasterSource; |
| 100 | 117 |
| 101 void DetermineIfSolidColor(); | |
| 102 | |
| 103 InvalidationRegion invalidation_; | |
| 104 | |
| 105 DISALLOW_COPY_AND_ASSIGN(RecordingSource); | 118 DISALLOW_COPY_AND_ASSIGN(RecordingSource); |
| 106 }; | 119 }; |
| 107 | 120 |
| 108 } // namespace cc | 121 } // namespace cc |
| 109 | 122 |
| 110 #endif // CC_PLAYBACK_RECORDING_SOURCE_H_ | 123 #endif // CC_PLAYBACK_RECORDING_SOURCE_H_ |
| OLD | NEW |