Chromium Code Reviews| 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" |
| 11 #include "base/android/jni_android.h" | 11 #include "base/android/jni_android.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "content/public/browser/android/content_view_core.h" | 13 #include "content/public/browser/android/content_view_core.h" |
| 14 #include "content/public/browser/render_view_host.h" | 14 #include "content/public/browser/render_view_host.h" |
| 15 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 16 #include "content/public/renderer/android/synchronous_compositor.h" | 16 #include "content/public/renderer/android/synchronous_compositor.h" |
| 17 #include "content/public/renderer/android/synchronous_input_event_handler.h" | |
| 17 #include "third_party/skia/include/core/SkBitmap.h" | 18 #include "third_party/skia/include/core/SkBitmap.h" |
| 18 #include "third_party/skia/include/core/SkCanvas.h" | 19 #include "third_party/skia/include/core/SkCanvas.h" |
| 19 #include "third_party/skia/include/core/SkDevice.h" | 20 #include "third_party/skia/include/core/SkDevice.h" |
| 20 #include "third_party/skia/include/core/SkGraphics.h" | 21 #include "third_party/skia/include/core/SkGraphics.h" |
| 21 #include "third_party/skia/include/core/SkPicture.h" | 22 #include "third_party/skia/include/core/SkPicture.h" |
| 22 #include "ui/gfx/size_conversions.h" | 23 #include "ui/gfx/size_conversions.h" |
| 23 #include "ui/gfx/transform.h" | 24 #include "ui/gfx/transform.h" |
| 24 #include "ui/gfx/vector2d_f.h" | 25 #include "ui/gfx/vector2d_f.h" |
| 25 #include "ui/gl/gl_bindings.h" | 26 #include "ui/gl/gl_bindings.h" |
| 26 | 27 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 return true; | 104 return true; |
| 104 } | 105 } |
| 105 | 106 |
| 106 } // namespace | 107 } // namespace |
| 107 | 108 |
| 108 InProcessViewRenderer::InProcessViewRenderer( | 109 InProcessViewRenderer::InProcessViewRenderer( |
| 109 BrowserViewRenderer::Client* client, | 110 BrowserViewRenderer::Client* client, |
| 110 JavaHelper* java_helper) | 111 JavaHelper* java_helper) |
| 111 : client_(client), | 112 : client_(client), |
| 112 java_helper_(java_helper), | 113 java_helper_(java_helper), |
| 114 content_view_core_(NULL), | |
| 113 web_contents_(NULL), | 115 web_contents_(NULL), |
| 114 compositor_(NULL), | 116 compositor_(NULL), |
| 117 input_event_handler_(NULL), | |
| 115 view_visible_(false), | 118 view_visible_(false), |
| 116 continuous_invalidate_(false), | 119 continuous_invalidate_(false), |
| 117 continuous_invalidate_task_pending_(false), | 120 continuous_invalidate_task_pending_(false), |
| 118 width_(0), | 121 width_(0), |
| 119 height_(0), | 122 height_(0), |
| 120 attached_to_window_(false), | 123 attached_to_window_(false), |
| 121 hardware_initialized_(false), | 124 hardware_initialized_(false), |
| 122 hardware_failed_(false), | 125 hardware_failed_(false), |
| 123 egl_context_at_init_(NULL), | 126 egl_context_at_init_(NULL), |
| 124 weak_factory_(this) { | 127 weak_factory_(this) { |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 153 compositor_->SetClient(NULL); | 156 compositor_->SetClient(NULL); |
| 154 compositor_ = compositor; | 157 compositor_ = compositor; |
| 155 hardware_initialized_ = false; | 158 hardware_initialized_ = false; |
| 156 hardware_failed_ = false; | 159 hardware_failed_ = false; |
| 157 compositor_->SetClient(this); | 160 compositor_->SetClient(this); |
| 158 | 161 |
| 159 if (attached_to_window_) | 162 if (attached_to_window_) |
| 160 client_->RequestProcessMode(); | 163 client_->RequestProcessMode(); |
| 161 } | 164 } |
| 162 | 165 |
| 166 void InProcessViewRenderer::BindSynchronousInputEventHandler( | |
| 167 content::SynchronousInputEventHandler* input_event_handler) { | |
| 168 input_event_handler_ = input_event_handler; | |
| 169 } | |
| 170 | |
| 163 void InProcessViewRenderer::SetContents( | 171 void InProcessViewRenderer::SetContents( |
| 164 content::ContentViewCore* content_view_core) { | 172 content::ContentViewCore* content_view_core) { |
| 165 // First remove association from the prior ContentViewCore / WebContents. | 173 // First remove association from the prior ContentViewCore / WebContents. |
| 174 if (content_view_core_) { | |
| 175 content_view_core_->SetInputEventFilterCallback( | |
| 176 ContentViewCore::InputEventFilterCallback()); | |
| 177 } | |
| 178 | |
| 166 if (web_contents_) { | 179 if (web_contents_) { |
| 167 web_contents_->SetUserData(kUserDataKey, NULL); | 180 web_contents_->SetUserData(kUserDataKey, NULL); |
| 168 DCHECK(!web_contents_); // WebContentsGone should have been called. | 181 DCHECK(!web_contents_); // WebContentsGone should have been called. |
| 169 } | 182 } |
| 170 | 183 |
| 171 if (!content_view_core) | 184 content_view_core_ = content_view_core; |
| 185 if (!content_view_core_) | |
| 172 return; | 186 return; |
| 173 | 187 |
| 188 content_view_core_->SetInputEventFilterCallback( | |
| 189 base::Bind(&InProcessViewRenderer::HandleInputEvent, | |
| 190 base::Unretained(this))); | |
|
jamesr
2013/05/24 23:46:16
what prevents this callback from being invoked aft
jdduke (slow)
2013/05/25 01:22:11
The assumption (which I should probably specify in
| |
| 191 | |
| 174 web_contents_ = content_view_core->GetWebContents(); | 192 web_contents_ = content_view_core->GetWebContents(); |
| 175 web_contents_->SetUserData(kUserDataKey, new UserData(this)); | 193 web_contents_->SetUserData(kUserDataKey, new UserData(this)); |
| 176 } | 194 } |
| 177 | 195 |
| 178 void InProcessViewRenderer::WebContentsGone() { | 196 void InProcessViewRenderer::WebContentsGone() { |
| 179 web_contents_ = NULL; | 197 web_contents_ = NULL; |
| 180 } | 198 } |
| 181 | 199 |
| 182 bool InProcessViewRenderer::PrepareDrawGL(int x, int y) { | 200 bool InProcessViewRenderer::PrepareDrawGL(int x, int y) { |
| 183 // No harm in updating |hw_rendering_scroll_| even if we return false. | 201 // No harm in updating |hw_rendering_scroll_| even if we return false. |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 422 bool InProcessViewRenderer::RenderSW(SkCanvas* canvas) { | 440 bool InProcessViewRenderer::RenderSW(SkCanvas* canvas) { |
| 423 // TODO(joth): BrowserViewRendererImpl had a bunch of logic for dpi and page | 441 // TODO(joth): BrowserViewRendererImpl had a bunch of logic for dpi and page |
| 424 // scale here. Determine what if any needs bringing over to this class. | 442 // scale here. Determine what if any needs bringing over to this class. |
| 425 return CompositeSW(canvas); | 443 return CompositeSW(canvas); |
| 426 } | 444 } |
| 427 | 445 |
| 428 bool InProcessViewRenderer::CompositeSW(SkCanvas* canvas) { | 446 bool InProcessViewRenderer::CompositeSW(SkCanvas* canvas) { |
| 429 return compositor_ && compositor_->DemandDrawSw(canvas); | 447 return compositor_ && compositor_->DemandDrawSw(canvas); |
| 430 } | 448 } |
| 431 | 449 |
| 450 content::InputEventAckState InProcessViewRenderer::HandleInputEvent( | |
| 451 int routing_id, | |
| 452 const WebKit::WebInputEvent& input_event) { | |
| 453 if (!input_event_handler_) | |
| 454 return content::INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | |
| 455 | |
| 456 return input_event_handler_->HandleInputEvent(routing_id, &input_event); | |
| 457 } | |
| 458 | |
| 459 | |
| 432 } // namespace android_webview | 460 } // namespace android_webview |
| OLD | NEW |