OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "android_webview/browser/parent_output_surface.h" | |
6 | |
7 #include "cc/output/output_surface_client.h" | |
8 #include "gpu/command_buffer/client/gles2_interface.h" | |
9 | |
10 namespace android_webview { | |
11 | |
12 ParentOutputSurface::ParentOutputSurface( | |
13 scoped_refptr<cc::ContextProvider> context_provider) | |
14 : cc::OutputSurface(context_provider), weak_factory_(this) { | |
15 capabilities_.draw_and_swap_full_viewport_every_frame = true; | |
16 } | |
17 | |
18 ParentOutputSurface::~ParentOutputSurface() { | |
19 } | |
20 | |
21 bool ParentOutputSurface::BindToClient(cc::OutputSurfaceClient* client) { | |
22 bool result = cc::OutputSurface::BindToClient(client); | |
23 if (result) | |
24 UpdateClientBeforeDraw(); | |
danakj
2014/05/20 21:50:02
why? you call SetDrawConstraints before every Comp
| |
25 return result; | |
26 } | |
27 | |
28 void ParentOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { | |
29 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
| |
30 client_->DidSwapBuffers(); | |
31 } | |
32 | |
33 base::WeakPtr<ParentOutputSurface> ParentOutputSurface::GetWeakPtr() { | |
34 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
| |
35 } | |
36 | |
37 void ParentOutputSurface::SetDrawConstraints(const gfx::Size& surface_size, | |
38 const gfx::Rect& clip) { | |
39 surface_size_ = surface_size; | |
40 clip_ = clip; | |
41 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
| |
42 UpdateClientBeforeDraw(); | |
43 } | |
44 | |
45 void ParentOutputSurface::UpdateClientBeforeDraw() { | |
46 SetNeedsRedrawRect(gfx::Rect(surface_size_)); | |
47 gfx::Transform identity; | |
48 gfx::Rect empty; | |
49 SetExternalDrawConstraints(identity, empty, clip_, true); | |
50 } | |
51 | |
52 } // namespace android_webview | |
OLD | NEW |