OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.graphics.Bitmap; | 7 import android.graphics.Bitmap; |
8 import android.graphics.Rect; | 8 import android.graphics.Rect; |
9 import android.util.SparseArray; | 9 import android.util.SparseArray; |
10 | 10 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 71 } |
72 | 72 |
73 /** | 73 /** |
74 * Asynchronously, generate and grab a bitmap representing what is currently
on the screen | 74 * Asynchronously, generate and grab a bitmap representing what is currently
on the screen |
75 * for {@code view}. | 75 * for {@code view}. |
76 * | 76 * |
77 * @param scale The scale that should be applied to the content. | 77 * @param scale The scale that should be applied to the content. |
78 * @param srcRect A subrect of the original content to capture. If this is
empty, it will grab | 78 * @param srcRect A subrect of the original content to capture. If this is
empty, it will grab |
79 * the whole surface. | 79 * the whole surface. |
80 * @param view The {@link ContentViewCore} to grab the bitmap from. | 80 * @param view The {@link ContentViewCore} to grab the bitmap from. |
| 81 * @param config The output content bitmap configuration. |
81 * @param callback The callback to be executed after readback completes. | 82 * @param callback The callback to be executed after readback completes. |
82 */ | 83 */ |
83 public void getContentBitmapAsync(float scale, Rect srcRect, ContentViewCore
view, | 84 public void getContentBitmapAsync(float scale, Rect srcRect, ContentViewCore
view, |
84 GetBitmapCallback callback) { | 85 Bitmap.Config config, GetBitmapCallback callback) { |
85 if (!readyForReadback()) { | 86 if (!readyForReadback()) { |
86 callback.onFinishGetBitmap(null); | 87 callback.onFinishGetBitmap(null); |
87 return; | 88 return; |
88 } | 89 } |
89 ThreadUtils.assertOnUiThread(); | 90 ThreadUtils.assertOnUiThread(); |
90 | 91 |
91 int readbackId = mNextReadbackId++; | 92 int readbackId = mNextReadbackId++; |
92 mGetBitmapRequests.put(readbackId, callback); | 93 mGetBitmapRequests.put(readbackId, callback); |
93 nativeGetContentBitmap(mNativeContentReadbackHandler, readbackId, scale, | 94 nativeGetContentBitmap(mNativeContentReadbackHandler, readbackId, scale, |
94 Bitmap.Config.ARGB_8888, srcRect.top, srcRect.left, srcRect.widt
h(), | 95 config, srcRect.top, srcRect.left, srcRect.width(), |
95 srcRect.height(), view); | 96 srcRect.height(), view); |
96 } | 97 } |
97 | 98 |
98 /** | 99 /** |
99 * Asynchronously, grab a bitmap of the current browser compositor root laye
r. | 100 * Asynchronously, grab a bitmap of the current browser compositor root laye
r. |
100 * | 101 * |
101 * @param windowAndroid The window that hosts the compositor. | 102 * @param windowAndroid The window that hosts the compositor. |
102 * @param callback The callback to be executed after readback completes
. | 103 * @param callback The callback to be executed after readback completes
. |
103 */ | 104 */ |
104 public void getCompositorBitmapAsync(WindowAndroid windowAndroid, GetBitmapC
allback callback) { | 105 public void getCompositorBitmapAsync(WindowAndroid windowAndroid, GetBitmapC
allback callback) { |
(...skipping 16 matching lines...) Expand all Loading... |
121 protected abstract boolean readyForReadback(); | 122 protected abstract boolean readyForReadback(); |
122 | 123 |
123 private native long nativeInit(); | 124 private native long nativeInit(); |
124 private native void nativeDestroy(long nativeContentReadbackHandler); | 125 private native void nativeDestroy(long nativeContentReadbackHandler); |
125 private native void nativeGetContentBitmap(long nativeContentReadbackHandler
, int readbackId, | 126 private native void nativeGetContentBitmap(long nativeContentReadbackHandler
, int readbackId, |
126 float scale, Bitmap.Config config, float x, float y, float width, fl
oat height, | 127 float scale, Bitmap.Config config, float x, float y, float width, fl
oat height, |
127 Object contentViewCore); | 128 Object contentViewCore); |
128 private native void nativeGetCompositorBitmap(long nativeContentReadbackHand
ler, | 129 private native void nativeGetCompositorBitmap(long nativeContentReadbackHand
ler, |
129 int readbackId, long nativeWindowAndroid); | 130 int readbackId, long nativeWindowAndroid); |
130 } | 131 } |
OLD | NEW |