Update V8 to version 4.7.37.
[chromium-blink-merge.git] / cc / playback / display_list_raster_source.h
blobd8071b1808d080eea1128a6a4720339670f6ae62
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_RASTER_SOURCE_H_
6 #define CC_PLAYBACK_DISPLAY_LIST_RASTER_SOURCE_H_
8 #include <vector>
10 #include "base/memory/scoped_ptr.h"
11 #include "cc/base/cc_export.h"
12 #include "cc/debug/rendering_stats_instrumentation.h"
13 #include "cc/playback/display_list_recording_source.h"
14 #include "cc/playback/raster_source.h"
15 #include "skia/ext/analysis_canvas.h"
16 #include "skia/ext/refptr.h"
17 #include "third_party/skia/include/core/SkPicture.h"
19 namespace cc {
20 class DisplayItemList;
22 class CC_EXPORT DisplayListRasterSource : public RasterSource {
23 public:
24 static scoped_refptr<DisplayListRasterSource>
25 CreateFromDisplayListRecordingSource(const DisplayListRecordingSource* other,
26 bool can_use_lcd_text);
28 // RasterSource overrides.
29 void PlaybackToCanvas(SkCanvas* canvas,
30 const gfx::Rect& canvas_bitmap_rect,
31 const gfx::Rect& canvas_playback_rect,
32 float contents_scale) const override;
33 void PlaybackToSharedCanvas(SkCanvas* canvas,
34 const gfx::Rect& canvas_rect,
35 float contents_scale) const override;
36 void PerformSolidColorAnalysis(
37 const gfx::Rect& content_rect,
38 float contents_scale,
39 RasterSource::SolidColorAnalysis* analysis) const override;
40 bool IsSolidColor() const override;
41 SkColor GetSolidColor() const override;
42 gfx::Size GetSize() const override;
43 void GatherPixelRefs(
44 const gfx::Rect& layer_rect,
45 std::vector<skia::PositionPixelRef>* pixel_refs) const override;
46 bool CoversRect(const gfx::Rect& layer_rect) const override;
47 bool HasRecordings() const override;
48 gfx::Rect RecordedViewport() const override;
49 void SetShouldAttemptToUseDistanceFieldText() override;
50 bool ShouldAttemptToUseDistanceFieldText() const override;
51 void DidBeginTracing() override;
52 void AsValueInto(base::trace_event::TracedValue* array) const override;
53 skia::RefPtr<SkPicture> GetFlattenedPicture() override;
54 size_t GetPictureMemoryUsage() const override;
55 bool CanUseLCDText() const override;
56 scoped_refptr<RasterSource> CreateCloneWithoutLCDText() const override;
58 protected:
59 DisplayListRasterSource();
60 DisplayListRasterSource(const DisplayListRecordingSource* other,
61 bool can_use_lcd_text);
62 DisplayListRasterSource(const DisplayListRasterSource* other,
63 bool can_use_lcd_text);
64 ~DisplayListRasterSource() override;
66 // These members are const as this raster source may be in use on another
67 // thread and so should not be touched after construction.
68 const scoped_refptr<DisplayItemList> display_list_;
69 const size_t painter_reported_memory_usage_;
70 const SkColor background_color_;
71 const bool requires_clear_;
72 const bool can_use_lcd_text_;
73 const bool is_solid_color_;
74 const SkColor solid_color_;
75 const gfx::Rect recorded_viewport_;
76 const gfx::Size size_;
77 const bool clear_canvas_with_debug_color_;
78 const int slow_down_raster_scale_factor_for_debug_;
79 // TODO(enne/vmiura): this has a read/write race between raster and compositor
80 // threads with multi-threaded Ganesh. Make this const or remove it.
81 bool should_attempt_to_use_distance_field_text_;
83 private:
84 // Called when analyzing a tile. We can use AnalysisCanvas as
85 // SkPicture::AbortCallback, which allows us to early out from analysis.
86 void RasterForAnalysis(skia::AnalysisCanvas* canvas,
87 const gfx::Rect& canvas_rect,
88 float contents_scale) const;
90 void RasterCommon(SkCanvas* canvas,
91 SkPicture::AbortCallback* callback,
92 const gfx::Rect& canvas_bitmap_rect,
93 const gfx::Rect& canvas_playback_rect,
94 float contents_scale) const;
96 DISALLOW_COPY_AND_ASSIGN(DisplayListRasterSource);
99 } // namespace cc
101 #endif // CC_PLAYBACK_DISPLAY_LIST_RASTER_SOURCE_H_