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"
|
|
|
|
|
|
|
|
namespace electron {
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
2024-01-30 02:43:28 +00:00
|
|
|
const SkBitmap* bitmap() const { return view_bitmap_.get(); }
|
2017-05-21 17:55:19 +00:00
|
|
|
void SetBitmap(const SkBitmap& bitmap);
|
|
|
|
|
2024-01-30 02:43:28 +00:00
|
|
|
const gfx::Rect& bounds() { return view_bounds_; }
|
2017-05-21 17:55:19 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace electron
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_OSR_OSR_VIEW_PROXY_H_
|