Skip to content

Commit

Permalink
[Android WebView] Migrate the rendering code to a separate set of cla…
Browse files Browse the repository at this point in the history
…sses.

It takes from https://codereview.chromium.org/11823027/
and assumes SW rendering and Capture Picture to be ready and enabled.

Most changes just move around code. The major structural changes are:
- Introduce a browser-layer view renderer interface and move the code to its implementation.
- Take out the rendering-related IPC to its own separate set of host/renderer classes.
- Change the way the view hierarchy and the compositor are initialized. Now they are created and set on BrowserViewRendererImpl construction.
- Content is now provided via a ContentViewCore object when initialized, updating the layer to use and the WebContents to observe.
- Remove/update the DEPS and gyp changes introduced to support rendering in the native layer.

BUG=167913,167908,161409
NOTRY=true

Review URL: https://chromiumcodereview.appspot.com/12041009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182710 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
leandrogracia@chromium.org committed Feb 15, 2013
1 parent b0ca197 commit 6f9281c
Show file tree
Hide file tree
Showing 24 changed files with 1,259 additions and 715 deletions.
1 change: 0 additions & 1 deletion android_webview/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ include_rules = [
"-android_webview/lib",

"!chrome/browser/component",
"+cc",
"+content/public/common",
"+jni",
"+net",
Expand Down
8 changes: 8 additions & 0 deletions android_webview/android_webview.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
'../components/components.gyp:web_contents_delegate_android',
'../content/content.gyp:content',
'../skia/skia.gyp:skia',
'../ui/gl/gl.gyp:gl',
'android_webview_pak',
],
'include_dirs': [
Expand Down Expand Up @@ -135,6 +136,9 @@
'browser/aw_request_interceptor.cc',
'browser/aw_request_interceptor.h',
'browser/aw_result_codes.h',
'browser/browser_view_renderer.h',
'browser/browser_view_renderer_impl.cc',
'browser/browser_view_renderer_impl.h',
'browser/find_helper.cc',
'browser/find_helper.h',
'browser/icon_helper.cc',
Expand All @@ -158,6 +162,8 @@
'browser/renderer_host/aw_render_view_host_ext.h',
'browser/renderer_host/aw_resource_dispatcher_host_delegate.cc',
'browser/renderer_host/aw_resource_dispatcher_host_delegate.h',
'browser/renderer_host/view_renderer_host.cc',
'browser/renderer_host/view_renderer_host.h',
'browser/scoped_allow_wait_for_legacy_web_view_api.h',
'browser/scoped_allow_wait_for_legacy_web_view_api.h',
'common/android_webview_message_generator.cc',
Expand All @@ -184,6 +190,8 @@
'renderer/aw_render_process_observer.h',
'renderer/aw_render_view_ext.cc',
'renderer/aw_render_view_ext.h',
'renderer/view_renderer.cc',
'renderer/view_renderer.h',
],
},
{
Expand Down
6 changes: 6 additions & 0 deletions android_webview/browser/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ include_rules = [
"-android_webview",
"+android_webview/browser",
"+android_webview/common",
"+android_webview/public/browser",

"+cc",

"+components/auto_login_parser",
"+components/navigation_interception",
"+components/visitedlink/browser",

"+content/public/browser",

"+ui/gfx",
"+ui/gl",

# Temporary until we bundle our own favicon. See
# AwContentBrowserClient::GetDefaultFavicon
"!grit/ui_resources.h",
Expand Down
95 changes: 95 additions & 0 deletions android_webview/browser/browser_view_renderer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_
#define ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_

#include "base/android/scoped_java_ref.h"

struct AwDrawGLInfo;

namespace content {
class ContentViewCore;
}

namespace gfx {
class Rect;
}

namespace android_webview {

// Interface for all the WebView-specific content rendering operations.
// Provides software and hardware rendering and the Capture Picture API.
class BrowserViewRenderer {
public:
class Client {
public:
// Called to trigger view invalidations.
virtual void Invalidate() = 0;

// Called when a new Picture is available. Needs to be enabled
// via the EnableOnNewPicture method.
virtual void OnNewPicture(
const base::android::JavaRef<jobject>& picture) = 0;

protected:
virtual ~Client() {}
};

// Delegate to perform rendering actions involving Java objects.
class JavaHelper {
public:
// Creates a RGBA_8888 Java Bitmap object of the requested size.
virtual base::android::ScopedJavaLocalRef<jobject> CreateBitmap(
JNIEnv* env,
int width,
int height) = 0;

// Draws the provided Java Bitmap into the provided Java Canvas.
virtual void DrawBitmapIntoCanvas(
JNIEnv* env,
const base::android::JavaRef<jobject>& jbitmap,
const base::android::JavaRef<jobject>& jcanvas) = 0;

// Creates a Java Picture object that records drawing the provided Bitmap.
virtual base::android::ScopedJavaLocalRef<jobject> RecordBitmapIntoPicture(
JNIEnv* env,
const base::android::JavaRef<jobject>& jbitmap) = 0;

protected:
virtual ~JavaHelper() {}
};

enum OnNewPictureMode {
kOnNewPictureDisabled = 0,
kOnNewPictureEnabled,
kOnNewPictureInvalidationOnly,
};

// Content control methods.
virtual void SetContents(content::ContentViewCore* content_view_core) = 0;

// Hardware rendering methods.
virtual void DrawGL(AwDrawGLInfo* draw_info) = 0;
virtual void SetScrollForHWFrame(int x, int y) = 0;

// Software rendering methods.
virtual bool DrawSW(jobject java_canvas, const gfx::Rect& clip_bounds) = 0;

// CapturePicture API methods.
virtual base::android::ScopedJavaLocalRef<jobject> CapturePicture() = 0;
virtual void EnableOnNewPicture(OnNewPictureMode mode) = 0;

// View update notifications.
virtual void OnVisibilityChanged(bool view_visible, bool window_visible) = 0;
virtual void OnSizeChanged(int width, int height) = 0;
virtual void OnAttachedToWindow(int width, int height) = 0;
virtual void OnDetachedFromWindow() = 0;

virtual ~BrowserViewRenderer() {}
};

} // namespace android_webview

#endif // ANDROID_WEBVIEW_BROWSER_BROWSER_VIEW_RENDERER_H_
Loading

0 comments on commit 6f9281c

Please sign in to comment.