Skip to content

Commit

Permalink
aura: Support SurfaceDestroyed() on Android
Browse files Browse the repository at this point in the history
TBR=sky@chromium.org
BUG=513540

Review URL: https://codereview.chromium.org/1406333003

Cr-Commit-Position: refs/heads/master@{#354809}
  • Loading branch information
sievers authored and Commit bot committed Oct 19, 2015
1 parent 64e4009 commit 58f4336
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions components/mus/ws/display_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@ void DefaultDisplayManager::OnAcceleratedWidgetAvailable(
UpdateMetrics(metrics_.size_in_pixels.To<gfx::Size>(), device_pixel_ratio);
}

void DefaultDisplayManager::OnAcceleratedWidgetDestroyed() {
NOTREACHED();
}

void DefaultDisplayManager::OnActivationChanged(bool active) {}

} // namespace mus
1 change: 1 addition & 0 deletions components/mus/ws/display_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class DefaultDisplayManager : public DisplayManager,
void OnLostCapture() override;
void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget,
float device_pixel_ratio) override;
void OnAcceleratedWidgetDestroyed() override;
void OnActivationChanged(bool active) override;

mojo::ApplicationImpl* app_impl_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class TestPlatformWindowDelegate : public ui::PlatformWindowDelegate {
float device_pixel_ratio) override {
widget_ = widget;
}
void OnAcceleratedWidgetDestroyed() override {
NOTREACHED();
}
void OnActivationChanged(bool active) override {}

private:
Expand Down
4 changes: 4 additions & 0 deletions content/common/gpu/media/rendering_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ class RenderingHelper::StubOzoneDelegate : public ui::PlatformWindowDelegate {
accelerated_widget_ = widget;
}

void OnAcceleratedWidgetDestroyed() override {
NOTREACHED();
}

void OnActivationChanged(bool active) override {};

gfx::AcceleratedWidget accelerated_widget() const {
Expand Down
6 changes: 6 additions & 0 deletions ui/aura/window_tree_host_platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ void WindowTreeHostPlatform::OnAcceleratedWidgetAvailable(
WindowTreeHost::OnAcceleratedWidgetAvailable();
}

void WindowTreeHostPlatform::OnAcceleratedWidgetDestroyed() {
gfx::AcceleratedWidget widget = compositor()->ReleaseAcceleratedWidget();
DCHECK_EQ(widget, widget_);
widget_ = gfx::kNullAcceleratedWidget;
}

void WindowTreeHostPlatform::OnActivationChanged(bool active) {
if (active)
OnHostActivated();
Expand Down
1 change: 1 addition & 0 deletions ui/aura/window_tree_host_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class AURA_EXPORT WindowTreeHostPlatform
void OnLostCapture() override;
void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget,
float device_pixel_ratio) override;
void OnAcceleratedWidgetDestroyed() override;
void OnActivationChanged(bool active) override;

gfx::AcceleratedWidget widget_;
Expand Down
3 changes: 3 additions & 0 deletions ui/ozone/demo/ozone_demo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ class DemoWindow : public ui::PlatformWindowDelegate {
DCHECK_NE(widget, gfx::kNullAcceleratedWidget);
widget_ = widget;
}
void OnAcceleratedWidgetDestroyed() override {
NOTREACHED();
}
void OnActivationChanged(bool active) override {}

private:
Expand Down
2 changes: 1 addition & 1 deletion ui/platform_window/android/platform_window_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ void PlatformWindowAndroid::SurfaceCreated(JNIEnv* env,

void PlatformWindowAndroid::SurfaceDestroyed(JNIEnv* env, jobject obj) {
DCHECK(window_);
delegate_->OnAcceleratedWidgetDestroyed();
ReleaseWindow();
delegate_->OnAcceleratedWidgetAvailable(gfx::kNullAcceleratedWidget, 0.f);
}

void PlatformWindowAndroid::SurfaceSetSize(JNIEnv* env,
Expand Down
4 changes: 4 additions & 0 deletions ui/platform_window/platform_window_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class PlatformWindowDelegate {
virtual void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget,
float device_pixel_ratio) = 0;

// Notifies the delegate that the widget cannot be used anymore until
// a new widget is made available through OnAcceleratedWidgetAvailable().
virtual void OnAcceleratedWidgetDestroyed() = 0;

virtual void OnActivationChanged(bool active) = 0;
};

Expand Down

0 comments on commit 58f4336

Please sign in to comment.