OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/in_process_renderer/in_process_view_renderer.h
" | 5 #include "android_webview/browser/in_process_renderer/in_process_view_renderer.h
" |
6 | 6 |
7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 | 8 |
9 #include "android_webview/public/browser/draw_gl.h" | 9 #include "android_webview/public/browser/draw_gl.h" |
10 #include "android_webview/public/browser/draw_sw.h" | 10 #include "android_webview/public/browser/draw_sw.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 using content::Compositor; | 42 using content::Compositor; |
43 using content::ContentViewCore; | 43 using content::ContentViewCore; |
44 | 44 |
45 namespace android_webview { | 45 namespace android_webview { |
46 | 46 |
47 namespace { | 47 namespace { |
48 | 48 |
49 class GLStateRestore { | 49 class GLStateRestore { |
50 public: | 50 public: |
51 GLStateRestore() { | 51 GLStateRestore() { |
| 52 #if !defined(NDEBUG) |
| 53 { |
| 54 GLint vertex_array_buffer_binding; |
| 55 glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &vertex_array_buffer_binding); |
| 56 DCHECK_EQ(0, vertex_array_buffer_binding); |
| 57 |
| 58 GLint index_array_buffer_binding; |
| 59 glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, |
| 60 &index_array_buffer_binding); |
| 61 DCHECK_EQ(0, index_array_buffer_binding); |
| 62 } |
| 63 #endif // !defined(NDEBUG) |
52 glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, | 64 glGetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES, |
53 &texture_external_oes_binding_); | 65 &texture_external_oes_binding_); |
54 glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &vertex_array_buffer_binding_); | |
55 glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, | |
56 &index_array_buffer_binding_); | |
57 glGetIntegerv(GL_PACK_ALIGNMENT, &pack_alignment_); | 66 glGetIntegerv(GL_PACK_ALIGNMENT, &pack_alignment_); |
58 glGetIntegerv(GL_UNPACK_ALIGNMENT, &unpack_alignment_); | 67 glGetIntegerv(GL_UNPACK_ALIGNMENT, &unpack_alignment_); |
59 | 68 |
60 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(vertex_attrib_); ++i) { | 69 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(vertex_attrib_); ++i) { |
61 glGetVertexAttribiv( | 70 glGetVertexAttribiv( |
62 i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &vertex_attrib_[i].enabled); | 71 i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &vertex_attrib_[i].enabled); |
63 glGetVertexAttribiv( | 72 glGetVertexAttribiv( |
64 i, GL_VERTEX_ATTRIB_ARRAY_SIZE, &vertex_attrib_[i].size); | 73 i, GL_VERTEX_ATTRIB_ARRAY_SIZE, &vertex_attrib_[i].size); |
65 glGetVertexAttribiv( | 74 glGetVertexAttribiv( |
66 i, GL_VERTEX_ATTRIB_ARRAY_TYPE, &vertex_attrib_[i].type); | 75 i, GL_VERTEX_ATTRIB_ARRAY_TYPE, &vertex_attrib_[i].type); |
(...skipping 11 matching lines...) Expand all Loading... |
78 glGetBooleanv(GL_BLEND, &blend_enabled_); | 87 glGetBooleanv(GL_BLEND, &blend_enabled_); |
79 glGetIntegerv(GL_BLEND_SRC_RGB, &blend_src_rgb_); | 88 glGetIntegerv(GL_BLEND_SRC_RGB, &blend_src_rgb_); |
80 glGetIntegerv(GL_BLEND_SRC_ALPHA, &blend_src_alpha_); | 89 glGetIntegerv(GL_BLEND_SRC_ALPHA, &blend_src_alpha_); |
81 glGetIntegerv(GL_BLEND_DST_RGB, &blend_dest_rgb_); | 90 glGetIntegerv(GL_BLEND_DST_RGB, &blend_dest_rgb_); |
82 glGetIntegerv(GL_BLEND_DST_ALPHA, &blend_dest_alpha_); | 91 glGetIntegerv(GL_BLEND_DST_ALPHA, &blend_dest_alpha_); |
83 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture_); | 92 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture_); |
84 glGetIntegerv(GL_VIEWPORT, viewport_); | 93 glGetIntegerv(GL_VIEWPORT, viewport_); |
85 glGetBooleanv(GL_SCISSOR_TEST, &scissor_test_); | 94 glGetBooleanv(GL_SCISSOR_TEST, &scissor_test_); |
86 glGetIntegerv(GL_SCISSOR_BOX, scissor_box_); | 95 glGetIntegerv(GL_SCISSOR_BOX, scissor_box_); |
87 glGetIntegerv(GL_CURRENT_PROGRAM, ¤t_program_); | 96 glGetIntegerv(GL_CURRENT_PROGRAM, ¤t_program_); |
88 | |
89 DCHECK_EQ(0, vertex_array_buffer_binding_); | |
90 DCHECK_EQ(0, index_array_buffer_binding_); | |
91 } | 97 } |
92 | 98 |
93 ~GLStateRestore() { | 99 ~GLStateRestore() { |
94 glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_external_oes_binding_); | 100 glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_external_oes_binding_); |
95 glBindBuffer(GL_ARRAY_BUFFER, vertex_array_buffer_binding_); | |
96 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_array_buffer_binding_); | |
97 glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment_); | 101 glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment_); |
98 glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_alignment_); | 102 glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_alignment_); |
99 | 103 |
100 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(vertex_attrib_); ++i) { | 104 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(vertex_attrib_); ++i) { |
101 glVertexAttribPointer(i, | 105 glVertexAttribPointer(i, |
102 vertex_attrib_[i].size, | 106 vertex_attrib_[i].size, |
103 vertex_attrib_[i].type, | 107 vertex_attrib_[i].type, |
104 vertex_attrib_[i].normalized, | 108 vertex_attrib_[i].normalized, |
105 vertex_attrib_[i].stride, | 109 vertex_attrib_[i].stride, |
106 vertex_attrib_[i].pointer); | 110 vertex_attrib_[i].pointer); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 if (scissor_test_) { | 145 if (scissor_test_) { |
142 glEnable(GL_SCISSOR_TEST); | 146 glEnable(GL_SCISSOR_TEST); |
143 } else { | 147 } else { |
144 glDisable(GL_SCISSOR_TEST); | 148 glDisable(GL_SCISSOR_TEST); |
145 } | 149 } |
146 | 150 |
147 glScissor( | 151 glScissor( |
148 scissor_box_[0], scissor_box_[1], scissor_box_[2], scissor_box_[3]); | 152 scissor_box_[0], scissor_box_[1], scissor_box_[2], scissor_box_[3]); |
149 | 153 |
150 glUseProgram(current_program_); | 154 glUseProgram(current_program_); |
| 155 |
| 156 glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 157 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
151 } | 158 } |
152 | 159 |
153 private: | 160 private: |
154 GLint texture_external_oes_binding_; | 161 GLint texture_external_oes_binding_; |
155 GLint vertex_array_buffer_binding_; | |
156 GLint index_array_buffer_binding_; | |
157 GLint pack_alignment_; | 162 GLint pack_alignment_; |
158 GLint unpack_alignment_; | 163 GLint unpack_alignment_; |
159 | 164 |
160 struct { | 165 struct { |
161 GLint enabled; | 166 GLint enabled; |
162 GLint size; | 167 GLint size; |
163 GLint type; | 168 GLint type; |
164 GLint normalized; | 169 GLint normalized; |
165 GLint stride; | 170 GLint stride; |
166 GLvoid* pointer; | 171 GLvoid* pointer; |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 // TODO(joth): BrowserViewRendererImpl had a bunch of logic for dpi and page | 585 // TODO(joth): BrowserViewRendererImpl had a bunch of logic for dpi and page |
581 // scale here. Determine what if any needs bringing over to this class. | 586 // scale here. Determine what if any needs bringing over to this class. |
582 return CompositeSW(canvas); | 587 return CompositeSW(canvas); |
583 } | 588 } |
584 | 589 |
585 bool InProcessViewRenderer::CompositeSW(SkCanvas* canvas) { | 590 bool InProcessViewRenderer::CompositeSW(SkCanvas* canvas) { |
586 return compositor_ && compositor_->DemandDrawSw(canvas); | 591 return compositor_ && compositor_->DemandDrawSw(canvas); |
587 } | 592 } |
588 | 593 |
589 } // namespace android_webview | 594 } // namespace android_webview |
OLD | NEW |