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; | 8 import android.graphics.Bitmap; |
9 import android.graphics.Canvas; | 9 import android.graphics.Canvas; |
10 import android.graphics.Color; | 10 import android.graphics.Color; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 protected void onReadyToRender() { | 160 protected void onReadyToRender() { |
161 } | 161 } |
162 | 162 |
163 /** | 163 /** |
164 * This method could be subclassed optionally to provide a custom SurfaceVie
w object to | 164 * This method could be subclassed optionally to provide a custom SurfaceVie
w object to |
165 * this ContentViewRenderView. | 165 * this ContentViewRenderView. |
166 * @param context The context used to create the SurfaceView object. | 166 * @param context The context used to create the SurfaceView object. |
167 * @return The created SurfaceView object. | 167 * @return The created SurfaceView object. |
168 */ | 168 */ |
169 protected SurfaceView createSurfaceView(Context context) { | 169 protected SurfaceView createSurfaceView(Context context) { |
170 return new SurfaceView(context) { | 170 return new SurfaceView(context); |
171 @Override | |
172 public void onDraw(Canvas canvas) { | |
173 // We only need to draw to software canvases, which are used for
taking screenshots. | |
174 if (canvas.isHardwareAccelerated()) return; | |
175 Bitmap bitmap = Bitmap.createBitmap(getWidth(), getHeight(), | |
176 Bitmap.Config.ARGB_8888); | |
177 if (nativeCompositeToBitmap(mNativeContentViewRenderView, bitmap
)) { | |
178 canvas.drawBitmap(bitmap, 0, 0, null); | |
179 } | |
180 } | |
181 }; | |
182 } | 171 } |
183 | 172 |
184 /** | 173 /** |
185 * @return whether the surface view is initialized and ready to render. | 174 * @return whether the surface view is initialized and ready to render. |
186 */ | 175 */ |
187 public boolean isInitialized() { | 176 public boolean isInitialized() { |
188 return mSurfaceView.getHolder().getSurface() != null; | 177 return mSurfaceView.getHolder().getSurface() != null; |
189 } | 178 } |
190 | 179 |
191 /** | 180 /** |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 private native void nativeDestroy(long nativeContentViewRenderView); | 251 private native void nativeDestroy(long nativeContentViewRenderView); |
263 private native void nativeSetCurrentContentViewCore(long nativeContentViewRe
nderView, | 252 private native void nativeSetCurrentContentViewCore(long nativeContentViewRe
nderView, |
264 long nativeContentViewCore); | 253 long nativeContentViewCore); |
265 private native void nativeSetLayerTreeBuildHelper(long nativeContentViewRend
erView, | 254 private native void nativeSetLayerTreeBuildHelper(long nativeContentViewRend
erView, |
266 long buildHelperNativePtr); | 255 long buildHelperNativePtr); |
267 private native void nativeSurfaceCreated(long nativeContentViewRenderView); | 256 private native void nativeSurfaceCreated(long nativeContentViewRenderView); |
268 private native void nativeSurfaceDestroyed(long nativeContentViewRenderView)
; | 257 private native void nativeSurfaceDestroyed(long nativeContentViewRenderView)
; |
269 private native void nativeSurfaceChanged(long nativeContentViewRenderView, | 258 private native void nativeSurfaceChanged(long nativeContentViewRenderView, |
270 int format, int width, int height, Surface surface); | 259 int format, int width, int height, Surface surface); |
271 private native boolean nativeComposite(long nativeContentViewRenderView); | 260 private native boolean nativeComposite(long nativeContentViewRenderView); |
272 private native boolean nativeCompositeToBitmap(long nativeContentViewRenderV
iew, Bitmap bitmap); | |
273 private native void nativeSetOverlayVideoMode(long nativeContentViewRenderVi
ew, | 261 private native void nativeSetOverlayVideoMode(long nativeContentViewRenderVi
ew, |
274 boolean enabled); | 262 boolean enabled); |
275 } | 263 } |
OLD | NEW |