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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewRenderView.java

Issue 2502763003: Introduce ViewRoot to forward input/view events to native (Closed)
Patch Set: tidy up Created 4 years 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.graphics.Color; 8 import android.graphics.Color;
9 import android.graphics.PixelFormat; 9 import android.graphics.PixelFormat;
10 import android.view.Surface; 10 import android.view.Surface;
11 import android.view.SurfaceHolder; 11 import android.view.SurfaceHolder;
12 import android.view.SurfaceView; 12 import android.view.SurfaceView;
13 import android.widget.FrameLayout; 13 import android.widget.FrameLayout;
14 14
15 import org.chromium.base.annotations.CalledByNative; 15 import org.chromium.base.annotations.CalledByNative;
16 import org.chromium.base.annotations.JNINamespace; 16 import org.chromium.base.annotations.JNINamespace;
17 import org.chromium.content_public.browser.WebContents; 17 import org.chromium.content_public.browser.WebContents;
18 import org.chromium.ui.base.EventHandler;
18 import org.chromium.ui.base.WindowAndroid; 19 import org.chromium.ui.base.WindowAndroid;
19 20
20 /*** 21 /***
21 * This view is used by a ContentView to render its content. 22 * This view is used by a ContentView to render its content.
22 * Call {@link #setCurrentContentViewCore(ContentViewCore)} with the contentView Core that should be 23 * Call {@link #setCurrentContentViewCore(ContentViewCore)} with the contentView Core that should be
23 * managing the view. 24 * managing the view.
24 * Note that only one ContentViewCore can be shown at a time. 25 * Note that only one ContentViewCore can be shown at a time.
25 */ 26 */
26 @JNINamespace("content") 27 @JNINamespace("content")
27 public class ContentViewRenderView extends FrameLayout { 28 public class ContentViewRenderView extends FrameLayout {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 assert rootWindow != null; 65 assert rootWindow != null;
65 mNativeContentViewRenderView = nativeInit(rootWindow.getNativePointer()) ; 66 mNativeContentViewRenderView = nativeInit(rootWindow.getNativePointer()) ;
66 assert mNativeContentViewRenderView != 0; 67 assert mNativeContentViewRenderView != 0;
67 mSurfaceCallback = new SurfaceHolder.Callback() { 68 mSurfaceCallback = new SurfaceHolder.Callback() {
68 @Override 69 @Override
69 public void surfaceChanged(SurfaceHolder holder, int format, int wid th, int height) { 70 public void surfaceChanged(SurfaceHolder holder, int format, int wid th, int height) {
70 assert mNativeContentViewRenderView != 0; 71 assert mNativeContentViewRenderView != 0;
71 nativeSurfaceChanged(mNativeContentViewRenderView, 72 nativeSurfaceChanged(mNativeContentViewRenderView,
72 format, width, height, holder.getSurface()); 73 format, width, height, holder.getSurface());
73 if (mContentViewCore != null) { 74 if (mContentViewCore != null) {
74 mContentViewCore.onPhysicalBackingSizeChanged( 75 getEventHandler().onPhysicalBackingSizeChanged(width, height );
75 width, height);
76 } 76 }
77 } 77 }
78 78
79 @Override 79 @Override
80 public void surfaceCreated(SurfaceHolder holder) { 80 public void surfaceCreated(SurfaceHolder holder) {
81 assert mNativeContentViewRenderView != 0; 81 assert mNativeContentViewRenderView != 0;
82 nativeSurfaceCreated(mNativeContentViewRenderView); 82 nativeSurfaceCreated(mNativeContentViewRenderView);
83 83
84 onReadyToRender(); 84 onReadyToRender();
85 } 85 }
86 86
87 @Override 87 @Override
88 public void surfaceDestroyed(SurfaceHolder holder) { 88 public void surfaceDestroyed(SurfaceHolder holder) {
89 assert mNativeContentViewRenderView != 0; 89 assert mNativeContentViewRenderView != 0;
90 nativeSurfaceDestroyed(mNativeContentViewRenderView); 90 nativeSurfaceDestroyed(mNativeContentViewRenderView);
91 } 91 }
92 }; 92 };
93 mSurfaceView.getHolder().addCallback(mSurfaceCallback); 93 mSurfaceView.getHolder().addCallback(mSurfaceCallback);
94 mSurfaceView.setVisibility(VISIBLE); 94 mSurfaceView.setVisibility(VISIBLE);
95 } 95 }
96 96
97 private EventHandler getEventHandler() {
98 return mContentViewCore.getWindowAndroid().getEventHandler();
99 }
100
97 /** 101 /**
98 * Sets the background color of the surface view. This method is necessary because the 102 * Sets the background color of the surface view. This method is necessary because the
99 * background color of ContentViewRenderView itself is covered by the backgr ound of 103 * background color of ContentViewRenderView itself is covered by the backgr ound of
100 * SurfaceView. 104 * SurfaceView.
101 * @param color The color of the background. 105 * @param color The color of the background.
102 */ 106 */
103 public void setSurfaceViewBackgroundColor(int color) { 107 public void setSurfaceViewBackgroundColor(int color) {
104 if (mSurfaceView != null) { 108 if (mSurfaceView != null) {
105 mSurfaceView.setBackgroundColor(color); 109 mSurfaceView.setBackgroundColor(color);
106 } 110 }
(...skipping 14 matching lines...) Expand all
121 mSurfaceView.getHolder().removeCallback(mSurfaceCallback); 125 mSurfaceView.getHolder().removeCallback(mSurfaceCallback);
122 nativeDestroy(mNativeContentViewRenderView); 126 nativeDestroy(mNativeContentViewRenderView);
123 mNativeContentViewRenderView = 0; 127 mNativeContentViewRenderView = 0;
124 } 128 }
125 129
126 public void setCurrentContentViewCore(ContentViewCore contentViewCore) { 130 public void setCurrentContentViewCore(ContentViewCore contentViewCore) {
127 assert mNativeContentViewRenderView != 0; 131 assert mNativeContentViewRenderView != 0;
128 mContentViewCore = contentViewCore; 132 mContentViewCore = contentViewCore;
129 133
130 if (mContentViewCore != null) { 134 if (mContentViewCore != null) {
131 mContentViewCore.onPhysicalBackingSizeChanged(getWidth(), getHeight( )); 135 getEventHandler().onPhysicalBackingSizeChanged(getWidth(), getHeight ());
132 nativeSetCurrentWebContents( 136 nativeSetCurrentWebContents(
133 mNativeContentViewRenderView, mContentViewCore.getWebContent s()); 137 mNativeContentViewRenderView, mContentViewCore.getWebContent s());
134 } else { 138 } else {
135 nativeSetCurrentWebContents(mNativeContentViewRenderView, null); 139 nativeSetCurrentWebContents(mNativeContentViewRenderView, null);
136 } 140 }
137 } 141 }
138 142
139 /** 143 /**
140 * This method should be subclassed to provide actions to be performed once the view is ready to 144 * This method should be subclassed to provide actions to be performed once the view is ready to
141 * render. 145 * render.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 private native void nativeDestroy(long nativeContentViewRenderView); 189 private native void nativeDestroy(long nativeContentViewRenderView);
186 private native void nativeSetCurrentWebContents( 190 private native void nativeSetCurrentWebContents(
187 long nativeContentViewRenderView, WebContents webContents); 191 long nativeContentViewRenderView, WebContents webContents);
188 private native void nativeSurfaceCreated(long nativeContentViewRenderView); 192 private native void nativeSurfaceCreated(long nativeContentViewRenderView);
189 private native void nativeSurfaceDestroyed(long nativeContentViewRenderView) ; 193 private native void nativeSurfaceDestroyed(long nativeContentViewRenderView) ;
190 private native void nativeSurfaceChanged(long nativeContentViewRenderView, 194 private native void nativeSurfaceChanged(long nativeContentViewRenderView,
191 int format, int width, int height, Surface surface); 195 int format, int width, int height, Surface surface);
192 private native void nativeSetOverlayVideoMode(long nativeContentViewRenderVi ew, 196 private native void nativeSetOverlayVideoMode(long nativeContentViewRenderVi ew,
193 boolean enabled); 197 boolean enabled);
194 } 198 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698