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

Side by Side Diff: android_webview/native/aw_contents.cc

Issue 414163002: aw: Add and use DrawGL kModeSync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make AwDrawGLInfo future proof Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 <limits> 7 #include <limits>
8 8
9 #include "android_webview/browser/aw_browser_context.h" 9 #include "android_webview/browser/aw_browser_context.h"
10 #include "android_webview/browser/aw_browser_main_parts.h" 10 #include "android_webview/browser/aw_browser_main_parts.h"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 jint GetNativeInstanceCount(JNIEnv* env, jclass) { 335 jint GetNativeInstanceCount(JNIEnv* env, jclass) {
336 return base::subtle::NoBarrier_Load(&g_instance_count); 336 return base::subtle::NoBarrier_Load(&g_instance_count);
337 } 337 }
338 338
339 jlong AwContents::GetAwDrawGLViewContext(JNIEnv* env, jobject obj) { 339 jlong AwContents::GetAwDrawGLViewContext(JNIEnv* env, jobject obj) {
340 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 340 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
341 return reinterpret_cast<intptr_t>(this); 341 return reinterpret_cast<intptr_t>(this);
342 } 342 }
343 343
344 void AwContents::DrawGL(AwDrawGLInfo* draw_info) { 344 void AwContents::DrawGL(AwDrawGLInfo* draw_info) {
345 if (draw_info->mode == AwDrawGLInfo::kModeSync) {
346 if (hardware_renderer_)
347 hardware_renderer_->CommitFrame();
hush (inactive) 2014/07/25 18:08:07 CommitFrame will just copy the child draw result (
boliu 2014/07/25 18:11:02 Everything above here is correct.
hush (inactive) 2014/07/25 18:31:00 Okay. Imagine a scenario where onDraw happens ever
boliu 2014/07/25 18:41:51 Yes. But "old frame" isn't a good charaterization.
348 return;
349 }
350
345 { 351 {
346 GLViewRendererManager* manager = GLViewRendererManager::GetInstance(); 352 GLViewRendererManager* manager = GLViewRendererManager::GetInstance();
347 base::AutoLock lock(render_thread_lock_); 353 base::AutoLock lock(render_thread_lock_);
348 if (renderer_manager_key_ != manager->NullKey()) { 354 if (renderer_manager_key_ != manager->NullKey()) {
349 manager->DidDrawGL(renderer_manager_key_); 355 manager->DidDrawGL(renderer_manager_key_);
350 } 356 }
351 } 357 }
352 358
353 ScopedAppGLStateRestore state_restore( 359 ScopedAppGLStateRestore state_restore(
354 draw_info->mode == AwDrawGLInfo::kModeDraw 360 draw_info->mode == AwDrawGLInfo::kModeDraw
355 ? ScopedAppGLStateRestore::MODE_DRAW 361 ? ScopedAppGLStateRestore::MODE_DRAW
356 : ScopedAppGLStateRestore::MODE_RESOURCE_MANAGEMENT); 362 : ScopedAppGLStateRestore::MODE_RESOURCE_MANAGEMENT);
357 ScopedAllowGL allow_gl; 363 ScopedAllowGL allow_gl;
358 364
359 if (shared_renderer_state_.IsInsideHardwareRelease()) { 365 if (shared_renderer_state_.IsInsideHardwareRelease()) {
360 hardware_renderer_.reset(); 366 hardware_renderer_.reset();
361 return; 367 return;
362 } 368 }
363 369
364 if (draw_info->mode != AwDrawGLInfo::kModeDraw) 370 if (draw_info->mode != AwDrawGLInfo::kModeDraw)
365 return; 371 return;
366 372
367 if (!hardware_renderer_) { 373 if (!hardware_renderer_) {
368 hardware_renderer_.reset(new HardwareRenderer(&shared_renderer_state_)); 374 hardware_renderer_.reset(new HardwareRenderer(&shared_renderer_state_));
375 hardware_renderer_->CommitFrame();
369 } 376 }
370 377
371 hardware_renderer_->DrawGL(state_restore.stencil_enabled(), 378 hardware_renderer_->DrawGL(state_restore.stencil_enabled(),
372 state_restore.framebuffer_binding_ext(), 379 state_restore.framebuffer_binding_ext(),
373 draw_info); 380 draw_info);
374 } 381 }
375 382
376 namespace { 383 namespace {
377 void DocumentHasImagesCallback(const ScopedJavaGlobalRef<jobject>& message, 384 void DocumentHasImagesCallback(const ScopedJavaGlobalRef<jobject>& message,
378 bool has_images) { 385 bool has_images) {
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 } 1151 }
1145 1152
1146 browser_view_renderer_.TrimMemory(level, visible); 1153 browser_view_renderer_.TrimMemory(level, visible);
1147 } 1154 }
1148 1155
1149 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) { 1156 void SetShouldDownloadFavicons(JNIEnv* env, jclass jclazz) {
1150 g_should_download_favicons = true; 1157 g_should_download_favicons = true;
1151 } 1158 }
1152 1159
1153 } // namespace android_webview 1160 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698