View.isHardwareAccelerated() ;//returns true if the View is attached to a hardware accelerated window. Canvas.isHardwareAccelerated();// returns true if the Canvas is hardware accelerated;
3、开启硬件加速之后,许多2D的绘制方法会抛出异常:
Canvas
clipPath() clipRegion() drawPicture() drawTextOnPath() drawVertices() Paint setLinearText() setMaskFilter() setRasterizer() Xfermodes AvoidXfermode PixelXorXfermode In addition, some operations behave differently with hardware acceleration enabled: Canvas clipRect(): XOR, Difference and ReverseDifference clip modes are ignored. 3D transforms do not apply to the clip rectangle drawBitmapMesh(): colors array is ignored Paint setDither(): ignored setFilterBitmap(): filtering is always on setShadowLayer(): works with text only PorterDuffXfermode PorterDuff.Mode.DARKEN will be equivalent to SRC_OVER when blending against the framebuffer. PorterDuff.Mode.LIGHTEN will be equivalent to SRC_OVER when blending against the framebuffer. PorterDuff.Mode.OVERLAY will be equivalent to SRC_OVER when blending against the framebuffer. ComposeShader ComposeShader can only contain shaders of different types (a BitmapShader and a LinearGradient for instance, but not two instances of BitmapShader ) ComposeShader cannot contain a ComposeShader