use of android.graphics.Picture in project glide by bumptech.
the class SvgDrawableTranscoder method transcode.
@Override
public Resource<PictureDrawable> transcode(Resource<SVG> toTranscode) {
SVG svg = toTranscode.get();
Picture picture = svg.renderToPicture();
PictureDrawable drawable = new PictureDrawable(picture);
return new SimpleResource<PictureDrawable>(drawable);
}
use of android.graphics.Picture in project android_frameworks_base by ParanoidAndroid.
the class WebViewClassic method capturePicture.
/**
* See {@link WebView#capturePicture()}
*/
@Override
public Picture capturePicture() {
if (mNativeClass == 0)
return null;
Picture result = new Picture();
nativeCopyBaseContentToPicture(result);
return result;
}
use of android.graphics.Picture in project android_frameworks_base by ParanoidAndroid.
the class WebViewClassic method pageSwapCallback.
/** Called by JNI when pages are swapped (only occurs with hardware
* acceleration) */
protected void pageSwapCallback(boolean notifyAnimationStarted) {
if (DebugFlags.MEASURE_PAGE_SWAP_FPS) {
long now = System.currentTimeMillis();
long diff = now - mLastSwapTime;
mAverageSwapFps = ((1000.0 / diff) + mAverageSwapFps) / 2;
Log.d(LOGTAG, "page swap fps: " + mAverageSwapFps);
mLastSwapTime = now;
}
mWebViewCore.resumeWebKitDraw();
if (notifyAnimationStarted) {
mWebViewCore.sendMessage(EventHub.NOTIFY_ANIMATION_STARTED);
}
if (mWebView instanceof PageSwapDelegate) {
// This provides a hook for ProfiledWebView to observe the tile page swaps.
((PageSwapDelegate) mWebView).onPageSwapOccurred(notifyAnimationStarted);
}
if (mPictureListener != null) {
// trigger picture listener for hardware layers. Software layers are
// triggered in setNewPicture
Picture picture = mContext.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR2 ? capturePicture() : null;
mPictureListener.onNewPicture(getWebView(), picture);
}
}
use of android.graphics.Picture in project android_frameworks_base by ParanoidAndroid.
the class WebViewClassic method savePicture.
/**
* See {@link WebView#savePicture(Bundle, File)}
*/
@Override
@Deprecated
public boolean savePicture(Bundle b, final File dest) {
if (dest == null || b == null) {
return false;
}
final Picture p = capturePicture();
// Use a temporary file while writing to ensure the destination file
// contains valid data.
final File temp = new File(dest.getPath() + ".writing");
new Thread(new Runnable() {
@Override
public void run() {
FileOutputStream out = null;
try {
out = new FileOutputStream(temp);
p.writeToStream(out);
// Writing the picture succeeded, rename the temporary file
// to the destination.
temp.renameTo(dest);
} catch (Exception e) {
// too late to do anything about it.
} finally {
if (out != null) {
try {
out.close();
} catch (Exception e) {
// Can't do anything about that
}
}
temp.delete();
}
}
}).start();
// now update the bundle
b.putInt("scrollX", getScrollX());
b.putInt("scrollY", getScrollY());
mZoomManager.saveZoomState(b);
return true;
}
use of android.graphics.Picture in project android_frameworks_base by ParanoidAndroid.
the class WebViewClassic method restorePicture.
/**
* See {@link WebView#restorePicture(Bundle, File)};
*/
@Override
@Deprecated
public boolean restorePicture(Bundle b, File src) {
if (src == null || b == null) {
return false;
}
if (!src.exists()) {
return false;
}
try {
final FileInputStream in = new FileInputStream(src);
final Bundle copy = new Bundle(b);
new Thread(new Runnable() {
@Override
public void run() {
try {
final Picture p = Picture.createFromStream(in);
if (p != null) {
// Post a runnable on the main thread to update the
// history picture fields.
mPrivateHandler.post(new Runnable() {
@Override
public void run() {
restoreHistoryPictureFields(p, copy);
}
});
}
} finally {
try {
in.close();
} catch (Exception e) {
// Nothing we can do now.
}
}
}
}).start();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return true;
}
Aggregations