OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_view_renderer.h" | 5 #include "android_webview/browser/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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 } | 299 } |
300 | 300 |
301 InProcessViewRenderer::InProcessViewRenderer( | 301 InProcessViewRenderer::InProcessViewRenderer( |
302 BrowserViewRenderer::Client* client, | 302 BrowserViewRenderer::Client* client, |
303 JavaHelper* java_helper, | 303 JavaHelper* java_helper, |
304 content::WebContents* web_contents) | 304 content::WebContents* web_contents) |
305 : client_(client), | 305 : client_(client), |
306 java_helper_(java_helper), | 306 java_helper_(java_helper), |
307 web_contents_(web_contents), | 307 web_contents_(web_contents), |
308 compositor_(NULL), | 308 compositor_(NULL), |
309 view_visible_(false), | 309 visible_(false), |
310 dip_scale_(0.0), | 310 dip_scale_(0.0), |
311 continuous_invalidate_(false), | 311 continuous_invalidate_(false), |
312 block_invalidates_(false), | 312 block_invalidates_(false), |
313 width_(0), | 313 width_(0), |
314 height_(0), | 314 height_(0), |
315 attached_to_window_(false), | 315 attached_to_window_(false), |
316 hardware_initialized_(false), | 316 hardware_initialized_(false), |
317 hardware_failed_(false), | 317 hardware_failed_(false), |
318 last_egl_context_(NULL) { | 318 last_egl_context_(NULL) { |
319 CHECK(web_contents_); | 319 CHECK(web_contents_); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 block_invalidates_ = false; | 357 block_invalidates_ = false; |
358 EnsureContinuousInvalidation(NULL); | 358 EnsureContinuousInvalidation(NULL); |
359 return result; | 359 return result; |
360 } | 360 } |
361 | 361 |
362 void InProcessViewRenderer::DrawGL(AwDrawGLInfo* draw_info) { | 362 void InProcessViewRenderer::DrawGL(AwDrawGLInfo* draw_info) { |
363 if (!HardwareEnabled()) | 363 if (!HardwareEnabled()) |
364 return; | 364 return; |
365 | 365 |
366 TRACE_EVENT0("android_webview", "InProcessViewRenderer::DrawGL"); | 366 TRACE_EVENT0("android_webview", "InProcessViewRenderer::DrawGL"); |
367 DCHECK(view_visible_); | 367 DCHECK(visible_); |
368 | 368 |
369 // We need to watch if the current Android context has changed and enforce | 369 // We need to watch if the current Android context has changed and enforce |
370 // a clean-up in the compositor. | 370 // a clean-up in the compositor. |
371 EGLContext current_context = eglGetCurrentContext(); | 371 EGLContext current_context = eglGetCurrentContext(); |
372 if (!current_context) { | 372 if (!current_context) { |
373 TRACE_EVENT_INSTANT0( | 373 TRACE_EVENT_INSTANT0( |
374 "android_webview", "EarlyOut_NullEGLContext", TRACE_EVENT_SCOPE_THREAD); | 374 "android_webview", "EarlyOut_NullEGLContext", TRACE_EVENT_SCOPE_THREAD); |
375 return; | 375 return; |
376 } | 376 } |
377 | 377 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 base::Unretained(picture.get())))) { | 546 base::Unretained(picture.get())))) { |
547 return ScopedJavaLocalRef<jobject>(); | 547 return ScopedJavaLocalRef<jobject>(); |
548 } | 548 } |
549 | 549 |
550 return java_helper_->RecordBitmapIntoPicture(env, jbitmap); | 550 return java_helper_->RecordBitmapIntoPicture(env, jbitmap); |
551 } | 551 } |
552 | 552 |
553 void InProcessViewRenderer::EnableOnNewPicture(bool enabled) { | 553 void InProcessViewRenderer::EnableOnNewPicture(bool enabled) { |
554 } | 554 } |
555 | 555 |
556 void InProcessViewRenderer::OnVisibilityChanged(bool view_visible, | 556 void InProcessViewRenderer::OnVisibilityChanged(bool visible) { |
557 bool window_visible) { | 557 TRACE_EVENT_INSTANT1("android_webview", |
558 TRACE_EVENT_INSTANT2("android_webview", | |
559 "InProcessViewRenderer::OnVisibilityChanged", | 558 "InProcessViewRenderer::OnVisibilityChanged", |
560 TRACE_EVENT_SCOPE_THREAD, | 559 TRACE_EVENT_SCOPE_THREAD, |
561 "view_visible", | 560 "visible", |
562 view_visible, | 561 visible); |
563 "window_visible", | 562 visible_ = visible; |
564 window_visible); | |
565 view_visible_ = window_visible && view_visible; | |
566 } | 563 } |
567 | 564 |
568 void InProcessViewRenderer::OnSizeChanged(int width, int height) { | 565 void InProcessViewRenderer::OnSizeChanged(int width, int height) { |
569 TRACE_EVENT_INSTANT2("android_webview", | 566 TRACE_EVENT_INSTANT2("android_webview", |
570 "InProcessViewRenderer::OnSizeChanged", | 567 "InProcessViewRenderer::OnSizeChanged", |
571 TRACE_EVENT_SCOPE_THREAD, | 568 TRACE_EVENT_SCOPE_THREAD, |
572 "width", | 569 "width", |
573 width, | 570 width, |
574 "height", | 571 "height", |
575 height); | 572 height); |
(...skipping 20 matching lines...) Expand all Loading... |
596 "InProcessViewRenderer::OnDetachedFromWindow"); | 593 "InProcessViewRenderer::OnDetachedFromWindow"); |
597 // TODO(joth): Release GL resources. crbug.com/231986. | 594 // TODO(joth): Release GL resources. crbug.com/231986. |
598 attached_to_window_ = false; | 595 attached_to_window_ = false; |
599 } | 596 } |
600 | 597 |
601 bool InProcessViewRenderer::IsAttachedToWindow() { | 598 bool InProcessViewRenderer::IsAttachedToWindow() { |
602 return attached_to_window_; | 599 return attached_to_window_; |
603 } | 600 } |
604 | 601 |
605 bool InProcessViewRenderer::IsViewVisible() { | 602 bool InProcessViewRenderer::IsViewVisible() { |
606 return view_visible_; | 603 return visible_; |
607 } | 604 } |
608 | 605 |
609 gfx::Rect InProcessViewRenderer::GetScreenRect() { | 606 gfx::Rect InProcessViewRenderer::GetScreenRect() { |
610 return gfx::Rect(client_->GetLocationOnScreen(), gfx::Size(width_, height_)); | 607 return gfx::Rect(client_->GetLocationOnScreen(), gfx::Size(width_, height_)); |
611 } | 608 } |
612 | 609 |
613 void InProcessViewRenderer::DidInitializeCompositor( | 610 void InProcessViewRenderer::DidInitializeCompositor( |
614 content::SynchronousCompositor* compositor) { | 611 content::SynchronousCompositor* compositor) { |
615 TRACE_EVENT0("android_webview", | 612 TRACE_EVENT0("android_webview", |
616 "InProcessViewRenderer::DidInitializeCompositor"); | 613 "InProcessViewRenderer::DidInitializeCompositor"); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 // TODO(joth): BrowserViewRendererImpl had a bunch of logic for dpi and page | 707 // TODO(joth): BrowserViewRendererImpl had a bunch of logic for dpi and page |
711 // scale here. Determine what if any needs bringing over to this class. | 708 // scale here. Determine what if any needs bringing over to this class. |
712 return CompositeSW(canvas); | 709 return CompositeSW(canvas); |
713 } | 710 } |
714 | 711 |
715 bool InProcessViewRenderer::CompositeSW(SkCanvas* canvas) { | 712 bool InProcessViewRenderer::CompositeSW(SkCanvas* canvas) { |
716 return compositor_ && compositor_->DemandDrawSw(canvas); | 713 return compositor_ && compositor_->DemandDrawSw(canvas); |
717 } | 714 } |
718 | 715 |
719 } // namespace android_webview | 716 } // namespace android_webview |
OLD | NEW |