OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.android_webview; |
| 6 |
| 7 import android.graphics.Bitmap; |
| 8 import android.graphics.Canvas; |
| 9 import android.graphics.Color; |
| 10 import android.graphics.Picture; |
| 11 |
| 12 import org.chromium.base.CalledByNative; |
| 13 import org.chromium.base.JNINamespace; |
| 14 |
| 15 /** |
| 16 * Provides auxiliary methods related to Picture objects and native SkPictures. |
| 17 */ |
| 18 @JNINamespace("android_webview") |
| 19 public class JavaBrowserViewRendererHelper { |
| 20 |
| 21 /** |
| 22 * Provides a Bitmap object with a given width and height used for auxiliary
rasterization. |
| 23 */ |
| 24 @CalledByNative |
| 25 private static Bitmap createBitmap(int width, int height) { |
| 26 return Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); |
| 27 } |
| 28 |
| 29 /** |
| 30 * Draws a provided bitmap into a canvas. |
| 31 * Used for convenience from the native side and other static helper methods
. |
| 32 */ |
| 33 @CalledByNative |
| 34 private static void drawBitmapIntoCanvas(Bitmap bitmap, Canvas canvas) { |
| 35 canvas.drawBitmap(bitmap, 0, 0, null); |
| 36 } |
| 37 |
| 38 /** |
| 39 * Creates a new Picture that records drawing a provided bitmap. |
| 40 * Will return an empty Picture if the Bitmap is null. |
| 41 */ |
| 42 @CalledByNative |
| 43 private static Picture recordBitmapIntoPicture(Bitmap bitmap) { |
| 44 Picture picture = new Picture(); |
| 45 if (bitmap != null) { |
| 46 Canvas recordingCanvas = picture.beginRecording(bitmap.getWidth(), b
itmap.getHeight()); |
| 47 drawBitmapIntoCanvas(bitmap, recordingCanvas); |
| 48 picture.endRecording(); |
| 49 } |
| 50 return picture; |
| 51 } |
| 52 |
| 53 // Should never be instantiated. |
| 54 private JavaBrowserViewRendererHelper() { |
| 55 } |
| 56 } |
OLD | NEW |