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

Side by Side Diff: android_webview/java/src/org/chromium/android_webview/RenderHelper.java

Issue 12041009: [Android WebView] Migrate the rendering code to a separate set of classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1
2 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5
6 package org.chromium.android_webview;
7
8 import android.graphics.Bitmap;
9 import android.graphics.Canvas;
10 import android.graphics.Color;
11 import android.graphics.Picture;
12
13 import org.chromium.base.CalledByNative;
14 import org.chromium.base.JNINamespace;
15
16 import java.lang.ref.SoftReference;
17
18 /**
19 * Provides auxiliary methods related to Picture objects and native SkPictures.
20 */
21 @JNINamespace("android_webview")
22 public abstract class RenderHelper {
mkosiba (inactive) 2013/01/22 02:13:34 nit1: like in my other comment - you should probab
Leandro Graciá Gil 2013/01/22 08:18:46 Done.
23
24 // Cached bitmap used for auxiliary rasterization in rendering fallback mode s.
25 private static SoftReference<Bitmap> sBitmapCache;
26
27 /**
28 * Provides a Bitmap object with a given width and height used for auxiliary rasterization.
29 * Might reuse cached bitmaps.
30 */
31 @CalledByNative
32 private static Bitmap createBitmap(int width, int height) {
joth 2013/01/21 22:54:24 maybe createTemporaryBitmap? to reflect fact the
Leandro Graciá Gil 2013/01/22 08:18:46 Leaving as it is since we're removing the soft ref
33 Bitmap bitmap = sBitmapCache != null ? sBitmapCache.get() : null;
34 if (bitmap == null || bitmap.getWidth() != width || bitmap.getHeight() ! = height) {
35 bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888) ;
benm (inactive) 2013/01/21 20:34:49 in the case that bitmap != null, would bitmap.recy
joth 2013/01/21 22:54:24 In general this could be dangerous, as the caller
Leandro Graciá Gil 2013/01/22 08:18:46 Removing SoftReference as suggested.
36 bitmap.eraseColor(Color.BLACK);
37 sBitmapCache = new SoftReference<Bitmap>(bitmap);
38 }
39 return bitmap;
40 }
41
42 /**
43 * Draws a provided bitmap into a canvas.
44 * Used for convenience from the native side and other static helper methods .
45 */
46 @CalledByNative
47 private static void drawBitmapIntoCanvas(Bitmap bitmap, Canvas canvas) {
48 canvas.drawBitmap(bitmap, 0, 0, null);
49 }
50
51 /**
52 * Creates a new Picture that records drawing a provided bitmap.
53 */
54 @CalledByNative
55 private static Picture recordRasterizedBitmap(Bitmap bitmap) {
joth 2013/01/21 22:54:24 maybe clearer as createPictureFromBitmap or conver
Leandro Graciá Gil 2013/01/22 08:18:46 Using recordBitmapIntoPicture to make it consisten
56 Picture picture = new Picture();
57 Canvas recordingCanvas = picture.beginRecording(bitmap.getWidth(), bitma p.getHeight());
58 drawBitmapIntoCanvas(bitmap, recordingCanvas);
59 picture.endRecording();
60 return picture;
61 }
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698