Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / cc / playback / display_list_recording_source.h
blob912d9363a99cbdaa25774400785ba4406e630580
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
3 // found in the LICENSE file.
5 #ifndef CC_PLAYBACK_DISPLAY_LIST_RECORDING_SOURCE_H_
6 #define CC_PLAYBACK_DISPLAY_LIST_RECORDING_SOURCE_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "cc/playback/recording_source.h"
11 namespace cc {
12 class DisplayItemList;
13 class DisplayListRasterSource;
15 class CC_EXPORT DisplayListRecordingSource : public RecordingSource {
16 public:
17 explicit DisplayListRecordingSource(const gfx::Size& grid_cell_size);
18 ~DisplayListRecordingSource() override;
20 // RecordingSource overrides.
21 bool UpdateAndExpandInvalidation(ContentLayerClient* painter,
22 Region* invalidation,
23 const gfx::Size& layer_size,
24 const gfx::Rect& visible_layer_rect,
25 int frame_number,
26 RecordingMode recording_mode) override;
27 scoped_refptr<RasterSource> CreateRasterSource(
28 bool can_use_lcd_text) const override;
29 gfx::Size GetSize() const final;
30 void SetEmptyBounds() override;
31 void SetSlowdownRasterScaleFactor(int factor) override;
32 void SetGatherDiscardableImages(bool gather_images) override;
33 void SetBackgroundColor(SkColor background_color) override;
34 void SetRequiresClear(bool requires_clear) override;
35 bool IsSuitableForGpuRasterization() const override;
36 // Returns true if the new recorded viewport exposes enough new area to be
37 // worth re-recording.
38 static bool ExposesEnoughNewArea(
39 const gfx::Rect& current_recorded_viewport,
40 const gfx::Rect& potential_new_recorded_viewport,
41 const gfx::Size& layer_size);
43 gfx::Rect recorded_viewport() const { return recorded_viewport_; }
45 protected:
46 void Clear();
48 gfx::Rect recorded_viewport_;
49 gfx::Size size_;
50 int slow_down_raster_scale_factor_for_debug_;
51 bool gather_images_;
52 bool requires_clear_;
53 bool is_solid_color_;
54 bool clear_canvas_with_debug_color_;
55 SkColor solid_color_;
56 SkColor background_color_;
57 int pixel_record_distance_;
58 gfx::Size grid_cell_size_;
60 scoped_refptr<DisplayItemList> display_list_;
61 size_t painter_reported_memory_usage_;
63 private:
64 friend class DisplayListRasterSource;
66 void DetermineIfSolidColor();
68 DISALLOW_COPY_AND_ASSIGN(DisplayListRecordingSource);
71 } // namespace cc
73 #endif // CC_PLAYBACK_DISPLAY_LIST_RECORDING_SOURCE_H_