OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/native/aw_contents.h" | 5 #include "android_webview/native/aw_contents.h" |
6 | 6 |
7 #include <sys/system_properties.h> | |
8 | |
7 #include "android_webview/browser/aw_browser_main_parts.h" | 9 #include "android_webview/browser/aw_browser_main_parts.h" |
8 #include "android_webview/browser/net_disk_cache_remover.h" | 10 #include "android_webview/browser/net_disk_cache_remover.h" |
9 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" | 11 #include "android_webview/browser/renderer_host/aw_render_view_host_ext.h" |
10 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" | 12 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" |
11 #include "android_webview/common/aw_hit_test_data.h" | 13 #include "android_webview/common/aw_hit_test_data.h" |
12 #include "android_webview/native/aw_browser_dependency_factory.h" | 14 #include "android_webview/native/aw_browser_dependency_factory.h" |
13 #include "android_webview/native/aw_contents_io_thread_client_impl.h" | 15 #include "android_webview/native/aw_contents_io_thread_client_impl.h" |
14 #include "android_webview/native/aw_web_contents_delegate.h" | 16 #include "android_webview/native/aw_web_contents_delegate.h" |
15 #include "android_webview/native/state_serializer.h" | 17 #include "android_webview/native/state_serializer.h" |
16 #include "base/android/jni_android.h" | 18 #include "base/android/jni_android.h" |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
333 // The scrolling values of the Android Framework affect the transformation | 335 // The scrolling values of the Android Framework affect the transformation |
334 // matrix. This needs to be undone to let the compositor handle scrolling. | 336 // matrix. This needs to be undone to let the compositor handle scrolling. |
335 transform.Translate(last_scroll_x_, last_scroll_y_); | 337 transform.Translate(last_scroll_x_, last_scroll_y_); |
336 transform_layer_->setTransform(transform); | 338 transform_layer_->setTransform(transform); |
337 | 339 |
338 compositor_->Composite(); | 340 compositor_->Composite(); |
339 is_composite_pending_ = false; | 341 is_composite_pending_ = false; |
340 | 342 |
341 // TODO(leandrogracia): remove when crbug.com/164140 is closed. | 343 // TODO(leandrogracia): remove when crbug.com/164140 is closed. |
342 // --------------------------------------------------------------------------- | 344 // --------------------------------------------------------------------------- |
343 glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_external_oes_binding); | 345 char no_gl_restore_prop[PROP_VALUE_MAX]; |
344 glBindBuffer(GL_ARRAY_BUFFER, vertex_array_buffer_binding); | 346 __system_property_get("webview.chromium_no_gl_restore", no_gl_restore_prop); |
345 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_array_buffer_binding); | 347 if (!strcmp(no_gl_restore_prop, "true")) { |
348 LOG(WARNING) << "Android GL functor not restoring the previous GL state."; | |
joth
2012/12/20 02:52:18
could just return here instead?
(it maybe just the
Leandro GraciĆ” Gil
2012/12/20 03:32:14
We could, but I'd prefer to keep the block as much
| |
349 } else { | |
350 glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_external_oes_binding); | |
351 glBindBuffer(GL_ARRAY_BUFFER, vertex_array_buffer_binding); | |
352 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_array_buffer_binding); | |
346 | 353 |
347 glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment); | 354 glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment); |
348 glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_alignment); | 355 glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_alignment); |
349 | 356 |
350 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(vertex_attrib); ++i) { | 357 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(vertex_attrib); ++i) { |
351 glVertexAttribPointer(i, vertex_attrib[i].size, | 358 glVertexAttribPointer(i, vertex_attrib[i].size, |
352 vertex_attrib[i].type, vertex_attrib[i].normalized, | 359 vertex_attrib[i].type, vertex_attrib[i].normalized, |
353 vertex_attrib[i].stride, vertex_attrib[i].pointer); | 360 vertex_attrib[i].stride, vertex_attrib[i].pointer); |
354 | 361 |
355 if (vertex_attrib[i].enabled) | 362 if (vertex_attrib[i].enabled) |
356 glEnableVertexAttribArray(i); | 363 glEnableVertexAttribArray(i); |
364 else | |
365 glDisableVertexAttribArray(i); | |
366 } | |
367 | |
368 if (depth_test) | |
369 glEnable(GL_DEPTH_TEST); | |
357 else | 370 else |
358 glDisableVertexAttribArray(i); | 371 glDisable(GL_DEPTH_TEST); |
372 | |
373 if (cull_face) | |
374 glEnable(GL_CULL_FACE); | |
375 else | |
376 glDisable(GL_CULL_FACE); | |
377 | |
378 glColorMask(color_mask[0], color_mask[1], color_mask[2], | |
379 color_mask[3]); | |
380 | |
381 if (blend_enabled) | |
382 glEnable(GL_BLEND); | |
383 else | |
384 glDisable(GL_BLEND); | |
385 | |
386 glBlendFuncSeparate(blend_src_rgb, blend_dest_rgb, | |
387 blend_src_alpha, blend_dest_alpha); | |
388 | |
389 glActiveTexture(active_texture); | |
390 | |
391 glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); | |
392 | |
393 if (scissor_test) | |
394 glEnable(GL_SCISSOR_TEST); | |
395 else | |
396 glDisable(GL_SCISSOR_TEST); | |
397 | |
398 glScissor(scissor_box[0], scissor_box[1], scissor_box[2], | |
399 scissor_box[3]); | |
400 | |
401 glUseProgram(current_program); | |
359 } | 402 } |
360 | |
361 if (depth_test) | |
362 glEnable(GL_DEPTH_TEST); | |
363 else | |
364 glDisable(GL_DEPTH_TEST); | |
365 | |
366 if (cull_face) | |
367 glEnable(GL_CULL_FACE); | |
368 else | |
369 glDisable(GL_CULL_FACE); | |
370 | |
371 glColorMask(color_mask[0], color_mask[1], color_mask[2], | |
372 color_mask[3]); | |
373 | |
374 if (blend_enabled) | |
375 glEnable(GL_BLEND); | |
376 else | |
377 glDisable(GL_BLEND); | |
378 | |
379 glBlendFuncSeparate(blend_src_rgb, blend_dest_rgb, | |
380 blend_src_alpha, blend_dest_alpha); | |
381 | |
382 glActiveTexture(active_texture); | |
383 | |
384 glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); | |
385 | |
386 if (scissor_test) | |
387 glEnable(GL_SCISSOR_TEST); | |
388 else | |
389 glDisable(GL_SCISSOR_TEST); | |
390 | |
391 glScissor(scissor_box[0], scissor_box[1], scissor_box[2], | |
392 scissor_box[3]); | |
393 | |
394 glUseProgram(current_program); | |
395 // --------------------------------------------------------------------------- | 403 // --------------------------------------------------------------------------- |
396 } | 404 } |
397 | 405 |
398 jint AwContents::GetWebContents(JNIEnv* env, jobject obj) { | 406 jint AwContents::GetWebContents(JNIEnv* env, jobject obj) { |
399 return reinterpret_cast<jint>(web_contents_.get()); | 407 return reinterpret_cast<jint>(web_contents_.get()); |
400 } | 408 } |
401 | 409 |
402 void AwContents::DidInitializeContentViewCore(JNIEnv* env, jobject obj, | 410 void AwContents::DidInitializeContentViewCore(JNIEnv* env, jobject obj, |
403 jint content_view_core) { | 411 jint content_view_core) { |
404 ContentViewCore* core = reinterpret_cast<ContentViewCore*>(content_view_core); | 412 ContentViewCore* core = reinterpret_cast<ContentViewCore*>(content_view_core); |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
792 return; | 800 return; |
793 } | 801 } |
794 pending_contents_ = pending.Pass(); | 802 pending_contents_ = pending.Pass(); |
795 } | 803 } |
796 | 804 |
797 jint AwContents::ReleasePopupWebContents(JNIEnv* env, jobject obj) { | 805 jint AwContents::ReleasePopupWebContents(JNIEnv* env, jobject obj) { |
798 return reinterpret_cast<jint>(pending_contents_.release()); | 806 return reinterpret_cast<jint>(pending_contents_.release()); |
799 } | 807 } |
800 | 808 |
801 } // namespace android_webview | 809 } // namespace android_webview |
OLD | NEW |