recording_source.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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.
  4. #ifndef CC_LAYERS_RECORDING_SOURCE_H_
  5. #define CC_LAYERS_RECORDING_SOURCE_H_
  6. #include <stddef.h>
  7. #include "base/memory/ref_counted.h"
  8. #include "cc/base/invalidation_region.h"
  9. #include "cc/cc_export.h"
  10. #include "third_party/skia/include/core/SkColor.h"
  11. #include "ui/gfx/geometry/rect.h"
  12. #include "ui/gfx/geometry/size.h"
  13. namespace cc {
  14. class DisplayItemList;
  15. class RasterSource;
  16. class Region;
  17. class CC_EXPORT RecordingSource {
  18. public:
  19. RecordingSource();
  20. RecordingSource(const RecordingSource&) = delete;
  21. virtual ~RecordingSource();
  22. RecordingSource& operator=(const RecordingSource&) = delete;
  23. bool UpdateAndExpandInvalidation(Region* invalidation,
  24. const gfx::Size& layer_size,
  25. const gfx::Rect& new_recorded_viewport);
  26. void UpdateDisplayItemList(const scoped_refptr<DisplayItemList>& display_list,
  27. float recording_scale_factor);
  28. gfx::Size GetSize() const;
  29. void SetEmptyBounds();
  30. void SetSlowdownRasterScaleFactor(int factor);
  31. void SetBackgroundColor(SkColor4f background_color);
  32. void SetRequiresClear(bool requires_clear);
  33. void SetNeedsDisplayRect(const gfx::Rect& layer_rect);
  34. // These functions are virtual for testing.
  35. virtual scoped_refptr<RasterSource> CreateRasterSource() const;
  36. bool is_solid_color() const { return is_solid_color_; }
  37. protected:
  38. gfx::Rect recorded_viewport_;
  39. gfx::Size size_;
  40. int slow_down_raster_scale_factor_for_debug_ = 0;
  41. bool requires_clear_ = false;
  42. bool is_solid_color_ = false;
  43. SkColor4f solid_color_ = SkColors::kTransparent;
  44. SkColor4f background_color_ = SkColors::kTransparent;
  45. scoped_refptr<DisplayItemList> display_list_;
  46. float recording_scale_factor_ = 1.0f;
  47. private:
  48. void UpdateInvalidationForNewViewport(const gfx::Rect& old_recorded_viewport,
  49. const gfx::Rect& new_recorded_viewport,
  50. Region* invalidation);
  51. void FinishDisplayItemListUpdate();
  52. friend class RasterSource;
  53. void DetermineIfSolidColor();
  54. InvalidationRegion invalidation_;
  55. };
  56. } // namespace cc
  57. #endif // CC_LAYERS_RECORDING_SOURCE_H_