2017-05-21 11:55:19 -06: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 14:46:59 -06:00
|
|
|
#include "shell/browser/osr/osr_view_proxy.h"
|
2017-05-21 11:55:19 -06:00
|
|
|
|
2019-09-16 16:12:00 -06:00
|
|
|
#include <memory>
|
|
|
|
|
2019-06-19 15:23:04 -06:00
|
|
|
namespace electron {
|
2017-05-21 11:55:19 -06:00
|
|
|
|
2018-05-21 16:18:38 -06:00
|
|
|
OffscreenViewProxy::OffscreenViewProxy(views::View* view) : view_(view) {
|
2019-09-16 16:12:00 -06:00
|
|
|
view_bitmap_ = std::make_unique<SkBitmap>();
|
2017-05-21 11:55:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
OffscreenViewProxy::~OffscreenViewProxy() {
|
|
|
|
if (observer_) {
|
|
|
|
observer_->ProxyViewDestroyed(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OffscreenViewProxy::SetObserver(OffscreenViewProxyObserver* observer) {
|
|
|
|
if (observer_) {
|
|
|
|
observer_->ProxyViewDestroyed(this);
|
|
|
|
}
|
|
|
|
observer_ = observer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OffscreenViewProxy::RemoveObserver() {
|
|
|
|
observer_ = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OffscreenViewProxy::SetBitmap(const SkBitmap& bitmap) {
|
|
|
|
if (view_bounds_.width() == bitmap.width() &&
|
2018-04-17 19:55:30 -06:00
|
|
|
view_bounds_.height() == bitmap.height() && observer_) {
|
2019-09-16 16:12:00 -06:00
|
|
|
view_bitmap_ = std::make_unique<SkBitmap>(bitmap);
|
2017-05-21 11:55:19 -06:00
|
|
|
observer_->OnProxyViewPaint(view_bounds_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OffscreenViewProxy::SetBounds(const gfx::Rect& bounds) {
|
|
|
|
view_bounds_ = bounds;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OffscreenViewProxy::OnEvent(ui::Event* event) {
|
|
|
|
if (view_) {
|
|
|
|
view_->OnEvent(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-19 15:23:04 -06:00
|
|
|
} // namespace electron
|