use of android.graphics.Picture in project android_frameworks_base by ParanoidAndroid.
the class WebViewClassic method setNewPicture.
void setNewPicture(final WebViewCore.DrawData draw, boolean updateBaseLayer) {
if (mNativeClass == 0) {
if (mDelaySetPicture != null) {
throw new IllegalStateException("Tried to setNewPicture with" + " a delay picture already set! (memory leak)");
}
// Not initialized yet, delay set
mDelaySetPicture = draw;
return;
}
WebViewCore.ViewState viewState = draw.mViewState;
boolean isPictureAfterFirstLayout = viewState != null;
if (updateBaseLayer) {
setBaseLayer(draw.mBaseLayer, getSettings().getShowVisualIndicator(), isPictureAfterFirstLayout);
}
final Point viewSize = draw.mViewSize;
// We update the layout (i.e. request a layout from the
// view system) if the last view size that we sent to
// WebCore matches the view size of the picture we just
// received in the fixed dimension.
final boolean updateLayout = viewSize.x == mLastWidthSent && viewSize.y == mLastHeightSent;
// Don't send scroll event for picture coming from webkit,
// since the new picture may cause a scroll event to override
// the saved history scroll position.
mSendScrollEvent = false;
recordNewContentSize(draw.mContentSize.x, draw.mContentSize.y, updateLayout);
if (isPictureAfterFirstLayout) {
// Reset the last sent data here since dealing with new page.
mLastWidthSent = 0;
mZoomManager.onFirstLayout(draw);
int scrollX = viewState.mShouldStartScrolledRight ? getContentWidth() : viewState.mScrollX;
int scrollY = viewState.mScrollY;
contentScrollTo(scrollX, scrollY, false);
if (!mDrawHistory) {
// As we are on a new page, hide the keyboard
hideSoftKeyboard();
}
}
mSendScrollEvent = true;
int functor = 0;
boolean forceInval = isPictureAfterFirstLayout;
ViewRootImpl viewRoot = mWebView.getViewRootImpl();
if (mWebView.isHardwareAccelerated() && mWebView.getLayerType() != View.LAYER_TYPE_SOFTWARE && viewRoot != null) {
functor = nativeGetDrawGLFunction(mNativeClass);
if (functor != 0) {
// force an invalidate if functor attach not successful
forceInval |= !viewRoot.attachFunctor(functor);
}
}
if (functor == 0 || forceInval || mWebView.getLayerType() != View.LAYER_TYPE_NONE) {
// invalidate the screen so that the next repaint will show new content
// TODO: partial invalidate
mWebView.invalidate();
}
// update the zoom information based on the new picture
if (mZoomManager.onNewPicture(draw))
invalidate();
if (isPictureAfterFirstLayout) {
mViewManager.postReadyToDrawAll();
}
scrollEditWithCursor();
if (mPictureListener != null) {
if (!mWebView.isHardwareAccelerated() || mWebView.getLayerType() == View.LAYER_TYPE_SOFTWARE) {
// trigger picture listener for software layers. Hardware layers are
// triggered in pageSwapCallback
Picture picture = mContext.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR2 ? capturePicture() : null;
mPictureListener.onNewPicture(getWebView(), picture);
}
}
}
use of android.graphics.Picture in project CustomShapeImageView by MostafaGazar.
the class SVGParser method parse.
private static SVG parse(InputStream in, Integer searchColor, Integer replaceColor, boolean whiteMode, int targetWidth, int targetHeight) throws SVGParseException {
// Util.debug("Parsing SVG...");
try {
long start = System.currentTimeMillis();
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
final Picture picture = new Picture();
SVGHandler handler = new SVGHandler(picture, targetWidth, targetHeight);
handler.setColorSwap(searchColor, replaceColor);
handler.setWhiteMode(whiteMode);
xr.setContentHandler(handler);
xr.parse(new InputSource(in));
// Util.debug("Parsing complete in " + (System.currentTimeMillis() - start) + " millis.");
SVG result = new SVG(picture, handler.bounds);
// Skip bounds if it was an empty pic
if (!Float.isInfinite(handler.limits.top)) {
result.setLimits(handler.limits);
}
return result;
} catch (Exception e) {
throw new SVGParseException(e);
}
}
use of android.graphics.Picture in project robotium by RobotiumTech.
the class ScreenshotTaker method getBitmapOfWebView.
/**
* Returns a bitmap of a given WebView.
*
* @param webView the webView to save a bitmap from
* @return a bitmap of the given web view
*
*/
private Bitmap getBitmapOfWebView(final WebView webView) {
Picture picture = webView.capturePicture();
Bitmap b = Bitmap.createBitmap(picture.getWidth(), picture.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
picture.draw(c);
return b;
}
use of android.graphics.Picture in project storymaker by StoryMaker.
the class OverlayCameraActivity method setOverlayImage.
private void setOverlayImage(int idx) {
try {
String groupPath = "images/overlays/svg/" + overlayGroup;
if (overlays == null)
overlays = getAssets().list(groupPath);
bitmap = Bitmap.createBitmap(mOverlayView.getWidth(), mOverlayView.getHeight(), Bitmap.Config.ARGB_8888);
canvas = new Canvas(bitmap);
String imgPath = groupPath + '/' + overlays[idx];
// SVG svg = SVGParser.getSVGFromAsset(getAssets(), "images/overlays/svg/" + overlays[idx],0xFFFFFF,0xCC0000);
SVG svg = SVGParser.getSVGFromAsset(getAssets(), imgPath);
Rect rBounds = new Rect(0, 0, mOverlayView.getWidth(), mOverlayView.getHeight());
Picture p = svg.getPicture();
canvas.drawPicture(p, rBounds);
mOverlayView.setImageBitmap(bitmap);
} catch (IOException ex) {
Timber.e(ex, "error rendering overlay", ex);
return;
}
}
use of android.graphics.Picture in project chromeview by pwnall.
the class JavaBrowserViewRendererHelper method recordBitmapIntoPicture.
/**
* Creates a new Picture that records drawing a provided bitmap.
* Will return an empty Picture if the Bitmap is null.
*/
@CalledByNative
private static Picture recordBitmapIntoPicture(Bitmap bitmap) {
Picture picture = new Picture();
if (bitmap != null) {
Canvas recordingCanvas = picture.beginRecording(bitmap.getWidth(), bitmap.getHeight());
drawBitmapIntoCanvas(bitmap, recordingCanvas);
picture.endRecording();
}
return picture;
}
Aggregations