Chromium Code Reviews| Index: android_webview/browser/parent_output_surface.cc |
| diff --git a/android_webview/browser/parent_output_surface.cc b/android_webview/browser/parent_output_surface.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bab65b654e66ce4ec6ee0100bed18305826fddcd |
| --- /dev/null |
| +++ b/android_webview/browser/parent_output_surface.cc |
| @@ -0,0 +1,52 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "android_webview/browser/parent_output_surface.h" |
| + |
| +#include "cc/output/output_surface_client.h" |
| +#include "gpu/command_buffer/client/gles2_interface.h" |
| + |
| +namespace android_webview { |
| + |
| +ParentOutputSurface::ParentOutputSurface( |
| + scoped_refptr<cc::ContextProvider> context_provider) |
| + : cc::OutputSurface(context_provider), weak_factory_(this) { |
| + capabilities_.draw_and_swap_full_viewport_every_frame = true; |
| +} |
| + |
| +ParentOutputSurface::~ParentOutputSurface() { |
| +} |
| + |
| +bool ParentOutputSurface::BindToClient(cc::OutputSurfaceClient* client) { |
| + bool result = cc::OutputSurface::BindToClient(client); |
| + if (result) |
| + UpdateClientBeforeDraw(); |
|
danakj
2014/05/20 21:50:02
why? you call SetDrawConstraints before every Comp
|
| + return result; |
| +} |
| + |
| +void ParentOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { |
| + context_provider_->ContextGL()->ShallowFlushCHROMIUM(); |
|
danakj
2014/05/20 21:50:02
why?
boliu
2014/05/21 01:33:26
This is the "synchronous" behavior of parent compo
|
| + client_->DidSwapBuffers(); |
| +} |
| + |
| +base::WeakPtr<ParentOutputSurface> ParentOutputSurface::GetWeakPtr() { |
| + return weak_factory_.GetWeakPtr(); |
|
no sievers
2014/05/20 20:48:26
Any chance we can avoid the need for WeakPtr?
boliu
2014/05/21 01:33:26
It's really only needed for the DCHECK for the Upd
|
| +} |
| + |
| +void ParentOutputSurface::SetDrawConstraints(const gfx::Size& surface_size, |
| + const gfx::Rect& clip) { |
| + surface_size_ = surface_size; |
| + clip_ = clip; |
| + if (client_) |
|
danakj
2014/05/20 21:50:02
How would you get here with a null client, on the
boliu
2014/05/21 01:33:26
Done. Thanks for the suggestion :D
|
| + UpdateClientBeforeDraw(); |
| +} |
| + |
| +void ParentOutputSurface::UpdateClientBeforeDraw() { |
| + SetNeedsRedrawRect(gfx::Rect(surface_size_)); |
| + gfx::Transform identity; |
| + gfx::Rect empty; |
| + SetExternalDrawConstraints(identity, empty, clip_, true); |
| +} |
| + |
| +} // namespace android_webview |