cc: Adding DidFinishImplFrame to LTHI.
[chromium-blink-merge.git] / cc / resources / display_list_raster_source.h
blob8c2ab910496373d6501f9d5864b115a556a235af
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_RESOURCES_DISPLAY_LIST_RASTER_SOURCE_H_
6 #define CC_RESOURCES_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/resources/display_list_recording_source.h"
14 #include "cc/resources/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_rect,
31 float contents_scale) const override;
32 void PlaybackToSharedCanvas(SkCanvas* canvas,
33 const gfx::Rect& canvas_rect,
34 float contents_scale) const override;
35 void PerformSolidColorAnalysis(
36 const gfx::Rect& content_rect,
37 float contents_scale,
38 RasterSource::SolidColorAnalysis* analysis) const override;
39 bool IsSolidColor() const override;
40 SkColor GetSolidColor() const override;
41 gfx::Size GetSize() const override;
42 void GatherPixelRefs(const gfx::Rect& content_rect,
43 float contents_scale,
44 std::vector<SkPixelRef*>* pixel_refs) const override;
45 bool CoversRect(const gfx::Rect& content_rect,
46 float contents_scale) const override;
47 bool HasRecordings() const override;
48 void SetShouldAttemptToUseDistanceFieldText() override;
49 bool ShouldAttemptToUseDistanceFieldText() const override;
50 void DidBeginTracing() override;
51 void AsValueInto(base::trace_event::TracedValue* array) const override;
52 skia::RefPtr<SkPicture> GetFlattenedPicture() override;
53 size_t GetPictureMemoryUsage() const override;
54 bool CanUseLCDText() const override;
55 scoped_refptr<RasterSource> CreateCloneWithoutLCDText() const override;
57 protected:
58 DisplayListRasterSource();
59 DisplayListRasterSource(const DisplayListRecordingSource* other,
60 bool can_use_lcd_text);
61 DisplayListRasterSource(const DisplayListRasterSource* other,
62 bool can_use_lcd_text);
63 ~DisplayListRasterSource() override;
65 // These members are const as this raster source may be in use on another
66 // thread and so should not be touched after construction.
67 const scoped_refptr<DisplayItemList> display_list_;
68 const SkColor background_color_;
69 const bool requires_clear_;
70 const bool can_use_lcd_text_;
71 const bool is_solid_color_;
72 const SkColor solid_color_;
73 const gfx::Rect recorded_viewport_;
74 const gfx::Size size_;
75 const bool clear_canvas_with_debug_color_;
76 const int slow_down_raster_scale_factor_for_debug_;
77 // TODO(enne/vmiura): this has a read/write race between raster and compositor
78 // threads with multi-threaded Ganesh. Make this const or remove it.
79 bool should_attempt_to_use_distance_field_text_;
81 private:
82 // Called when analyzing a tile. We can use AnalysisCanvas as
83 // SkDrawPictureCallback, which allows us to early out from analysis.
84 void RasterForAnalysis(skia::AnalysisCanvas* canvas,
85 const gfx::Rect& canvas_rect,
86 float contents_scale) const;
88 void RasterCommon(SkCanvas* canvas,
89 SkDrawPictureCallback* callback,
90 const gfx::Rect& canvas_rect,
91 float contents_scale) const;
93 DISALLOW_COPY_AND_ASSIGN(DisplayListRasterSource);
96 } // namespace cc
98 #endif // CC_RESOURCES_DISPLAY_LIST_RASTER_SOURCE_H_