osr_view_proxy.h 1.3 KB

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