Merge "Fix VectorDrawable_Delegate and DrawerLayout" into nyc-dev
This commit is contained in:
@@ -124,7 +124,7 @@ public class VectorDrawable_Delegate {
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
static void nDraw(long rendererPtr, long canvasWrapperPtr,
|
||||
static int nDraw(long rendererPtr, long canvasWrapperPtr,
|
||||
long colorFilterPtr, Rect bounds, boolean needsMirroring, boolean canReuseCache) {
|
||||
VPathRenderer_Delegate nativePathRenderer = VNativeObject.getDelegate(rendererPtr);
|
||||
|
||||
@@ -143,6 +143,8 @@ public class VectorDrawable_Delegate {
|
||||
nativePathRenderer.draw(canvasWrapperPtr, colorFilterPtr, bounds.width(), bounds.height());
|
||||
|
||||
Canvas_Delegate.native_restore(canvasWrapperPtr, true);
|
||||
|
||||
return bounds.width() * bounds.height();
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
|
||||
@@ -0,0 +1,303 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.layoutlib.bridge.android.graphics;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.NinePatch;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.Picture;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
|
||||
/**
|
||||
* Canvas implementation that does not do any rendering
|
||||
*/
|
||||
public class NopCanvas extends Canvas {
|
||||
public NopCanvas() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHardwareAccelerated() {
|
||||
// Return true so there is no allocations for the software renderer in the constructor
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save(int saveFlags) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveLayer(RectF bounds, Paint paint, int saveFlags) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveLayer(RectF bounds, Paint paint) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveLayer(float left, float top, float right, float bottom, Paint paint,
|
||||
int saveFlags) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveLayer(float left, float top, float right, float bottom, Paint paint) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveLayerAlpha(RectF bounds, int alpha, int saveFlags) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveLayerAlpha(RectF bounds, int alpha) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveLayerAlpha(float left, float top, float right, float bottom, int alpha,
|
||||
int saveFlags) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveLayerAlpha(float left, float top, float right, float bottom, int alpha) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restore() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSaveCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreToCount(int saveCount) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRGB(int r, int g, int b) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawARGB(int a, int r, int g, int b) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawColor(int color) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawColor(int color, Mode mode) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPaint(Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPoints(float[] pts, int offset, int count, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPoints(float[] pts, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPoint(float x, float y, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLine(float startX, float startY, float stopX, float stopY, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLines(float[] pts, int offset, int count, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLines(float[] pts, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRect(RectF rect, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRect(Rect r, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRect(float left, float top, float right, float bottom, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawOval(RectF oval, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawOval(float left, float top, float right, float bottom, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawCircle(float cx, float cy, float radius, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter,
|
||||
Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawArc(float left, float top, float right, float bottom, float startAngle,
|
||||
float sweepAngle, boolean useCenter, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRoundRect(RectF rect, float rx, float ry, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRoundRect(float left, float top, float right, float bottom, float rx, float ry,
|
||||
Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPath(Path path, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void throwIfCannotDraw(Bitmap bitmap) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPatch(NinePatch patch, Rect dst, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPatch(NinePatch patch, RectF dst, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBitmap(Bitmap bitmap, float left, float top, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBitmap(int[] colors, int offset, int stride, float x, float y, int width,
|
||||
int height, boolean hasAlpha, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBitmap(int[] colors, int offset, int stride, int x, int y, int width,
|
||||
int height, boolean hasAlpha, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBitmapMesh(Bitmap bitmap, int meshWidth, int meshHeight, float[] verts,
|
||||
int vertOffset, int[] colors, int colorOffset, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawVertices(VertexMode mode, int vertexCount, float[] verts, int vertOffset,
|
||||
float[] texs, int texOffset, int[] colors, int colorOffset, short[] indices,
|
||||
int indexOffset, int indexCount, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawText(char[] text, int index, int count, float x, float y, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawText(String text, float x, float y, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawText(String text, int start, int end, float x, float y, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawText(CharSequence text, int start, int end, float x, float y, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTextRun(char[] text, int index, int count, int contextIndex, int contextCount,
|
||||
float x, float y, boolean isRtl, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTextRun(CharSequence text, int start, int end, int contextStart, int contextEnd,
|
||||
float x, float y, boolean isRtl, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPosText(char[] text, int index, int count, float[] pos, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPosText(String text, float[] pos, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTextOnPath(char[] text, int index, int count, Path path, float hOffset,
|
||||
float vOffset, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPicture(Picture picture) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPicture(Picture picture, RectF dst) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPicture(Picture picture, Rect dst) {
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,7 @@ import com.android.layoutlib.bridge.android.BridgeContext;
|
||||
import com.android.layoutlib.bridge.android.BridgeLayoutParamsMapAttributes;
|
||||
import com.android.layoutlib.bridge.android.BridgeXmlBlockParser;
|
||||
import com.android.layoutlib.bridge.android.RenderParamsFlags;
|
||||
import com.android.layoutlib.bridge.android.graphics.NopCanvas;
|
||||
import com.android.layoutlib.bridge.android.support.DesignLibUtil;
|
||||
import com.android.layoutlib.bridge.impl.binding.FakeAdapter;
|
||||
import com.android.layoutlib.bridge.impl.binding.FakeExpandableAdapter;
|
||||
@@ -114,6 +115,8 @@ import static com.android.layoutlib.bridge.util.ReflectionUtils.isInstanceOf;
|
||||
*/
|
||||
public class RenderSessionImpl extends RenderAction<SessionParams> {
|
||||
|
||||
private static final Canvas NOP_CANVAS = new NopCanvas();
|
||||
|
||||
// scene state
|
||||
private RenderSession mScene;
|
||||
private BridgeXmlBlockParser mBlockParser;
|
||||
@@ -483,7 +486,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
||||
long initialTime = System_Delegate.nanoTime();
|
||||
if (!mFirstFrameExecuted) {
|
||||
// We need to run an initial draw call to initialize the animations
|
||||
render(getContext(), mViewRoot, mCanvas, 0, 0);
|
||||
render(getContext(), mViewRoot, NOP_CANVAS, mMeasuredScreenWidth, mMeasuredScreenHeight);
|
||||
|
||||
// The first frame will initialize the animations
|
||||
Choreographer_Delegate.doFrame(initialTime);
|
||||
|
||||
Reference in New Issue
Block a user