2017-05-21 17:55:19 +00:00
|
|
|
// Copyright (c) 2017 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_OSR_OSR_VIEW_PROXY_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_OSR_OSR_VIEW_PROXY_H_
|
2017-05-21 17:55:19 +00:00
|
|
|
|
2018-09-13 00:25:56 +00:00
|
|
|
#include <memory>
|
2017-05-21 17:55:19 +00:00
|
|
|
|
2023-05-11 20:07:39 +00:00
|
|
|
#include "base/memory/raw_ptr.h"
|
2017-05-21 17:55:19 +00:00
|
|
|
#include "third_party/skia/include/core/SkBitmap.h"
|
|
|
|
#include "ui/events/event.h"
|
|
|
|
#include "ui/gfx/geometry/rect.h"
|
|
|
|
#include "ui/views/view.h"
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
namespace electron {
|
2017-05-21 17:55:19 +00:00
|
|
|
|
|
|
|
class OffscreenViewProxy;
|
|
|
|
|
|
|
|
class OffscreenViewProxyObserver {
|
|
|
|
public:
|
|
|
|
virtual void OnProxyViewPaint(const gfx::Rect& damage_rect) = 0;
|
|
|
|
virtual void ProxyViewDestroyed(OffscreenViewProxy* proxy) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class OffscreenViewProxy {
|
|
|
|
public:
|
|
|
|
explicit OffscreenViewProxy(views::View* view);
|
|
|
|
~OffscreenViewProxy();
|
|
|
|
|
|
|
|
void SetObserver(OffscreenViewProxyObserver* observer);
|
|
|
|
void RemoveObserver();
|
|
|
|
|
|
|
|
const SkBitmap* GetBitmap() const;
|
|
|
|
void SetBitmap(const SkBitmap& bitmap);
|
|
|
|
|
|
|
|
const gfx::Rect& GetBounds();
|
|
|
|
void SetBounds(const gfx::Rect& bounds);
|
|
|
|
|
|
|
|
void OnEvent(ui::Event* event);
|
|
|
|
|
|
|
|
void ResetView() { view_ = nullptr; }
|
2018-04-18 01:44:10 +00:00
|
|
|
|
2017-05-21 17:55:19 +00:00
|
|
|
private:
|
2023-05-11 20:07:39 +00:00
|
|
|
raw_ptr<views::View> view_;
|
2017-05-21 17:55:19 +00:00
|
|
|
|
|
|
|
gfx::Rect view_bounds_;
|
|
|
|
std::unique_ptr<SkBitmap> view_bitmap_;
|
|
|
|
|
2023-05-11 20:07:39 +00:00
|
|
|
raw_ptr<OffscreenViewProxyObserver> observer_ = nullptr;
|
2017-05-21 17:55:19 +00:00
|
|
|
};
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|
2017-05-21 17:55:19 +00:00
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_OSR_OSR_VIEW_PROXY_H_
|