Loading graphics/java/android/graphics/BitmapShader.java +7 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,12 @@ package android.graphics; * mirrored by setting the tiling mode. */ public class BitmapShader extends Shader { /** * Prevent garbage collection. */ @SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"}) private final Bitmap mBitmap; /** * Call this to create a new shader that will draw with a bitmap. * Loading @@ -29,6 +35,7 @@ public class BitmapShader extends Shader { * @param tileY The tiling mode for y to draw the bitmap in. */ public BitmapShader(Bitmap bitmap, TileMode tileX, TileMode tileY) { mBitmap = bitmap; final int b = bitmap.ni(); native_instance = nativeCreate(b, tileX.nativeInt, tileY.nativeInt); native_shader = nativePostCreate(native_instance, b, tileX.nativeInt, tileY.nativeInt); Loading libs/hwui/Matrix.cpp +19 −2 Original line number Diff line number Diff line Loading @@ -80,7 +80,7 @@ void Matrix4::load(const SkMatrix& v) { data[kScaleZ] = 1.0f; mSimpleMatrix = (!v[SkMatrix::kMPersp0] && !v[SkMatrix::kMPersp1] && !v[SkMatrix::kMPersp2]); mSimpleMatrix = (v.getType() <= SkMatrix::kScale_Mask); } void Matrix4::copyTo(SkMatrix& v) const { Loading Loading @@ -232,9 +232,26 @@ void Matrix4::loadOrtho(float left, float right, float bottom, float top, float data[kTranslateZ] = -(far + near) / (far - near); } #define MUL_ADD_STORE(a, b, c) a = (a) * (b) + (c) void Matrix4::mapPoint(float& x, float& y) const { if (mSimpleMatrix) { MUL_ADD_STORE(x, data[kScaleX], data[kTranslateX]); MUL_ADD_STORE(y, data[kScaleY], data[kTranslateY]); return; } float dx = x * data[kScaleX] + y * data[kSkewX] + data[kTranslateX]; float dy = x * data[kSkewY] + y * data[kScaleY] + data[kTranslateY]; float dz = x * data[kPerspective0] + y * data[kPerspective1] + data[kPerspective2]; if (dz) dz = 1.0f / dz; x = dx * dz; y = dy * dz; } void Matrix4::mapRect(Rect& r) const { if (mSimpleMatrix) { #define MUL_ADD_STORE(a, b, c) a = (a) * (b) + (c) MUL_ADD_STORE(r.left, data[kScaleX], data[kTranslateX]); MUL_ADD_STORE(r.right, data[kScaleX], data[kTranslateX]); MUL_ADD_STORE(r.top, data[kScaleY], data[kTranslateY]); Loading libs/hwui/Matrix.h +1 −3 Original line number Diff line number Diff line Loading @@ -104,10 +104,8 @@ public: void copyTo(float* v) const; void copyTo(SkMatrix& v) const; /** * Does not apply rotations! */ void mapRect(Rect& r) const; void mapPoint(float& x, float& y) const; float getTranslateX(); float getTranslateY(); Loading libs/hwui/SkiaShader.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -164,7 +164,8 @@ void SkiaLinearGradientShader::setupProgram(Program* program, const mat4& modelV Rect start(mBounds[0], mBounds[1], mBounds[2], mBounds[3]); if (mMatrix) { mat4 shaderMatrix(*mMatrix); shaderMatrix.mapRect(start); shaderMatrix.mapPoint(start.left, start.top); shaderMatrix.mapPoint(start.right, start.bottom); } snapshot.transform.mapRect(start); Loading Loading
graphics/java/android/graphics/BitmapShader.java +7 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,12 @@ package android.graphics; * mirrored by setting the tiling mode. */ public class BitmapShader extends Shader { /** * Prevent garbage collection. */ @SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"}) private final Bitmap mBitmap; /** * Call this to create a new shader that will draw with a bitmap. * Loading @@ -29,6 +35,7 @@ public class BitmapShader extends Shader { * @param tileY The tiling mode for y to draw the bitmap in. */ public BitmapShader(Bitmap bitmap, TileMode tileX, TileMode tileY) { mBitmap = bitmap; final int b = bitmap.ni(); native_instance = nativeCreate(b, tileX.nativeInt, tileY.nativeInt); native_shader = nativePostCreate(native_instance, b, tileX.nativeInt, tileY.nativeInt); Loading
libs/hwui/Matrix.cpp +19 −2 Original line number Diff line number Diff line Loading @@ -80,7 +80,7 @@ void Matrix4::load(const SkMatrix& v) { data[kScaleZ] = 1.0f; mSimpleMatrix = (!v[SkMatrix::kMPersp0] && !v[SkMatrix::kMPersp1] && !v[SkMatrix::kMPersp2]); mSimpleMatrix = (v.getType() <= SkMatrix::kScale_Mask); } void Matrix4::copyTo(SkMatrix& v) const { Loading Loading @@ -232,9 +232,26 @@ void Matrix4::loadOrtho(float left, float right, float bottom, float top, float data[kTranslateZ] = -(far + near) / (far - near); } #define MUL_ADD_STORE(a, b, c) a = (a) * (b) + (c) void Matrix4::mapPoint(float& x, float& y) const { if (mSimpleMatrix) { MUL_ADD_STORE(x, data[kScaleX], data[kTranslateX]); MUL_ADD_STORE(y, data[kScaleY], data[kTranslateY]); return; } float dx = x * data[kScaleX] + y * data[kSkewX] + data[kTranslateX]; float dy = x * data[kSkewY] + y * data[kScaleY] + data[kTranslateY]; float dz = x * data[kPerspective0] + y * data[kPerspective1] + data[kPerspective2]; if (dz) dz = 1.0f / dz; x = dx * dz; y = dy * dz; } void Matrix4::mapRect(Rect& r) const { if (mSimpleMatrix) { #define MUL_ADD_STORE(a, b, c) a = (a) * (b) + (c) MUL_ADD_STORE(r.left, data[kScaleX], data[kTranslateX]); MUL_ADD_STORE(r.right, data[kScaleX], data[kTranslateX]); MUL_ADD_STORE(r.top, data[kScaleY], data[kTranslateY]); Loading
libs/hwui/Matrix.h +1 −3 Original line number Diff line number Diff line Loading @@ -104,10 +104,8 @@ public: void copyTo(float* v) const; void copyTo(SkMatrix& v) const; /** * Does not apply rotations! */ void mapRect(Rect& r) const; void mapPoint(float& x, float& y) const; float getTranslateX(); float getTranslateY(); Loading
libs/hwui/SkiaShader.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -164,7 +164,8 @@ void SkiaLinearGradientShader::setupProgram(Program* program, const mat4& modelV Rect start(mBounds[0], mBounds[1], mBounds[2], mBounds[3]); if (mMatrix) { mat4 shaderMatrix(*mMatrix); shaderMatrix.mapRect(start); shaderMatrix.mapPoint(start.left, start.top); shaderMatrix.mapPoint(start.right, start.bottom); } snapshot.transform.mapRect(start); Loading