Search in sources :

Example 1 with Picture

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);
}
Also used : SVG(com.caverock.androidsvg.SVG) Picture(android.graphics.Picture) PictureDrawable(android.graphics.drawable.PictureDrawable) SimpleResource(com.bumptech.glide.load.resource.SimpleResource)

Example 2 with Picture

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;
}
Also used : Picture(android.graphics.Picture)

Example 3 with Picture

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);
    }
}
Also used : Picture(android.graphics.Picture)

Example 4 with 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;
}
Also used : Picture(android.graphics.Picture) FileOutputStream(java.io.FileOutputStream) File(java.io.File) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 5 with Picture

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;
}
Also used : Bundle(android.os.Bundle) Picture(android.graphics.Picture) FileNotFoundException(java.io.FileNotFoundException) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

Picture (android.graphics.Picture)22 IOException (java.io.IOException)7 Canvas (android.graphics.Canvas)4 FileNotFoundException (java.io.FileNotFoundException)4 Bitmap (android.graphics.Bitmap)3 SAXParser (javax.xml.parsers.SAXParser)3 SAXParserFactory (javax.xml.parsers.SAXParserFactory)3 SAXException (org.xml.sax.SAXException)3 XMLReader (org.xml.sax.XMLReader)3 Bundle (android.os.Bundle)2 WebView (android.webkit.WebView)2 PictureListener (android.webkit.WebView.PictureListener)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 FileOutputStream (java.io.FileOutputStream)2 Test (org.junit.Test)2 InputSource (org.xml.sax.InputSource)2 Paint (android.graphics.Paint)1 Point (android.graphics.Point)1 Rect (android.graphics.Rect)1