osr_output_device.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright (c) 2016 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ATOM_BROWSER_OSR_OSR_OUTPUT_DEVICE_H_
  5. #define ATOM_BROWSER_OSR_OSR_OUTPUT_DEVICE_H_
  6. #include "base/callback.h"
  7. #include "components/viz/service/display/software_output_device.h"
  8. #include "third_party/skia/include/core/SkBitmap.h"
  9. #include "third_party/skia/include/core/SkCanvas.h"
  10. namespace atom {
  11. typedef base::Callback<void(const gfx::Rect&, const SkBitmap&)> OnPaintCallback;
  12. class OffScreenOutputDevice : public viz::SoftwareOutputDevice {
  13. public:
  14. OffScreenOutputDevice(bool transparent, const OnPaintCallback& callback);
  15. ~OffScreenOutputDevice() override;
  16. // viz::SoftwareOutputDevice:
  17. void Resize(const gfx::Size& pixel_size, float scale_factor) override;
  18. SkCanvas* BeginPaint(const gfx::Rect& damage_rect) override;
  19. void EndPaint() override;
  20. void SetActive(bool active, bool paint);
  21. void OnPaint(const gfx::Rect& damage_rect);
  22. private:
  23. const bool transparent_;
  24. OnPaintCallback callback_;
  25. bool active_ = false;
  26. std::unique_ptr<SkCanvas> canvas_;
  27. std::unique_ptr<SkBitmap> bitmap_;
  28. gfx::Rect pending_damage_rect_;
  29. DISALLOW_COPY_AND_ASSIGN(OffScreenOutputDevice);
  30. };
  31. } // namespace atom
  32. #endif // ATOM_BROWSER_OSR_OSR_OUTPUT_DEVICE_H_