Example #1
0
		/// <summary>Create a new compose shader, given shaders A, B, and a combining PorterDuff mode.
		/// 	</summary>
		/// <remarks>
		/// Create a new compose shader, given shaders A, B, and a combining PorterDuff mode.
		/// When the mode is applied, it will be given the result from shader A as its
		/// "dst", and the result from shader B as its "src".
		/// </remarks>
		/// <param name="shaderA">The colors from this shader are seen as the "dst" by the mode
		/// 	</param>
		/// <param name="shaderB">The colors from this shader are seen as the "src" by the mode
		/// 	</param>
		/// <param name="mode">The PorterDuff mode that combines the colors from the two shaders.
		/// 	</param>
		public ComposeShader(android.graphics.Shader shaderA, android.graphics.Shader shaderB
			, android.graphics.PorterDuff.Mode mode)
		{
			mShaderA = shaderA;
			mShaderB = shaderB;
			native_instance = nativeCreate2(shaderA.native_instance, shaderB.native_instance, 
				(int)mode);
			native_shader = nativePostCreate2(native_instance, shaderA.native_shader, shaderB
				.native_shader, (int)mode);
		}
Example #2
0
 /// <summary>Create a new compose shader, given shaders A, B, and a combining PorterDuff mode.
 ///     </summary>
 /// <remarks>
 /// Create a new compose shader, given shaders A, B, and a combining PorterDuff mode.
 /// When the mode is applied, it will be given the result from shader A as its
 /// "dst", and the result from shader B as its "src".
 /// </remarks>
 /// <param name="shaderA">The colors from this shader are seen as the "dst" by the mode
 ///     </param>
 /// <param name="shaderB">The colors from this shader are seen as the "src" by the mode
 ///     </param>
 /// <param name="mode">The PorterDuff mode that combines the colors from the two shaders.
 ///     </param>
 public ComposeShader(android.graphics.Shader shaderA, android.graphics.Shader shaderB
                      , android.graphics.PorterDuff.Mode mode)
 {
     mShaderA        = shaderA;
     mShaderB        = shaderB;
     native_instance = nativeCreate2(shaderA.native_instance, shaderB.native_instance,
                                     (int)mode);
     native_shader = nativePostCreate2(native_instance, shaderA.native_shader, shaderB
                                       .native_shader, (int)mode);
 }
Example #3
0
 public override void draw(android.graphics.Canvas canvas)
 {
     android.graphics.Bitmap bitmap = mBitmap;
     if (bitmap != null)
     {
         android.graphics.drawable.BitmapDrawable.BitmapState state = mBitmapState;
         if (state.mRebuildShader)
         {
             android.graphics.Shader.TileMode?tmx = state.mTileModeX;
             android.graphics.Shader.TileMode?tmy = state.mTileModeY;
             if (tmx == null && tmy == null)
             {
                 state.mPaint.setShader(null);
             }
             else
             {
                 state.mPaint.setShader(new android.graphics.BitmapShader(bitmap, tmx == null ? android.graphics.Shader.TileMode
                                                                          .CLAMP : tmx, tmy == null ? android.graphics.Shader.TileMode.CLAMP : tmy));
             }
             state.mRebuildShader = false;
             copyBounds(mDstRect);
         }
         android.graphics.Shader shader = state.mPaint.getShader();
         if (shader == null)
         {
             if (mApplyGravity)
             {
                 int layoutDirection = getResolvedLayoutDirectionSelf();
                 android.view.Gravity.apply(state.mGravity, mBitmapWidth, mBitmapHeight, getBounds
                                                (), mDstRect, layoutDirection);
                 mApplyGravity = false;
             }
             canvas.drawBitmap(bitmap, null, mDstRect, state.mPaint);
         }
         else
         {
             if (mApplyGravity)
             {
                 copyBounds(mDstRect);
                 mApplyGravity = false;
             }
             canvas.drawRect(mDstRect, state.mPaint);
         }
     }
 }
Example #4
0
		/// <summary>Create a new compose shader, given shaders A, B, and a combining mode.</summary>
		/// <remarks>
		/// Create a new compose shader, given shaders A, B, and a combining mode.
		/// When the mode is applied, it will be given the result from shader A as its
		/// "dst", and the result from shader B as its "src".
		/// </remarks>
		/// <param name="shaderA">The colors from this shader are seen as the "dst" by the mode
		/// 	</param>
		/// <param name="shaderB">The colors from this shader are seen as the "src" by the mode
		/// 	</param>
		/// <param name="mode">
		/// The mode that combines the colors from the two shaders. If mode
		/// is null, then SRC_OVER is assumed.
		/// </param>
		public ComposeShader(android.graphics.Shader shaderA, android.graphics.Shader shaderB
			, android.graphics.Xfermode mode)
		{
			mShaderA = shaderA;
			mShaderB = shaderB;
			native_instance = nativeCreate1(shaderA.native_instance, shaderB.native_instance, 
				(mode != null) ? mode.native_instance : null);
			if (mode is android.graphics.PorterDuffXfermode)
			{
				android.graphics.PorterDuff.Mode pdMode = ((android.graphics.PorterDuffXfermode)mode
					).mode;
				native_shader = nativePostCreate2(native_instance, shaderA.native_shader, shaderB
					.native_shader, pdMode != null ? (int)pdMode : 0);
			}
			else
			{
				native_shader = nativePostCreate1(native_instance, shaderA.native_shader, shaderB
					.native_shader, mode != null ? mode.native_instance : null);
			}
		}
Example #5
0
 /// <summary>Create a new compose shader, given shaders A, B, and a combining mode.</summary>
 /// <remarks>
 /// Create a new compose shader, given shaders A, B, and a combining mode.
 /// When the mode is applied, it will be given the result from shader A as its
 /// "dst", and the result from shader B as its "src".
 /// </remarks>
 /// <param name="shaderA">The colors from this shader are seen as the "dst" by the mode
 ///     </param>
 /// <param name="shaderB">The colors from this shader are seen as the "src" by the mode
 ///     </param>
 /// <param name="mode">
 /// The mode that combines the colors from the two shaders. If mode
 /// is null, then SRC_OVER is assumed.
 /// </param>
 public ComposeShader(android.graphics.Shader shaderA, android.graphics.Shader shaderB
                      , android.graphics.Xfermode mode)
 {
     mShaderA        = shaderA;
     mShaderB        = shaderB;
     native_instance = nativeCreate1(shaderA.native_instance, shaderB.native_instance,
                                     (mode != null) ? mode.native_instance : null);
     if (mode is android.graphics.PorterDuffXfermode)
     {
         android.graphics.PorterDuff.Mode pdMode = ((android.graphics.PorterDuffXfermode)mode
                                                    ).mode;
         native_shader = nativePostCreate2(native_instance, shaderA.native_shader, shaderB
                                           .native_shader, pdMode != null ? (int)pdMode : 0);
     }
     else
     {
         native_shader = nativePostCreate1(native_instance, shaderA.native_shader, shaderB
                                           .native_shader, mode != null ? mode.native_instance : null);
     }
 }
Example #6
0
		/// <summary>
		/// Set all class variables using current values from the given
		/// <see cref="Paint">Paint</see>
		/// .
		/// </summary>
		private void setClassVariablesFrom(android.graphics.Paint paint)
		{
			mColorFilter = paint.mColorFilter;
			mMaskFilter = paint.mMaskFilter;
			mPathEffect = paint.mPathEffect;
			mRasterizer = paint.mRasterizer;
			mShader = paint.mShader;
			mTypeface = paint.mTypeface;
			mXfermode = paint.mXfermode;
			mHasCompatScaling = paint.mHasCompatScaling;
			mCompatScaling = paint.mCompatScaling;
			mInvCompatScaling = paint.mInvCompatScaling;
			hasShadow = paint.hasShadow;
			shadowDx = paint.shadowDx;
			shadowDy = paint.shadowDy;
			shadowRadius = paint.shadowRadius;
			shadowColor = paint.shadowColor;
			mBidiFlags = paint.mBidiFlags;
		}
Example #7
0
		/// <summary>Set or clear the shader object.</summary>
		/// <remarks>
		/// Set or clear the shader object.
		/// <p />
		/// Pass null to clear any previous shader.
		/// As a convenience, the parameter passed is also returned.
		/// </remarks>
		/// <param name="shader">May be null. the new shader to be installed in the paint</param>
		/// <returns>shader</returns>
		public virtual android.graphics.Shader setShader(android.graphics.Shader shader)
		{
			android.graphics.Shader.NativeShader shaderNative = null;
			if (shader != null)
			{
				shaderNative = shader.native_instance;
			}
			native_setShader(mNativePaint, shaderNative);
			mShader = shader;
			return shader;
		}
Example #8
0
 public ComposeShader(android.graphics.Shader arg0, android.graphics.Shader arg1, android.graphics.PorterDuff.Mode arg2)  : base(global::MonoJavaBridge.JNIEnv.ThreadEnv)
 {
     global::MonoJavaBridge.JNIEnv         @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;
     global::MonoJavaBridge.JniLocalHandle handle = @__env.NewObject(android.graphics.ComposeShader.staticClass, global::android.graphics.ComposeShader._ComposeShader3304, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2));
     Init(@__env, handle);
 }