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.
|
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#ifndef SHELL_BROWSER_OSR_OSR_VIEW_PROXY_H_
|
|
|
|
#define 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
|
|
|
|
|
|
|
#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:
|
|
|
|
views::View* view_;
|
|
|
|
|
|
|
|
gfx::Rect view_bounds_;
|
|
|
|
std::unique_ptr<SkBitmap> view_bitmap_;
|
|
|
|
|
2018-05-21 22:18:38 +00:00
|
|
|
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
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#endif // SHELL_BROWSER_OSR_OSR_VIEW_PROXY_H_
|