OLD | NEW |
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.Bitmap; | |
9 import android.graphics.Canvas; | |
10 import android.graphics.Color; | 8 import android.graphics.Color; |
11 import android.graphics.PixelFormat; | 9 import android.graphics.PixelFormat; |
12 import android.view.Surface; | 10 import android.view.Surface; |
13 import android.view.SurfaceHolder; | 11 import android.view.SurfaceHolder; |
14 import android.view.SurfaceView; | 12 import android.view.SurfaceView; |
15 import android.widget.FrameLayout; | 13 import android.widget.FrameLayout; |
16 | 14 |
17 import org.chromium.base.CalledByNative; | 15 import org.chromium.base.CalledByNative; |
18 import org.chromium.base.JNINamespace; | 16 import org.chromium.base.JNINamespace; |
19 import org.chromium.ui.base.WindowAndroid; | 17 import org.chromium.ui.base.WindowAndroid; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 protected void onReadyToRender() { | 141 protected void onReadyToRender() { |
144 } | 142 } |
145 | 143 |
146 /** | 144 /** |
147 * This method could be subclassed optionally to provide a custom SurfaceVie
w object to | 145 * This method could be subclassed optionally to provide a custom SurfaceVie
w object to |
148 * this ContentViewRenderView. | 146 * this ContentViewRenderView. |
149 * @param context The context used to create the SurfaceView object. | 147 * @param context The context used to create the SurfaceView object. |
150 * @return The created SurfaceView object. | 148 * @return The created SurfaceView object. |
151 */ | 149 */ |
152 protected SurfaceView createSurfaceView(Context context) { | 150 protected SurfaceView createSurfaceView(Context context) { |
153 return new SurfaceView(context) { | 151 return new SurfaceView(context); |
154 @Override | |
155 public void onDraw(Canvas canvas) { | |
156 // We only need to draw to software canvases, which are used for
taking screenshots. | |
157 if (canvas.isHardwareAccelerated()) return; | |
158 Bitmap bitmap = Bitmap.createBitmap(getWidth(), getHeight(), | |
159 Bitmap.Config.ARGB_8888); | |
160 if (nativeCompositeToBitmap(mNativeContentViewRenderView, bitmap
)) { | |
161 canvas.drawBitmap(bitmap, 0, 0, null); | |
162 } | |
163 } | |
164 }; | |
165 } | 152 } |
166 | 153 |
167 /** | 154 /** |
168 * @return whether the surface view is initialized and ready to render. | 155 * @return whether the surface view is initialized and ready to render. |
169 */ | 156 */ |
170 public boolean isInitialized() { | 157 public boolean isInitialized() { |
171 return mSurfaceView.getHolder().getSurface() != null; | 158 return mSurfaceView.getHolder().getSurface() != null; |
172 } | 159 } |
173 | 160 |
174 /** | 161 /** |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 private native long nativeInit(long rootWindowNativePointer); | 194 private native long nativeInit(long rootWindowNativePointer); |
208 private native void nativeDestroy(long nativeContentViewRenderView); | 195 private native void nativeDestroy(long nativeContentViewRenderView); |
209 private native void nativeSetCurrentContentViewCore(long nativeContentViewRe
nderView, | 196 private native void nativeSetCurrentContentViewCore(long nativeContentViewRe
nderView, |
210 long nativeContentViewCore); | 197 long nativeContentViewCore); |
211 private native void nativeSetLayerTreeBuildHelper(long nativeContentViewRend
erView, | 198 private native void nativeSetLayerTreeBuildHelper(long nativeContentViewRend
erView, |
212 long buildHelperNativePtr); | 199 long buildHelperNativePtr); |
213 private native void nativeSurfaceCreated(long nativeContentViewRenderView); | 200 private native void nativeSurfaceCreated(long nativeContentViewRenderView); |
214 private native void nativeSurfaceDestroyed(long nativeContentViewRenderView)
; | 201 private native void nativeSurfaceDestroyed(long nativeContentViewRenderView)
; |
215 private native void nativeSurfaceChanged(long nativeContentViewRenderView, | 202 private native void nativeSurfaceChanged(long nativeContentViewRenderView, |
216 int format, int width, int height, Surface surface); | 203 int format, int width, int height, Surface surface); |
217 private native boolean nativeCompositeToBitmap(long nativeContentViewRenderV
iew, Bitmap bitmap); | |
218 private native void nativeSetOverlayVideoMode(long nativeContentViewRenderVi
ew, | 204 private native void nativeSetOverlayVideoMode(long nativeContentViewRenderVi
ew, |
219 boolean enabled); | 205 boolean enabled); |
220 } | 206 } |
OLD | NEW |