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

Unified Diff: android_webview/browser/in_process_view_renderer.cc

Issue 15851006: Move synchronous compositor into content/browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mkosiba comments1 Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: android_webview/browser/in_process_view_renderer.cc
diff --git a/android_webview/browser/in_process_renderer/in_process_view_renderer.cc b/android_webview/browser/in_process_view_renderer.cc
similarity index 95%
rename from android_webview/browser/in_process_renderer/in_process_view_renderer.cc
rename to android_webview/browser/in_process_view_renderer.cc
index 0121f11e45a7266a86c2a866160a07671539e3a4..b418ea0954bd0c3cc4b6e415e766e44d72549aa5 100644
--- a/android_webview/browser/in_process_renderer/in_process_view_renderer.cc
+++ b/android_webview/browser/in_process_view_renderer.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "android_webview/browser/in_process_renderer/in_process_view_renderer.h"
+#include "android_webview/browser/in_process_view_renderer.h"
#include <android/bitmap.h>
@@ -12,9 +12,9 @@
#include "base/debug/trace_event.h"
#include "base/logging.h"
#include "content/public/browser/android/content_view_core.h"
+#include "content/public/browser/android/synchronous_compositor.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/renderer/android/synchronous_compositor.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkDevice.h"
@@ -278,9 +278,8 @@ InProcessViewRenderer::InProcessViewRenderer(
}
InProcessViewRenderer::~InProcessViewRenderer() {
- if (compositor_)
- compositor_->SetClient(NULL);
SetContents(NULL);
+ DCHECK(compositor_ == NULL);
}
// static
@@ -289,33 +288,12 @@ InProcessViewRenderer* InProcessViewRenderer::FromWebContents(
return UserData::GetInstance(contents);
}
-// static
-InProcessViewRenderer* InProcessViewRenderer::FromId(int render_process_id,
- int render_view_id) {
- const content::RenderViewHost* rvh =
- content::RenderViewHost::FromID(render_process_id, render_view_id);
- if (!rvh) return NULL;
- return InProcessViewRenderer::FromWebContents(
- content::WebContents::FromRenderViewHost(rvh));
-}
-
-void InProcessViewRenderer::BindSynchronousCompositor(
- content::SynchronousCompositor* compositor) {
- DCHECK(compositor && compositor_ != compositor);
- if (compositor_)
- compositor_->SetClient(NULL);
- compositor_ = compositor;
- hardware_initialized_ = false;
- hardware_failed_ = false;
- compositor_->SetClient(this);
-
- if (attached_to_window_)
- client_->RequestProcessMode();
-}
-
void InProcessViewRenderer::SetContents(
content::ContentViewCore* content_view_core) {
// First remove association from the prior ContentViewCore / WebContents.
+ if (compositor_)
+ compositor_->SetClient(NULL);
+ compositor_ = NULL;
if (web_contents_) {
web_contents_->SetUserData(kUserDataKey, NULL);
DCHECK(!web_contents_); // WebContentsGone should have been called.
@@ -326,6 +304,10 @@ void InProcessViewRenderer::SetContents(
web_contents_ = content_view_core->GetWebContents();
web_contents_->SetUserData(kUserDataKey, new UserData(this));
+ content::SynchronousCompositor::GetOrCreateForWebContents(web_contents_)->
+ SetClient(this);
+ // Currently the logic in this class relies on |compositor_| remaining NULL
+ // until the DidInitializeCompositor() call, hence it is not set here.
}
void InProcessViewRenderer::WebContentsGone() {
@@ -549,12 +531,21 @@ gfx::Rect InProcessViewRenderer::GetScreenRect() {
return gfx::Rect(client_->GetLocationOnScreen(), gfx::Size(width_, height_));
}
+void InProcessViewRenderer::DidInitializeCompositor(
+ content::SynchronousCompositor* compositor) {
+ DCHECK(compositor && compositor_ == NULL);
+ compositor_ = compositor;
+ hardware_initialized_ = false;
+ hardware_failed_ = false;
+
+ if (attached_to_window_)
+ client_->RequestProcessMode();
+}
+
void InProcessViewRenderer::DidDestroyCompositor(
content::SynchronousCompositor* compositor) {
- // Allow for transient hand-over when two compositors may reference
- // a single client.
- if (compositor_ == compositor)
- compositor_ = NULL;
+ DCHECK(compositor_ == compositor);
+ compositor_ = NULL;
}
void InProcessViewRenderer::SetContinuousInvalidate(bool invalidate) {

Powered by Google App Engine
This is Rietveld 408576698