OLD | NEW |
---|---|
(Empty) | |
1 | |
2 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
joth
2013/02/06 20:26:31
nit: 2013
Leandro GraciĆ” Gil
2013/02/07 12:43:56
Done.
| |
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 /** | |
17 * Provides auxiliary methods related to Picture objects and native SkPictures. | |
18 */ | |
19 @JNINamespace("android_webview") | |
20 public class JavaBrowserViewRendererHelper { | |
21 | |
22 /** | |
23 * Provides a Bitmap object with a given width and height used for auxiliary rasterization. | |
24 */ | |
25 @CalledByNative | |
26 private static Bitmap createBitmap(int width, int height) { | |
27 return Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); | |
28 } | |
29 | |
30 /** | |
31 * Draws a provided bitmap into a canvas. | |
32 * Used for convenience from the native side and other static helper methods . | |
33 */ | |
34 @CalledByNative | |
35 private static void drawBitmapIntoCanvas(Bitmap bitmap, Canvas canvas) { | |
36 canvas.drawBitmap(bitmap, 0, 0, null); | |
37 } | |
38 | |
39 /** | |
40 * Creates a new Picture that records drawing a provided bitmap. | |
41 * Will return an empty Picture if the Bitmap is null. | |
42 */ | |
43 @CalledByNative | |
44 private static Picture recordBitmapIntoPicture(Bitmap bitmap) { | |
45 Picture picture = new Picture(); | |
46 if (bitmap != null) { | |
47 Canvas recordingCanvas = picture.beginRecording(bitmap.getWidth(), b itmap.getHeight()); | |
48 drawBitmapIntoCanvas(bitmap, recordingCanvas); | |
49 picture.endRecording(); | |
50 } | |
51 return picture; | |
52 } | |
53 | |
54 // Should never be instantiated. | |
55 private JavaBrowserViewRendererHelper() { | |
56 } | |
57 } | |
OLD | NEW |