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

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

Issue 16255010: Hookup android_webview scroll offset delegation to Java side. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tests now pass Created 7 years, 6 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 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
299 299
300 InProcessViewRenderer::InProcessViewRenderer( 300 InProcessViewRenderer::InProcessViewRenderer(
301 BrowserViewRenderer::Client* client, 301 BrowserViewRenderer::Client* client,
302 JavaHelper* java_helper, 302 JavaHelper* java_helper,
303 content::WebContents* web_contents) 303 content::WebContents* web_contents)
304 : client_(client), 304 : client_(client),
305 java_helper_(java_helper), 305 java_helper_(java_helper),
306 web_contents_(web_contents), 306 web_contents_(web_contents),
307 compositor_(NULL), 307 compositor_(NULL),
308 view_visible_(false), 308 view_visible_(false),
309 dip_scale_(0.0),
309 continuous_invalidate_(false), 310 continuous_invalidate_(false),
310 block_invalidates_(false), 311 block_invalidates_(false),
311 width_(0), 312 width_(0),
312 height_(0), 313 height_(0),
313 attached_to_window_(false), 314 attached_to_window_(false),
314 hardware_initialized_(false), 315 hardware_initialized_(false),
315 hardware_failed_(false), 316 hardware_failed_(false),
316 last_egl_context_(NULL) { 317 last_egl_context_(NULL) {
317 CHECK(web_contents_); 318 CHECK(web_contents_);
318 web_contents_->SetUserData(kUserDataKey, new UserData(this)); 319 web_contents_->SetUserData(kUserDataKey, new UserData(this));
(...skipping 15 matching lines...) Expand all
334 return UserData::GetInstance(contents); 335 return UserData::GetInstance(contents);
335 } 336 }
336 337
337 void InProcessViewRenderer::WebContentsGone() { 338 void InProcessViewRenderer::WebContentsGone() {
338 web_contents_ = NULL; 339 web_contents_ = NULL;
339 compositor_ = NULL; 340 compositor_ = NULL;
340 } 341 }
341 342
342 bool InProcessViewRenderer::OnDraw(jobject java_canvas, 343 bool InProcessViewRenderer::OnDraw(jobject java_canvas,
343 bool is_hardware_canvas, 344 bool is_hardware_canvas,
344 const gfx::Point& scroll, 345 const gfx::Vector2d& scroll,
345 const gfx::Rect& clip) { 346 const gfx::Rect& clip) {
346 scroll_at_start_of_frame_ = scroll; 347 scroll_at_start_of_frame_ = scroll;
347 if (is_hardware_canvas && attached_to_window_ && compositor_ && 348 if (is_hardware_canvas && attached_to_window_ && compositor_ &&
348 HardwareEnabled() && client_->RequestDrawGL(java_canvas)) { 349 HardwareEnabled() && client_->RequestDrawGL(java_canvas)) {
349 // All set: we'll get a call on DrawGL when the time comes. 350 // All set: we'll get a call on DrawGL when the time comes.
350 return true; 351 return true;
351 } 352 }
352 // Perform a software draw 353 // Perform a software draw
353 block_invalidates_ = true; 354 block_invalidates_ = true;
354 bool result = DrawSWInternal(java_canvas, clip); 355 bool result = DrawSWInternal(java_canvas, clip);
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 TRACE_EVENT_INSTANT1("android_webview", 637 TRACE_EVENT_INSTANT1("android_webview",
637 "InProcessViewRenderer::SetContinuousInvalidate", 638 "InProcessViewRenderer::SetContinuousInvalidate",
638 TRACE_EVENT_SCOPE_THREAD, 639 TRACE_EVENT_SCOPE_THREAD,
639 "invalidate", 640 "invalidate",
640 invalidate); 641 invalidate);
641 continuous_invalidate_ = invalidate; 642 continuous_invalidate_ = invalidate;
642 // TODO(boliu): Handle if not attached to window case. 643 // TODO(boliu): Handle if not attached to window case.
643 EnsureContinuousInvalidation(NULL); 644 EnsureContinuousInvalidation(NULL);
644 } 645 }
645 646
647 void InProcessViewRenderer::SetDipScale(double dip_scale) {
648 dip_scale_ = dip_scale;
649 CHECK(dip_scale_ > 0);
650 }
651
652 void InProcessViewRenderer::ScrollTo(gfx::Vector2d new_value) {
653
joth 2013/06/19 05:34:45 nit: spurious \n
mkosiba (inactive) 2013/06/19 11:12:19 Done.
654 DCHECK(dip_scale_ > 0);
655 gfx::Vector2dF new_value_css(new_value.x() / dip_scale_,
656 new_value.y() / dip_scale_);
657 DCHECK(scroll_offset_css_ != new_value_css);
658
659 scroll_offset_css_ = new_value_css;
660
661 if (compositor_)
662 compositor_->DidChangeRootLayerScrollOffset();
663 }
664
646 void InProcessViewRenderer::SetTotalRootLayerScrollOffset( 665 void InProcessViewRenderer::SetTotalRootLayerScrollOffset(
647 gfx::Vector2dF new_value) { 666 gfx::Vector2dF new_value_css) {
648 // TODO(mkosiba): Plumb this all the way through to the view. 667 // TOOD(mkosiba): Add a DCHECK to say that this does _not_ get called during
649 scroll_offset_ = new_value; 668 // DrawGl when http://crbug.com/249972 is fixed.
669 bool value_changed = scroll_offset_css_ != new_value_css;
joth 2013/06/19 05:34:45 nit: local var really needed?
mkosiba (inactive) 2013/06/19 11:12:19 no, I forgot to remove it while restructuring the
670
671 if (!value_changed)
672 return;
673
674 scroll_offset_css_ = new_value_css;
675
676 DCHECK(dip_scale_ > 0);
677 gfx::Vector2d scroll_offset(scroll_offset_css_.x() * dip_scale_,
678 scroll_offset_css_.y() * dip_scale_);
679
680 client_->ScrollContainerViewTo(scroll_offset);
650 } 681 }
651 682
652 gfx::Vector2dF InProcessViewRenderer::GetTotalRootLayerScrollOffset() { 683 gfx::Vector2dF InProcessViewRenderer::GetTotalRootLayerScrollOffset() {
653 return scroll_offset_; 684 return scroll_offset_css_;
654 } 685 }
655 686
656 void InProcessViewRenderer::EnsureContinuousInvalidation( 687 void InProcessViewRenderer::EnsureContinuousInvalidation(
657 AwDrawGLInfo* draw_info) { 688 AwDrawGLInfo* draw_info) {
658 if (continuous_invalidate_ && !block_invalidates_) { 689 if (continuous_invalidate_ && !block_invalidates_) {
659 if (draw_info) { 690 if (draw_info) {
660 draw_info->dirty_left = draw_info->clip_left; 691 draw_info->dirty_left = draw_info->clip_left;
661 draw_info->dirty_top = draw_info->clip_top; 692 draw_info->dirty_top = draw_info->clip_top;
662 draw_info->dirty_right = draw_info->clip_right; 693 draw_info->dirty_right = draw_info->clip_right;
663 draw_info->dirty_bottom = draw_info->clip_bottom; 694 draw_info->dirty_bottom = draw_info->clip_bottom;
664 draw_info->status_mask |= AwDrawGLInfo::kStatusMaskDraw; 695 draw_info->status_mask |= AwDrawGLInfo::kStatusMaskDraw;
665 } else { 696 } else {
666 client_->PostInvalidate(); 697 client_->PostInvalidate();
667 } 698 }
668 block_invalidates_ = true; 699 block_invalidates_ = true;
669 } 700 }
670 } 701 }
671 702
672 bool InProcessViewRenderer::RenderSW(SkCanvas* canvas) { 703 bool InProcessViewRenderer::RenderSW(SkCanvas* canvas) {
673 // TODO(joth): BrowserViewRendererImpl had a bunch of logic for dpi and page 704 // TODO(joth): BrowserViewRendererImpl had a bunch of logic for dpi and page
674 // scale here. Determine what if any needs bringing over to this class. 705 // scale here. Determine what if any needs bringing over to this class.
675 return CompositeSW(canvas); 706 return CompositeSW(canvas);
676 } 707 }
677 708
678 bool InProcessViewRenderer::CompositeSW(SkCanvas* canvas) { 709 bool InProcessViewRenderer::CompositeSW(SkCanvas* canvas) {
679 return compositor_ && compositor_->DemandDrawSw(canvas); 710 return compositor_ && compositor_->DemandDrawSw(canvas);
680 } 711 }
681 712
682 } // namespace android_webview 713 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698