osr_view_proxy.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright (c) 2017 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 SHELL_BROWSER_OSR_OSR_VIEW_PROXY_H_
  5. #define SHELL_BROWSER_OSR_OSR_VIEW_PROXY_H_
  6. #include <memory>
  7. #include <set>
  8. #include "third_party/skia/include/core/SkBitmap.h"
  9. #include "ui/events/event.h"
  10. #include "ui/gfx/geometry/rect.h"
  11. #include "ui/views/view.h"
  12. namespace electron {
  13. class OffscreenViewProxy;
  14. class OffscreenViewProxyObserver {
  15. public:
  16. virtual void OnProxyViewPaint(const gfx::Rect& damage_rect) = 0;
  17. virtual void ProxyViewDestroyed(OffscreenViewProxy* proxy) = 0;
  18. };
  19. class OffscreenViewProxy {
  20. public:
  21. explicit OffscreenViewProxy(views::View* view);
  22. ~OffscreenViewProxy();
  23. void SetObserver(OffscreenViewProxyObserver* observer);
  24. void RemoveObserver();
  25. const SkBitmap* GetBitmap() const;
  26. void SetBitmap(const SkBitmap& bitmap);
  27. const gfx::Rect& GetBounds();
  28. void SetBounds(const gfx::Rect& bounds);
  29. void OnEvent(ui::Event* event);
  30. void ResetView() { view_ = nullptr; }
  31. private:
  32. views::View* view_;
  33. gfx::Rect view_bounds_;
  34. std::unique_ptr<SkBitmap> view_bitmap_;
  35. OffscreenViewProxyObserver* observer_ = nullptr;
  36. };
  37. } // namespace electron
  38. #endif // SHELL_BROWSER_OSR_OSR_VIEW_PROXY_H_