Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: android_webview/browser/parent_output_surface.cc

Issue 2360423003: aw: Fix FBO restore in webview functor (Closed)
Patch Set: review Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "android_webview/browser/parent_output_surface.h" 5 #include "android_webview/browser/parent_output_surface.h"
6 6
7 #include "android_webview/browser/aw_render_thread_context_provider.h" 7 #include "android_webview/browser/aw_render_thread_context_provider.h"
8 #include "android_webview/browser/scoped_app_gl_state_restore.h"
8 #include "cc/output/compositor_frame.h" 9 #include "cc/output/compositor_frame.h"
9 #include "cc/output/output_surface_client.h" 10 #include "cc/output/output_surface_client.h"
10 #include "gpu/command_buffer/client/gles2_interface.h" 11 #include "gpu/command_buffer/client/gles2_interface.h"
11 12
12 namespace android_webview { 13 namespace android_webview {
13 14
14 ParentOutputSurface::ParentOutputSurface( 15 ParentOutputSurface::ParentOutputSurface(
15 scoped_refptr<AwRenderThreadContextProvider> context_provider) 16 scoped_refptr<AwRenderThreadContextProvider> context_provider)
16 : cc::OutputSurface(std::move(context_provider)) { 17 : cc::OutputSurface(std::move(context_provider)) {
17 stencil_state_.stencil_test_enabled = false;
18 } 18 }
19 19
20 ParentOutputSurface::~ParentOutputSurface() { 20 ParentOutputSurface::~ParentOutputSurface() {
21 } 21 }
22 22
23 void ParentOutputSurface::DidLoseOutputSurface() { 23 void ParentOutputSurface::DidLoseOutputSurface() {
24 // Android WebView does not handle context loss. 24 // Android WebView does not handle context loss.
25 LOG(FATAL) << "Render thread context loss"; 25 LOG(FATAL) << "Render thread context loss";
26 } 26 }
27 27
28 void ParentOutputSurface::Reshape(const gfx::Size& size, 28 void ParentOutputSurface::Reshape(const gfx::Size& size,
29 float scale_factor, 29 float scale_factor,
30 const gfx::ColorSpace& color_space, 30 const gfx::ColorSpace& color_space,
31 bool has_alpha) { 31 bool has_alpha) {
32 DCHECK_EQ(1.f, scale_factor); 32 DCHECK_EQ(1.f, scale_factor);
33 surface_size_ = size; 33 surface_size_ = size;
34 } 34 }
35 35
36 void ParentOutputSurface::SwapBuffers(cc::CompositorFrame frame) { 36 void ParentOutputSurface::SwapBuffers(cc::CompositorFrame frame) {
37 context_provider_->ContextGL()->ShallowFlushCHROMIUM(); 37 context_provider_->ContextGL()->ShallowFlushCHROMIUM();
38 } 38 }
39 39
40 bool ParentOutputSurface::HasExternalStencilTest() const { 40 bool ParentOutputSurface::HasExternalStencilTest() const {
41 return stencil_state_.stencil_test_enabled; 41 return ScopedAppGLStateRestore::Current()
42 ->stencil_state()
43 .stencil_test_enabled;
42 } 44 }
43 45
44 void ParentOutputSurface::ApplyExternalStencil() { 46 void ParentOutputSurface::ApplyExternalStencil() {
45 DCHECK(stencil_state_.stencil_test_enabled); 47 StencilState stencil_state =
48 ScopedAppGLStateRestore::Current()->stencil_state();
49 DCHECK(stencil_state.stencil_test_enabled);
46 gpu::gles2::GLES2Interface* gl = context_provider()->ContextGL(); 50 gpu::gles2::GLES2Interface* gl = context_provider()->ContextGL();
47 gl->StencilFuncSeparate(GL_FRONT, stencil_state_.stencil_front_func, 51 gl->StencilFuncSeparate(GL_FRONT, stencil_state.stencil_front_func,
48 stencil_state_.stencil_front_mask, 52 stencil_state.stencil_front_mask,
49 stencil_state_.stencil_front_ref); 53 stencil_state.stencil_front_ref);
50 gl->StencilFuncSeparate(GL_BACK, stencil_state_.stencil_back_func, 54 gl->StencilFuncSeparate(GL_BACK, stencil_state.stencil_back_func,
51 stencil_state_.stencil_back_mask, 55 stencil_state.stencil_back_mask,
52 stencil_state_.stencil_back_ref); 56 stencil_state.stencil_back_ref);
53 gl->StencilMaskSeparate(GL_FRONT, stencil_state_.stencil_front_writemask); 57 gl->StencilMaskSeparate(GL_FRONT, stencil_state.stencil_front_writemask);
54 gl->StencilMaskSeparate(GL_BACK, stencil_state_.stencil_back_writemask); 58 gl->StencilMaskSeparate(GL_BACK, stencil_state.stencil_back_writemask);
55 gl->StencilOpSeparate(GL_FRONT, stencil_state_.stencil_front_fail_op, 59 gl->StencilOpSeparate(GL_FRONT, stencil_state.stencil_front_fail_op,
56 stencil_state_.stencil_front_z_fail_op, 60 stencil_state.stencil_front_z_fail_op,
57 stencil_state_.stencil_front_z_pass_op); 61 stencil_state.stencil_front_z_pass_op);
58 gl->StencilOpSeparate(GL_BACK, stencil_state_.stencil_back_fail_op, 62 gl->StencilOpSeparate(GL_BACK, stencil_state.stencil_back_fail_op,
59 stencil_state_.stencil_back_z_fail_op, 63 stencil_state.stencil_back_z_fail_op,
60 stencil_state_.stencil_back_z_pass_op); 64 stencil_state.stencil_back_z_pass_op);
61 } 65 }
62 66
63 uint32_t ParentOutputSurface::GetFramebufferCopyTextureFormat() { 67 uint32_t ParentOutputSurface::GetFramebufferCopyTextureFormat() {
64 auto* gl = static_cast<AwRenderThreadContextProvider*>(context_provider()); 68 auto* gl = static_cast<AwRenderThreadContextProvider*>(context_provider());
65 return gl->GetCopyTextureInternalFormat(); 69 return gl->GetCopyTextureInternalFormat();
66 } 70 }
67 71
68 void ParentOutputSurface::SetGLState(const ScopedAppGLStateRestore& gl_state) {
69 stencil_state_ = gl_state.stencil_state();
70 }
71
72 } // namespace android_webview 72 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/parent_output_surface.h ('k') | android_webview/browser/render_thread_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698