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

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

Issue 1564703005: Implement external stencil for Android WebView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, fix pixel tests Created 4 years, 11 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 "cc/output/output_surface_client.h" 7 #include "cc/output/output_surface_client.h"
8 #include "gpu/command_buffer/client/gles2_interface.h" 8 #include "gpu/command_buffer/client/gles2_interface.h"
9 9
10 namespace android_webview { 10 namespace android_webview {
11 11
12 ParentOutputSurface::ParentOutputSurface( 12 ParentOutputSurface::ParentOutputSurface(
13 scoped_refptr<cc::ContextProvider> context_provider) 13 scoped_refptr<cc::ContextProvider> context_provider)
14 : cc::OutputSurface(context_provider) { 14 : cc::OutputSurface(context_provider) {
15 stencil_state_.stencil_test_enabled = false;
15 } 16 }
16 17
17 ParentOutputSurface::~ParentOutputSurface() { 18 ParentOutputSurface::~ParentOutputSurface() {
18 } 19 }
19 20
20 void ParentOutputSurface::DidLoseOutputSurface() { 21 void ParentOutputSurface::DidLoseOutputSurface() {
21 // Android WebView does not handle context loss. 22 // Android WebView does not handle context loss.
22 LOG(FATAL) << "Render thread context loss"; 23 LOG(FATAL) << "Render thread context loss";
23 } 24 }
24 25
25 void ParentOutputSurface::Reshape(const gfx::Size& size, 26 void ParentOutputSurface::Reshape(const gfx::Size& size,
26 float scale_factor, 27 float scale_factor,
27 bool has_alpha) { 28 bool has_alpha) {
28 DCHECK_EQ(1.f, scale_factor); 29 DCHECK_EQ(1.f, scale_factor);
29 surface_size_ = size; 30 surface_size_ = size;
30 } 31 }
31 32
32 void ParentOutputSurface::SwapBuffers(cc::CompositorFrame* frame) { 33 void ParentOutputSurface::SwapBuffers(cc::CompositorFrame* frame) {
33 context_provider_->ContextGL()->ShallowFlushCHROMIUM(); 34 context_provider_->ContextGL()->ShallowFlushCHROMIUM();
34 client_->DidSwapBuffers(); 35 client_->DidSwapBuffers();
35 } 36 }
36 37
38 void ParentOutputSurface::ApplyExternalStencil() {
39 DCHECK(stencil_state_.stencil_test_enabled);
40 gpu::gles2::GLES2Interface* gl = context_provider()->ContextGL();
41 gl->StencilFuncSeparate(GL_FRONT, stencil_state_.stencil_front_func,
42 stencil_state_.stencil_front_mask,
43 stencil_state_.stencil_front_ref);
44 gl->StencilFuncSeparate(GL_BACK, stencil_state_.stencil_back_func,
45 stencil_state_.stencil_back_mask,
46 stencil_state_.stencil_back_ref);
47 gl->StencilMaskSeparate(GL_FRONT, stencil_state_.stencil_front_writemask);
48 gl->StencilMaskSeparate(GL_BACK, stencil_state_.stencil_back_writemask);
49 gl->StencilOpSeparate(GL_FRONT, stencil_state_.stencil_front_fail_op,
50 stencil_state_.stencil_front_z_fail_op,
51 stencil_state_.stencil_front_z_pass_op);
52 gl->StencilOpSeparate(GL_BACK, stencil_state_.stencil_back_fail_op,
53 stencil_state_.stencil_back_z_fail_op,
54 stencil_state_.stencil_back_z_pass_op);
55 }
56
57 void ParentOutputSurface::SetGLState(const ScopedAppGLStateRestore& gl_state) {
58 stencil_state_ = gl_state.stencil_state();
59 SetExternalStencilTest(stencil_state_.stencil_test_enabled);
60 }
61
37 } // namespace android_webview 62 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/parent_output_surface.h ('k') | android_webview/browser/scoped_app_gl_state_restore.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698