Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Core / CSharp / System / Windows / Media / Generated / RenderDataDrawingContext.cs / 1 / RenderDataDrawingContext.cs
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
// This file was generated, please do not edit it directly.
//
// Please see http://wiki/default.aspx/Microsoft.Projects.Avalon/MilCodeGen.html for more information.
//
//---------------------------------------------------------------------------
using MS.Internal;
using MS.Internal.PresentationCore;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Windows.Threading;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Composition;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Diagnostics;
using SR=MS.Internal.PresentationCore.SR;
using SRID=MS.Internal.PresentationCore.SRID;
using System.Security;
using System.Security.Permissions;
namespace System.Windows.Media
{
///
/// RenderDataDrawingContext - A DrawingContext which produces a Drawing.
///
internal partial class RenderDataDrawingContext : DrawingContext
{
///
/// DrawLine -
/// Draws a line with the specified pen.
/// Note that this API does not accept a Brush, as there is no area to fill.
///
/// The Pen with which to stroke the line.
/// The start Point for the line.
/// The end Point for the line.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawLine(
Pen pen,
Point point0,
Point point1)
{
VerifyApiNonstructuralChange();
if (pen == null)
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawLine(const)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
MILCMD_DRAW_LINE record =
new MILCMD_DRAW_LINE (
_renderData.AddDependentResource(pen),
point0,
point1
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_LINE) == 40);
_renderData.WriteDataRecord(MILCMD.MilDrawLine,
(byte*)&record,
40 /* sizeof(MILCMD_DRAW_LINE) */);
}
}
///
/// DrawLine -
/// Draws a line with the specified pen.
/// Note that this API does not accept a Brush, as there is no area to fill.
///
/// The Pen with which to stroke the line.
/// The start Point for the line.
/// Optional AnimationClock for point0.
/// The end Point for the line.
/// Optional AnimationClock for point1.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawLine(
Pen pen,
Point point0,
AnimationClock point0Animations,
Point point1,
AnimationClock point1Animations)
{
VerifyApiNonstructuralChange();
if (pen == null)
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawLine(animate)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
UInt32 hPoint0Animations = CompositionResourceManager.InvalidResourceHandle;
UInt32 hPoint1Animations = CompositionResourceManager.InvalidResourceHandle;
hPoint0Animations = UseAnimations(point0, point0Animations);
hPoint1Animations = UseAnimations(point1, point1Animations);
MILCMD_DRAW_LINE_ANIMATE record =
new MILCMD_DRAW_LINE_ANIMATE (
_renderData.AddDependentResource(pen),
point0,
hPoint0Animations,
point1,
hPoint1Animations
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_LINE_ANIMATE) == 48);
_renderData.WriteDataRecord(MILCMD.MilDrawLineAnimate,
(byte*)&record,
48 /* sizeof(MILCMD_DRAW_LINE_ANIMATE) */);
}
}
///
/// DrawRectangle -
/// Draw a rectangle with the provided Brush and/or Pen.
/// If both the Brush and Pen are null this call is a no-op.
///
///
/// The Brush with which to fill the rectangle.
/// This is optional, and can be null, in which case no fill is performed.
///
///
/// The Pen with which to stroke the rectangle.
/// This is optional, and can be null, in which case no stroke is performed.
///
/// The Rect to fill and/or stroke.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawRectangle(
Brush brush,
Pen pen,
Rect rectangle)
{
VerifyApiNonstructuralChange();
if ((brush == null) && (pen == null))
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawRectangle(const)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
MILCMD_DRAW_RECTANGLE record =
new MILCMD_DRAW_RECTANGLE (
_renderData.AddDependentResource(brush),
_renderData.AddDependentResource(pen),
rectangle
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_RECTANGLE) == 40);
_renderData.WriteDataRecord(MILCMD.MilDrawRectangle,
(byte*)&record,
40 /* sizeof(MILCMD_DRAW_RECTANGLE) */);
}
}
///
/// DrawRectangle -
/// Draw a rectangle with the provided Brush and/or Pen.
/// If both the Brush and Pen are null this call is a no-op.
///
///
/// The Brush with which to fill the rectangle.
/// This is optional, and can be null, in which case no fill is performed.
///
///
/// The Pen with which to stroke the rectangle.
/// This is optional, and can be null, in which case no stroke is performed.
///
/// The Rect to fill and/or stroke.
/// Optional AnimationClock for rectangle.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawRectangle(
Brush brush,
Pen pen,
Rect rectangle,
AnimationClock rectangleAnimations)
{
VerifyApiNonstructuralChange();
if ((brush == null) && (pen == null))
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawRectangle(animate)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
UInt32 hRectangleAnimations = CompositionResourceManager.InvalidResourceHandle;
hRectangleAnimations = UseAnimations(rectangle, rectangleAnimations);
MILCMD_DRAW_RECTANGLE_ANIMATE record =
new MILCMD_DRAW_RECTANGLE_ANIMATE (
_renderData.AddDependentResource(brush),
_renderData.AddDependentResource(pen),
rectangle,
hRectangleAnimations
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_RECTANGLE_ANIMATE) == 48);
_renderData.WriteDataRecord(MILCMD.MilDrawRectangleAnimate,
(byte*)&record,
48 /* sizeof(MILCMD_DRAW_RECTANGLE_ANIMATE) */);
}
}
///
/// DrawRoundedRectangle -
/// Draw a rounded rectangle with the provided Brush and/or Pen.
/// If both the Brush and Pen are null this call is a no-op.
///
///
/// The Brush with which to fill the rectangle.
/// This is optional, and can be null, in which case no fill is performed.
///
///
/// The Pen with which to stroke the rectangle.
/// This is optional, and can be null, in which case no stroke is performed.
///
/// The Rect to fill and/or stroke.
///
/// The radius in the X dimension of the rounded corners of this
/// rounded Rect. This value will be clamped to the range [0..rectangle.Width/2]
///
///
/// The radius in the Y dimension of the rounded corners of this
/// rounded Rect. This value will be clamped to the range [0..rectangle.Height/2].
///
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawRoundedRectangle(
Brush brush,
Pen pen,
Rect rectangle,
Double radiusX,
Double radiusY)
{
VerifyApiNonstructuralChange();
if ((brush == null) && (pen == null))
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawRoundedRectangle(const)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
MILCMD_DRAW_ROUNDED_RECTANGLE record =
new MILCMD_DRAW_ROUNDED_RECTANGLE (
_renderData.AddDependentResource(brush),
_renderData.AddDependentResource(pen),
rectangle,
radiusX,
radiusY
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_ROUNDED_RECTANGLE) == 56);
_renderData.WriteDataRecord(MILCMD.MilDrawRoundedRectangle,
(byte*)&record,
56 /* sizeof(MILCMD_DRAW_ROUNDED_RECTANGLE) */);
}
}
///
/// DrawRoundedRectangle -
/// Draw a rounded rectangle with the provided Brush and/or Pen.
/// If both the Brush and Pen are null this call is a no-op.
///
///
/// The Brush with which to fill the rectangle.
/// This is optional, and can be null, in which case no fill is performed.
///
///
/// The Pen with which to stroke the rectangle.
/// This is optional, and can be null, in which case no stroke is performed.
///
/// The Rect to fill and/or stroke.
/// Optional AnimationClock for rectangle.
///
/// The radius in the X dimension of the rounded corners of this
/// rounded Rect. This value will be clamped to the range [0..rectangle.Width/2]
///
/// Optional AnimationClock for radiusX.
///
/// The radius in the Y dimension of the rounded corners of this
/// rounded Rect. This value will be clamped to the range [0..rectangle.Height/2].
///
/// Optional AnimationClock for radiusY.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawRoundedRectangle(
Brush brush,
Pen pen,
Rect rectangle,
AnimationClock rectangleAnimations,
Double radiusX,
AnimationClock radiusXAnimations,
Double radiusY,
AnimationClock radiusYAnimations)
{
VerifyApiNonstructuralChange();
if ((brush == null) && (pen == null))
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawRoundedRectangle(animate)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
UInt32 hRectangleAnimations = CompositionResourceManager.InvalidResourceHandle;
UInt32 hRadiusXAnimations = CompositionResourceManager.InvalidResourceHandle;
UInt32 hRadiusYAnimations = CompositionResourceManager.InvalidResourceHandle;
hRectangleAnimations = UseAnimations(rectangle, rectangleAnimations);
hRadiusXAnimations = UseAnimations(radiusX, radiusXAnimations);
hRadiusYAnimations = UseAnimations(radiusY, radiusYAnimations);
MILCMD_DRAW_ROUNDED_RECTANGLE_ANIMATE record =
new MILCMD_DRAW_ROUNDED_RECTANGLE_ANIMATE (
_renderData.AddDependentResource(brush),
_renderData.AddDependentResource(pen),
rectangle,
hRectangleAnimations,
radiusX,
hRadiusXAnimations,
radiusY,
hRadiusYAnimations
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_ROUNDED_RECTANGLE_ANIMATE) == 72);
_renderData.WriteDataRecord(MILCMD.MilDrawRoundedRectangleAnimate,
(byte*)&record,
72 /* sizeof(MILCMD_DRAW_ROUNDED_RECTANGLE_ANIMATE) */);
}
}
///
/// DrawEllipse -
/// Draw an ellipse with the provided Brush and/or Pen.
/// If both the Brush and Pen are null this call is a no-op.
///
///
/// The Brush with which to fill the ellipse.
/// This is optional, and can be null, in which case no fill is performed.
///
///
/// The Pen with which to stroke the ellipse.
/// This is optional, and can be null, in which case no stroke is performed.
///
///
/// The center of the ellipse to fill and/or stroke.
///
///
/// The radius in the X dimension of the ellipse.
/// The absolute value of the radius provided will be used.
///
///
/// The radius in the Y dimension of the ellipse.
/// The absolute value of the radius provided will be used.
///
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawEllipse(
Brush brush,
Pen pen,
Point center,
Double radiusX,
Double radiusY)
{
VerifyApiNonstructuralChange();
if ((brush == null) && (pen == null))
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawEllipse(const)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
MILCMD_DRAW_ELLIPSE record =
new MILCMD_DRAW_ELLIPSE (
_renderData.AddDependentResource(brush),
_renderData.AddDependentResource(pen),
center,
radiusX,
radiusY
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_ELLIPSE) == 40);
_renderData.WriteDataRecord(MILCMD.MilDrawEllipse,
(byte*)&record,
40 /* sizeof(MILCMD_DRAW_ELLIPSE) */);
}
}
///
/// DrawEllipse -
/// Draw an ellipse with the provided Brush and/or Pen.
/// If both the Brush and Pen are null this call is a no-op.
///
///
/// The Brush with which to fill the ellipse.
/// This is optional, and can be null, in which case no fill is performed.
///
///
/// The Pen with which to stroke the ellipse.
/// This is optional, and can be null, in which case no stroke is performed.
///
///
/// The center of the ellipse to fill and/or stroke.
///
/// Optional AnimationClock for center.
///
/// The radius in the X dimension of the ellipse.
/// The absolute value of the radius provided will be used.
///
/// Optional AnimationClock for radiusX.
///
/// The radius in the Y dimension of the ellipse.
/// The absolute value of the radius provided will be used.
///
/// Optional AnimationClock for radiusY.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawEllipse(
Brush brush,
Pen pen,
Point center,
AnimationClock centerAnimations,
Double radiusX,
AnimationClock radiusXAnimations,
Double radiusY,
AnimationClock radiusYAnimations)
{
VerifyApiNonstructuralChange();
if ((brush == null) && (pen == null))
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawEllipse(animate)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
UInt32 hCenterAnimations = CompositionResourceManager.InvalidResourceHandle;
UInt32 hRadiusXAnimations = CompositionResourceManager.InvalidResourceHandle;
UInt32 hRadiusYAnimations = CompositionResourceManager.InvalidResourceHandle;
hCenterAnimations = UseAnimations(center, centerAnimations);
hRadiusXAnimations = UseAnimations(radiusX, radiusXAnimations);
hRadiusYAnimations = UseAnimations(radiusY, radiusYAnimations);
MILCMD_DRAW_ELLIPSE_ANIMATE record =
new MILCMD_DRAW_ELLIPSE_ANIMATE (
_renderData.AddDependentResource(brush),
_renderData.AddDependentResource(pen),
center,
hCenterAnimations,
radiusX,
hRadiusXAnimations,
radiusY,
hRadiusYAnimations
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_ELLIPSE_ANIMATE) == 56);
_renderData.WriteDataRecord(MILCMD.MilDrawEllipseAnimate,
(byte*)&record,
56 /* sizeof(MILCMD_DRAW_ELLIPSE_ANIMATE) */);
}
}
///
/// DrawGeometry -
/// Draw a Geometry with the provided Brush and/or Pen.
/// If both the Brush and Pen are null this call is a no-op.
///
///
/// The Brush with which to fill the Geometry.
/// This is optional, and can be null, in which case no fill is performed.
///
///
/// The Pen with which to stroke the Geometry.
/// This is optional, and can be null, in which case no stroke is performed.
///
/// The Geometry to fill and/or stroke.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawGeometry(
Brush brush,
Pen pen,
Geometry geometry)
{
VerifyApiNonstructuralChange();
if (((brush == null) && (pen == null)) || (geometry == null))
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawGeometry(const)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
MILCMD_DRAW_GEOMETRY record =
new MILCMD_DRAW_GEOMETRY (
_renderData.AddDependentResource(brush),
_renderData.AddDependentResource(pen),
_renderData.AddDependentResource(geometry)
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_GEOMETRY) == 16);
_renderData.WriteDataRecord(MILCMD.MilDrawGeometry,
(byte*)&record,
16 /* sizeof(MILCMD_DRAW_GEOMETRY) */);
}
}
///
/// DrawImage -
/// Draw an Image into the region specified by the Rect.
/// The Image will potentially be stretched and distorted to fit the Rect.
/// For more fine grained control, consider filling a Rect with an ImageBrush via
/// DrawRectangle.
///
/// The ImageSource to draw.
///
/// The Rect into which the ImageSource will be fit.
///
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawImage(
ImageSource imageSource,
Rect rectangle)
{
VerifyApiNonstructuralChange();
if (imageSource == null)
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawImage(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_DRAW_IMAGE record =
new MILCMD_DRAW_IMAGE (
_renderData.AddDependentResource(imageSource),
rectangle
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_IMAGE) == 40);
_renderData.WriteDataRecord(MILCMD.MilDrawImage,
(byte*)&record,
40 /* sizeof(MILCMD_DRAW_IMAGE) */);
}
}
///
/// DrawImage -
/// Draw an Image into the region specified by the Rect.
/// The Image will potentially be stretched and distorted to fit the Rect.
/// For more fine grained control, consider filling a Rect with an ImageBrush via
/// DrawRectangle.
///
/// The ImageSource to draw.
///
/// The Rect into which the ImageSource will be fit.
///
/// Optional AnimationClock for rectangle.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawImage(
ImageSource imageSource,
Rect rectangle,
AnimationClock rectangleAnimations)
{
VerifyApiNonstructuralChange();
if (imageSource == null)
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawImage(animate)");
#endif
unsafe
{
EnsureRenderData();
UInt32 hRectangleAnimations = CompositionResourceManager.InvalidResourceHandle;
hRectangleAnimations = UseAnimations(rectangle, rectangleAnimations);
MILCMD_DRAW_IMAGE_ANIMATE record =
new MILCMD_DRAW_IMAGE_ANIMATE (
_renderData.AddDependentResource(imageSource),
rectangle,
hRectangleAnimations
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_IMAGE_ANIMATE) == 40);
_renderData.WriteDataRecord(MILCMD.MilDrawImageAnimate,
(byte*)&record,
40 /* sizeof(MILCMD_DRAW_IMAGE_ANIMATE) */);
}
}
///
/// DrawGlyphRun -
/// Draw a GlyphRun
///
///
/// Foreground brush to draw the GlyphRun with.
///
/// The GlyphRun to draw.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawGlyphRun(
Brush foregroundBrush,
GlyphRun glyphRun)
{
VerifyApiNonstructuralChange();
if ((foregroundBrush == null) || (glyphRun == null))
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawGlyphRun(const)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
MILCMD_DRAW_GLYPH_RUN record =
new MILCMD_DRAW_GLYPH_RUN (
_renderData.AddDependentResource(foregroundBrush),
_renderData.AddDependentResource(glyphRun)
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_GLYPH_RUN) == 8);
_renderData.WriteDataRecord(MILCMD.MilDrawGlyphRun,
(byte*)&record,
8 /* sizeof(MILCMD_DRAW_GLYPH_RUN) */);
}
}
///
/// DrawDrawing -
/// Draw a Drawing by appending a sub-Drawing to the current Drawing.
///
/// The drawing to draw.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawDrawing(
Drawing drawing)
{
VerifyApiNonstructuralChange();
if (drawing == null)
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawDrawing(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_DRAW_DRAWING record =
new MILCMD_DRAW_DRAWING (
_renderData.AddDependentResource(drawing)
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_DRAWING) == 8);
_renderData.WriteDataRecord(MILCMD.MilDrawDrawing,
(byte*)&record,
8 /* sizeof(MILCMD_DRAW_DRAWING) */);
}
}
///
/// DrawVideo -
/// Draw a Video into the region specified by the Rect.
/// The Video will potentially be stretched and distorted to fit the Rect.
/// For more fine grained control, consider filling a Rect with an VideoBrush via
/// DrawRectangle.
///
/// The MediaPlayer to draw.
/// The Rect into which the media will be fit.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawVideo(
MediaPlayer player,
Rect rectangle)
{
VerifyApiNonstructuralChange();
if (player == null)
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawVideo(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_DRAW_VIDEO record =
new MILCMD_DRAW_VIDEO (
_renderData.AddDependentResource(player),
rectangle
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_VIDEO) == 40);
_renderData.WriteDataRecord(MILCMD.MilDrawVideo,
(byte*)&record,
40 /* sizeof(MILCMD_DRAW_VIDEO) */);
}
}
///
/// DrawVideo -
/// Draw a Video into the region specified by the Rect.
/// The Video will potentially be stretched and distorted to fit the Rect.
/// For more fine grained control, consider filling a Rect with an VideoBrush via
/// DrawRectangle.
///
/// The MediaPlayer to draw.
/// The Rect into which the media will be fit.
/// Optional AnimationClock for rectangle.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawVideo(
MediaPlayer player,
Rect rectangle,
AnimationClock rectangleAnimations)
{
VerifyApiNonstructuralChange();
if (player == null)
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawVideo(animate)");
#endif
unsafe
{
EnsureRenderData();
UInt32 hRectangleAnimations = CompositionResourceManager.InvalidResourceHandle;
hRectangleAnimations = UseAnimations(rectangle, rectangleAnimations);
MILCMD_DRAW_VIDEO_ANIMATE record =
new MILCMD_DRAW_VIDEO_ANIMATE (
_renderData.AddDependentResource(player),
rectangle,
hRectangleAnimations
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_VIDEO_ANIMATE) == 40);
_renderData.WriteDataRecord(MILCMD.MilDrawVideoAnimate,
(byte*)&record,
40 /* sizeof(MILCMD_DRAW_VIDEO_ANIMATE) */);
}
}
///
/// DrawScene3D -
/// Draw a Scene3D (internal object encapsulating a 3D scene)
///
/// The Scene3D to draw.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
internal override void DrawScene3D(
Scene3D scene3D)
{
VerifyApiNonstructuralChange();
if (scene3D == null)
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawScene3D(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_DRAW_SCENE3D record =
new MILCMD_DRAW_SCENE3D (
_renderData.AddDependentResource(scene3D)
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_SCENE3D) == 8);
_renderData.WriteDataRecord(MILCMD.MilDrawScene3D,
(byte*)&record,
8 /* sizeof(MILCMD_DRAW_SCENE3D) */);
}
}
///
/// PushClip -
/// Push a clip region, which will apply to all drawing primitives until the
/// corresponding Pop call.
///
/// The Geometry to which we will clip.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void PushClip(
Geometry clipGeometry)
{
VerifyApiNonstructuralChange();
#if DEBUG
MediaTrace.DrawingContextOp.Trace("PushClip(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_PUSH_CLIP record =
new MILCMD_PUSH_CLIP (
_renderData.AddDependentResource(clipGeometry)
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_PUSH_CLIP) == 8);
_renderData.WriteDataRecord(MILCMD.MilPushClip,
(byte*)&record,
8 /* sizeof(MILCMD_PUSH_CLIP) */);
}
_stackDepth++;
}
///
/// PushOpacityMask -
/// Push an opacity mask which will blend the composite of all drawing primitives added
/// until the corresponding Pop call.
///
/// The opacity mask
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void PushOpacityMask(
Brush opacityMask)
{
VerifyApiNonstructuralChange();
#if DEBUG
MediaTrace.DrawingContextOp.Trace("PushOpacityMask(const)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
MILCMD_PUSH_OPACITY_MASK record =
new MILCMD_PUSH_OPACITY_MASK (
_renderData.AddDependentResource(opacityMask)
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_PUSH_OPACITY_MASK) == 24);
_renderData.WriteDataRecord(MILCMD.MilPushOpacityMask,
(byte*)&record,
24 /* sizeof(MILCMD_PUSH_OPACITY_MASK) */);
}
_stackDepth++;
}
///
/// PushOpacity -
/// Push an opacity which will blend the composite of all drawing primitives added
/// until the corresponding Pop call.
///
///
/// The opacity with which to blend - 0 is transparent, 1 is opaque.
///
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void PushOpacity(
Double opacity)
{
VerifyApiNonstructuralChange();
#if DEBUG
MediaTrace.DrawingContextOp.Trace("PushOpacity(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_PUSH_OPACITY record =
new MILCMD_PUSH_OPACITY (
opacity
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_PUSH_OPACITY) == 8);
_renderData.WriteDataRecord(MILCMD.MilPushOpacity,
(byte*)&record,
8 /* sizeof(MILCMD_PUSH_OPACITY) */);
}
_stackDepth++;
}
///
/// PushOpacity -
/// Push an opacity which will blend the composite of all drawing primitives added
/// until the corresponding Pop call.
///
///
/// The opacity with which to blend - 0 is transparent, 1 is opaque.
///
/// Optional AnimationClock for opacity.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void PushOpacity(
Double opacity,
AnimationClock opacityAnimations)
{
VerifyApiNonstructuralChange();
#if DEBUG
MediaTrace.DrawingContextOp.Trace("PushOpacity(animate)");
#endif
unsafe
{
EnsureRenderData();
UInt32 hOpacityAnimations = CompositionResourceManager.InvalidResourceHandle;
hOpacityAnimations = UseAnimations(opacity, opacityAnimations);
MILCMD_PUSH_OPACITY_ANIMATE record =
new MILCMD_PUSH_OPACITY_ANIMATE (
opacity,
hOpacityAnimations
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_PUSH_OPACITY_ANIMATE) == 16);
_renderData.WriteDataRecord(MILCMD.MilPushOpacityAnimate,
(byte*)&record,
16 /* sizeof(MILCMD_PUSH_OPACITY_ANIMATE) */);
}
_stackDepth++;
}
///
/// PushTransform -
/// Push a Transform which will apply to all drawing operations until the corresponding
/// Pop.
///
/// The Transform to push.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void PushTransform(
Transform transform)
{
VerifyApiNonstructuralChange();
#if DEBUG
MediaTrace.DrawingContextOp.Trace("PushTransform(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_PUSH_TRANSFORM record =
new MILCMD_PUSH_TRANSFORM (
_renderData.AddDependentResource(transform)
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_PUSH_TRANSFORM) == 8);
_renderData.WriteDataRecord(MILCMD.MilPushTransform,
(byte*)&record,
8 /* sizeof(MILCMD_PUSH_TRANSFORM) */);
}
_stackDepth++;
}
///
/// PushGuidelineSet -
/// Push a set of guidelines which will apply to all drawing operations until the
/// corresponding Pop.
///
/// The GuidelineSet to push.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void PushGuidelineSet(
GuidelineSet guidelines)
{
VerifyApiNonstructuralChange();
#if DEBUG
MediaTrace.DrawingContextOp.Trace("PushGuidelineSet(const)");
#endif
unsafe
{
EnsureRenderData();
if (guidelines != null && guidelines.IsFrozen && guidelines.IsDynamic)
{
DoubleCollection guidelinesX = guidelines.GuidelinesX;
DoubleCollection guidelinesY = guidelines.GuidelinesY;
int countX = guidelinesX == null ? 0 : guidelinesX.Count;
int countY = guidelinesY == null ? 0 : guidelinesY.Count;
if (countX == 0 && (countY == 1 || countY == 2)
)
{
if (countY == 1)
{
MILCMD_PUSH_GUIDELINE_Y1 record =
new MILCMD_PUSH_GUIDELINE_Y1(
guidelinesY[0]
);
_renderData.WriteDataRecord(
MILCMD.MilPushGuidelineY1,
(byte*)&record,
sizeof(MILCMD_PUSH_GUIDELINE_Y1)
);
}
else
{
MILCMD_PUSH_GUIDELINE_Y2 record =
new MILCMD_PUSH_GUIDELINE_Y2(
guidelinesY[0],
guidelinesY[1] - guidelinesY[0]
);
_renderData.WriteDataRecord(
MILCMD.MilPushGuidelineY2,
(byte*)&record,
sizeof(MILCMD_PUSH_GUIDELINE_Y2)
);
}
}
}
else
{
MILCMD_PUSH_GUIDELINE_SET record =
new MILCMD_PUSH_GUIDELINE_SET (
_renderData.AddDependentResource(guidelines)
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_PUSH_GUIDELINE_SET) == 8);
_renderData.WriteDataRecord(MILCMD.MilPushGuidelineSet,
(byte*)&record,
8 /* sizeof(MILCMD_PUSH_GUIDELINE_SET) */);
}
}
_stackDepth++;
}
///
/// PushGuidelineY1 -
/// Explicitly push one horizontal guideline.
///
/// The coordinate of leading guideline.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
internal override void PushGuidelineY1(
Double coordinate)
{
VerifyApiNonstructuralChange();
#if DEBUG
MediaTrace.DrawingContextOp.Trace("PushGuidelineY1(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_PUSH_GUIDELINE_Y1 record =
new MILCMD_PUSH_GUIDELINE_Y1 (
coordinate
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_PUSH_GUIDELINE_Y1) == 8);
_renderData.WriteDataRecord(MILCMD.MilPushGuidelineY1,
(byte*)&record,
8 /* sizeof(MILCMD_PUSH_GUIDELINE_Y1) */);
}
_stackDepth++;
}
///
/// PushGuidelineY2 -
/// Explicitly push a pair of horizontal guidelines.
///
///
/// The coordinate of leading guideline.
///
///
/// The offset from leading guideline to driven guideline.
///
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
internal override void PushGuidelineY2(
Double leadingCoordinate,
Double offsetToDrivenCoordinate)
{
VerifyApiNonstructuralChange();
#if DEBUG
MediaTrace.DrawingContextOp.Trace("PushGuidelineY2(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_PUSH_GUIDELINE_Y2 record =
new MILCMD_PUSH_GUIDELINE_Y2 (
leadingCoordinate,
offsetToDrivenCoordinate
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_PUSH_GUIDELINE_Y2) == 16);
_renderData.WriteDataRecord(MILCMD.MilPushGuidelineY2,
(byte*)&record,
16 /* sizeof(MILCMD_PUSH_GUIDELINE_Y2) */);
}
_stackDepth++;
}
///
/// PushEffect -
/// Push a BitmapEffect which will apply to all drawing operations until the
/// corresponding Pop.
///
/// The BitmapEffect to push.
/// The BitmapEffectInput.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void PushEffect(
BitmapEffect effect,
BitmapEffectInput effectInput)
{
VerifyApiNonstructuralChange();
#if DEBUG
MediaTrace.DrawingContextOp.Trace("PushEffect(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_PUSH_EFFECT record =
new MILCMD_PUSH_EFFECT (
_renderData.AddDependentResource(effect),
_renderData.AddDependentResource(effectInput)
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_PUSH_EFFECT) == 8);
_renderData.WriteDataRecord(MILCMD.MilPushEffect,
(byte*)&record,
8 /* sizeof(MILCMD_PUSH_EFFECT) */);
}
_stackDepth++;
if (_renderData.BitmapEffectStackDepth == 0)
{
_renderData.BeginTopLevelBitmapEffect(_stackDepth);
}
}
///
/// Pop
///
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void Pop(
)
{
VerifyApiNonstructuralChange();
if (_stackDepth <= 0)
{
throw new InvalidOperationException(SR.Get(SRID.DrawingContext_TooManyPops));
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("Pop(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_POP record =
new MILCMD_POP (
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
// Note that since sizeof(emptyStruct) returns 1, we compare against 1 for empty structs.
Debug.Assert(sizeof(MILCMD_POP) == 1);
_renderData.WriteDataRecord(MILCMD.MilPop,
(byte*)&record,
0 /* sizeof(MILCMD_POP) */);
}
_stackDepth--;
// end the top level effect, if we are popping the top
// level push effect instruction
if (_renderData.BitmapEffectStackDepth == (_stackDepth + 1))
{
_renderData.EndTopLevelBitmapEffect();
}
}
private UInt32 UseAnimations(
Double baseValue,
AnimationClock animations)
{
if (animations == null)
{
return 0;
}
else
{
return _renderData.AddDependentResource(
new DoubleAnimationClockResource(
baseValue,
animations));
}
}
private UInt32 UseAnimations(
Point baseValue,
AnimationClock animations)
{
if (animations == null)
{
return 0;
}
else
{
return _renderData.AddDependentResource(
new PointAnimationClockResource(
baseValue,
animations));
}
}
private UInt32 UseAnimations(
Size baseValue,
AnimationClock animations)
{
if (animations == null)
{
return 0;
}
else
{
return _renderData.AddDependentResource(
new SizeAnimationClockResource(
baseValue,
animations));
}
}
private UInt32 UseAnimations(
Rect baseValue,
AnimationClock animations)
{
if (animations == null)
{
return 0;
}
else
{
return _renderData.AddDependentResource(
new RectAnimationClockResource(
baseValue,
animations));
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
// This file was generated, please do not edit it directly.
//
// Please see http://wiki/default.aspx/Microsoft.Projects.Avalon/MilCodeGen.html for more information.
//
//---------------------------------------------------------------------------
using MS.Internal;
using MS.Internal.PresentationCore;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Windows.Threading;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Composition;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Diagnostics;
using SR=MS.Internal.PresentationCore.SR;
using SRID=MS.Internal.PresentationCore.SRID;
using System.Security;
using System.Security.Permissions;
namespace System.Windows.Media
{
///
/// RenderDataDrawingContext - A DrawingContext which produces a Drawing.
///
internal partial class RenderDataDrawingContext : DrawingContext
{
///
/// DrawLine -
/// Draws a line with the specified pen.
/// Note that this API does not accept a Brush, as there is no area to fill.
///
/// The Pen with which to stroke the line.
/// The start Point for the line.
/// The end Point for the line.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawLine(
Pen pen,
Point point0,
Point point1)
{
VerifyApiNonstructuralChange();
if (pen == null)
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawLine(const)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
MILCMD_DRAW_LINE record =
new MILCMD_DRAW_LINE (
_renderData.AddDependentResource(pen),
point0,
point1
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_LINE) == 40);
_renderData.WriteDataRecord(MILCMD.MilDrawLine,
(byte*)&record,
40 /* sizeof(MILCMD_DRAW_LINE) */);
}
}
///
/// DrawLine -
/// Draws a line with the specified pen.
/// Note that this API does not accept a Brush, as there is no area to fill.
///
/// The Pen with which to stroke the line.
/// The start Point for the line.
/// Optional AnimationClock for point0.
/// The end Point for the line.
/// Optional AnimationClock for point1.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawLine(
Pen pen,
Point point0,
AnimationClock point0Animations,
Point point1,
AnimationClock point1Animations)
{
VerifyApiNonstructuralChange();
if (pen == null)
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawLine(animate)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
UInt32 hPoint0Animations = CompositionResourceManager.InvalidResourceHandle;
UInt32 hPoint1Animations = CompositionResourceManager.InvalidResourceHandle;
hPoint0Animations = UseAnimations(point0, point0Animations);
hPoint1Animations = UseAnimations(point1, point1Animations);
MILCMD_DRAW_LINE_ANIMATE record =
new MILCMD_DRAW_LINE_ANIMATE (
_renderData.AddDependentResource(pen),
point0,
hPoint0Animations,
point1,
hPoint1Animations
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_LINE_ANIMATE) == 48);
_renderData.WriteDataRecord(MILCMD.MilDrawLineAnimate,
(byte*)&record,
48 /* sizeof(MILCMD_DRAW_LINE_ANIMATE) */);
}
}
///
/// DrawRectangle -
/// Draw a rectangle with the provided Brush and/or Pen.
/// If both the Brush and Pen are null this call is a no-op.
///
///
/// The Brush with which to fill the rectangle.
/// This is optional, and can be null, in which case no fill is performed.
///
///
/// The Pen with which to stroke the rectangle.
/// This is optional, and can be null, in which case no stroke is performed.
///
/// The Rect to fill and/or stroke.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawRectangle(
Brush brush,
Pen pen,
Rect rectangle)
{
VerifyApiNonstructuralChange();
if ((brush == null) && (pen == null))
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawRectangle(const)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
MILCMD_DRAW_RECTANGLE record =
new MILCMD_DRAW_RECTANGLE (
_renderData.AddDependentResource(brush),
_renderData.AddDependentResource(pen),
rectangle
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_RECTANGLE) == 40);
_renderData.WriteDataRecord(MILCMD.MilDrawRectangle,
(byte*)&record,
40 /* sizeof(MILCMD_DRAW_RECTANGLE) */);
}
}
///
/// DrawRectangle -
/// Draw a rectangle with the provided Brush and/or Pen.
/// If both the Brush and Pen are null this call is a no-op.
///
///
/// The Brush with which to fill the rectangle.
/// This is optional, and can be null, in which case no fill is performed.
///
///
/// The Pen with which to stroke the rectangle.
/// This is optional, and can be null, in which case no stroke is performed.
///
/// The Rect to fill and/or stroke.
/// Optional AnimationClock for rectangle.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawRectangle(
Brush brush,
Pen pen,
Rect rectangle,
AnimationClock rectangleAnimations)
{
VerifyApiNonstructuralChange();
if ((brush == null) && (pen == null))
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawRectangle(animate)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
UInt32 hRectangleAnimations = CompositionResourceManager.InvalidResourceHandle;
hRectangleAnimations = UseAnimations(rectangle, rectangleAnimations);
MILCMD_DRAW_RECTANGLE_ANIMATE record =
new MILCMD_DRAW_RECTANGLE_ANIMATE (
_renderData.AddDependentResource(brush),
_renderData.AddDependentResource(pen),
rectangle,
hRectangleAnimations
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_RECTANGLE_ANIMATE) == 48);
_renderData.WriteDataRecord(MILCMD.MilDrawRectangleAnimate,
(byte*)&record,
48 /* sizeof(MILCMD_DRAW_RECTANGLE_ANIMATE) */);
}
}
///
/// DrawRoundedRectangle -
/// Draw a rounded rectangle with the provided Brush and/or Pen.
/// If both the Brush and Pen are null this call is a no-op.
///
///
/// The Brush with which to fill the rectangle.
/// This is optional, and can be null, in which case no fill is performed.
///
///
/// The Pen with which to stroke the rectangle.
/// This is optional, and can be null, in which case no stroke is performed.
///
/// The Rect to fill and/or stroke.
///
/// The radius in the X dimension of the rounded corners of this
/// rounded Rect. This value will be clamped to the range [0..rectangle.Width/2]
///
///
/// The radius in the Y dimension of the rounded corners of this
/// rounded Rect. This value will be clamped to the range [0..rectangle.Height/2].
///
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawRoundedRectangle(
Brush brush,
Pen pen,
Rect rectangle,
Double radiusX,
Double radiusY)
{
VerifyApiNonstructuralChange();
if ((brush == null) && (pen == null))
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawRoundedRectangle(const)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
MILCMD_DRAW_ROUNDED_RECTANGLE record =
new MILCMD_DRAW_ROUNDED_RECTANGLE (
_renderData.AddDependentResource(brush),
_renderData.AddDependentResource(pen),
rectangle,
radiusX,
radiusY
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_ROUNDED_RECTANGLE) == 56);
_renderData.WriteDataRecord(MILCMD.MilDrawRoundedRectangle,
(byte*)&record,
56 /* sizeof(MILCMD_DRAW_ROUNDED_RECTANGLE) */);
}
}
///
/// DrawRoundedRectangle -
/// Draw a rounded rectangle with the provided Brush and/or Pen.
/// If both the Brush and Pen are null this call is a no-op.
///
///
/// The Brush with which to fill the rectangle.
/// This is optional, and can be null, in which case no fill is performed.
///
///
/// The Pen with which to stroke the rectangle.
/// This is optional, and can be null, in which case no stroke is performed.
///
/// The Rect to fill and/or stroke.
/// Optional AnimationClock for rectangle.
///
/// The radius in the X dimension of the rounded corners of this
/// rounded Rect. This value will be clamped to the range [0..rectangle.Width/2]
///
/// Optional AnimationClock for radiusX.
///
/// The radius in the Y dimension of the rounded corners of this
/// rounded Rect. This value will be clamped to the range [0..rectangle.Height/2].
///
/// Optional AnimationClock for radiusY.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawRoundedRectangle(
Brush brush,
Pen pen,
Rect rectangle,
AnimationClock rectangleAnimations,
Double radiusX,
AnimationClock radiusXAnimations,
Double radiusY,
AnimationClock radiusYAnimations)
{
VerifyApiNonstructuralChange();
if ((brush == null) && (pen == null))
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawRoundedRectangle(animate)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
UInt32 hRectangleAnimations = CompositionResourceManager.InvalidResourceHandle;
UInt32 hRadiusXAnimations = CompositionResourceManager.InvalidResourceHandle;
UInt32 hRadiusYAnimations = CompositionResourceManager.InvalidResourceHandle;
hRectangleAnimations = UseAnimations(rectangle, rectangleAnimations);
hRadiusXAnimations = UseAnimations(radiusX, radiusXAnimations);
hRadiusYAnimations = UseAnimations(radiusY, radiusYAnimations);
MILCMD_DRAW_ROUNDED_RECTANGLE_ANIMATE record =
new MILCMD_DRAW_ROUNDED_RECTANGLE_ANIMATE (
_renderData.AddDependentResource(brush),
_renderData.AddDependentResource(pen),
rectangle,
hRectangleAnimations,
radiusX,
hRadiusXAnimations,
radiusY,
hRadiusYAnimations
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_ROUNDED_RECTANGLE_ANIMATE) == 72);
_renderData.WriteDataRecord(MILCMD.MilDrawRoundedRectangleAnimate,
(byte*)&record,
72 /* sizeof(MILCMD_DRAW_ROUNDED_RECTANGLE_ANIMATE) */);
}
}
///
/// DrawEllipse -
/// Draw an ellipse with the provided Brush and/or Pen.
/// If both the Brush and Pen are null this call is a no-op.
///
///
/// The Brush with which to fill the ellipse.
/// This is optional, and can be null, in which case no fill is performed.
///
///
/// The Pen with which to stroke the ellipse.
/// This is optional, and can be null, in which case no stroke is performed.
///
///
/// The center of the ellipse to fill and/or stroke.
///
///
/// The radius in the X dimension of the ellipse.
/// The absolute value of the radius provided will be used.
///
///
/// The radius in the Y dimension of the ellipse.
/// The absolute value of the radius provided will be used.
///
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawEllipse(
Brush brush,
Pen pen,
Point center,
Double radiusX,
Double radiusY)
{
VerifyApiNonstructuralChange();
if ((brush == null) && (pen == null))
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawEllipse(const)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
MILCMD_DRAW_ELLIPSE record =
new MILCMD_DRAW_ELLIPSE (
_renderData.AddDependentResource(brush),
_renderData.AddDependentResource(pen),
center,
radiusX,
radiusY
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_ELLIPSE) == 40);
_renderData.WriteDataRecord(MILCMD.MilDrawEllipse,
(byte*)&record,
40 /* sizeof(MILCMD_DRAW_ELLIPSE) */);
}
}
///
/// DrawEllipse -
/// Draw an ellipse with the provided Brush and/or Pen.
/// If both the Brush and Pen are null this call is a no-op.
///
///
/// The Brush with which to fill the ellipse.
/// This is optional, and can be null, in which case no fill is performed.
///
///
/// The Pen with which to stroke the ellipse.
/// This is optional, and can be null, in which case no stroke is performed.
///
///
/// The center of the ellipse to fill and/or stroke.
///
/// Optional AnimationClock for center.
///
/// The radius in the X dimension of the ellipse.
/// The absolute value of the radius provided will be used.
///
/// Optional AnimationClock for radiusX.
///
/// The radius in the Y dimension of the ellipse.
/// The absolute value of the radius provided will be used.
///
/// Optional AnimationClock for radiusY.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawEllipse(
Brush brush,
Pen pen,
Point center,
AnimationClock centerAnimations,
Double radiusX,
AnimationClock radiusXAnimations,
Double radiusY,
AnimationClock radiusYAnimations)
{
VerifyApiNonstructuralChange();
if ((brush == null) && (pen == null))
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawEllipse(animate)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
UInt32 hCenterAnimations = CompositionResourceManager.InvalidResourceHandle;
UInt32 hRadiusXAnimations = CompositionResourceManager.InvalidResourceHandle;
UInt32 hRadiusYAnimations = CompositionResourceManager.InvalidResourceHandle;
hCenterAnimations = UseAnimations(center, centerAnimations);
hRadiusXAnimations = UseAnimations(radiusX, radiusXAnimations);
hRadiusYAnimations = UseAnimations(radiusY, radiusYAnimations);
MILCMD_DRAW_ELLIPSE_ANIMATE record =
new MILCMD_DRAW_ELLIPSE_ANIMATE (
_renderData.AddDependentResource(brush),
_renderData.AddDependentResource(pen),
center,
hCenterAnimations,
radiusX,
hRadiusXAnimations,
radiusY,
hRadiusYAnimations
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_ELLIPSE_ANIMATE) == 56);
_renderData.WriteDataRecord(MILCMD.MilDrawEllipseAnimate,
(byte*)&record,
56 /* sizeof(MILCMD_DRAW_ELLIPSE_ANIMATE) */);
}
}
///
/// DrawGeometry -
/// Draw a Geometry with the provided Brush and/or Pen.
/// If both the Brush and Pen are null this call is a no-op.
///
///
/// The Brush with which to fill the Geometry.
/// This is optional, and can be null, in which case no fill is performed.
///
///
/// The Pen with which to stroke the Geometry.
/// This is optional, and can be null, in which case no stroke is performed.
///
/// The Geometry to fill and/or stroke.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawGeometry(
Brush brush,
Pen pen,
Geometry geometry)
{
VerifyApiNonstructuralChange();
if (((brush == null) && (pen == null)) || (geometry == null))
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawGeometry(const)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
MILCMD_DRAW_GEOMETRY record =
new MILCMD_DRAW_GEOMETRY (
_renderData.AddDependentResource(brush),
_renderData.AddDependentResource(pen),
_renderData.AddDependentResource(geometry)
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_GEOMETRY) == 16);
_renderData.WriteDataRecord(MILCMD.MilDrawGeometry,
(byte*)&record,
16 /* sizeof(MILCMD_DRAW_GEOMETRY) */);
}
}
///
/// DrawImage -
/// Draw an Image into the region specified by the Rect.
/// The Image will potentially be stretched and distorted to fit the Rect.
/// For more fine grained control, consider filling a Rect with an ImageBrush via
/// DrawRectangle.
///
/// The ImageSource to draw.
///
/// The Rect into which the ImageSource will be fit.
///
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawImage(
ImageSource imageSource,
Rect rectangle)
{
VerifyApiNonstructuralChange();
if (imageSource == null)
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawImage(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_DRAW_IMAGE record =
new MILCMD_DRAW_IMAGE (
_renderData.AddDependentResource(imageSource),
rectangle
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_IMAGE) == 40);
_renderData.WriteDataRecord(MILCMD.MilDrawImage,
(byte*)&record,
40 /* sizeof(MILCMD_DRAW_IMAGE) */);
}
}
///
/// DrawImage -
/// Draw an Image into the region specified by the Rect.
/// The Image will potentially be stretched and distorted to fit the Rect.
/// For more fine grained control, consider filling a Rect with an ImageBrush via
/// DrawRectangle.
///
/// The ImageSource to draw.
///
/// The Rect into which the ImageSource will be fit.
///
/// Optional AnimationClock for rectangle.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawImage(
ImageSource imageSource,
Rect rectangle,
AnimationClock rectangleAnimations)
{
VerifyApiNonstructuralChange();
if (imageSource == null)
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawImage(animate)");
#endif
unsafe
{
EnsureRenderData();
UInt32 hRectangleAnimations = CompositionResourceManager.InvalidResourceHandle;
hRectangleAnimations = UseAnimations(rectangle, rectangleAnimations);
MILCMD_DRAW_IMAGE_ANIMATE record =
new MILCMD_DRAW_IMAGE_ANIMATE (
_renderData.AddDependentResource(imageSource),
rectangle,
hRectangleAnimations
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_IMAGE_ANIMATE) == 40);
_renderData.WriteDataRecord(MILCMD.MilDrawImageAnimate,
(byte*)&record,
40 /* sizeof(MILCMD_DRAW_IMAGE_ANIMATE) */);
}
}
///
/// DrawGlyphRun -
/// Draw a GlyphRun
///
///
/// Foreground brush to draw the GlyphRun with.
///
/// The GlyphRun to draw.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawGlyphRun(
Brush foregroundBrush,
GlyphRun glyphRun)
{
VerifyApiNonstructuralChange();
if ((foregroundBrush == null) || (glyphRun == null))
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawGlyphRun(const)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
MILCMD_DRAW_GLYPH_RUN record =
new MILCMD_DRAW_GLYPH_RUN (
_renderData.AddDependentResource(foregroundBrush),
_renderData.AddDependentResource(glyphRun)
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_GLYPH_RUN) == 8);
_renderData.WriteDataRecord(MILCMD.MilDrawGlyphRun,
(byte*)&record,
8 /* sizeof(MILCMD_DRAW_GLYPH_RUN) */);
}
}
///
/// DrawDrawing -
/// Draw a Drawing by appending a sub-Drawing to the current Drawing.
///
/// The drawing to draw.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawDrawing(
Drawing drawing)
{
VerifyApiNonstructuralChange();
if (drawing == null)
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawDrawing(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_DRAW_DRAWING record =
new MILCMD_DRAW_DRAWING (
_renderData.AddDependentResource(drawing)
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_DRAWING) == 8);
_renderData.WriteDataRecord(MILCMD.MilDrawDrawing,
(byte*)&record,
8 /* sizeof(MILCMD_DRAW_DRAWING) */);
}
}
///
/// DrawVideo -
/// Draw a Video into the region specified by the Rect.
/// The Video will potentially be stretched and distorted to fit the Rect.
/// For more fine grained control, consider filling a Rect with an VideoBrush via
/// DrawRectangle.
///
/// The MediaPlayer to draw.
/// The Rect into which the media will be fit.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawVideo(
MediaPlayer player,
Rect rectangle)
{
VerifyApiNonstructuralChange();
if (player == null)
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawVideo(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_DRAW_VIDEO record =
new MILCMD_DRAW_VIDEO (
_renderData.AddDependentResource(player),
rectangle
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_VIDEO) == 40);
_renderData.WriteDataRecord(MILCMD.MilDrawVideo,
(byte*)&record,
40 /* sizeof(MILCMD_DRAW_VIDEO) */);
}
}
///
/// DrawVideo -
/// Draw a Video into the region specified by the Rect.
/// The Video will potentially be stretched and distorted to fit the Rect.
/// For more fine grained control, consider filling a Rect with an VideoBrush via
/// DrawRectangle.
///
/// The MediaPlayer to draw.
/// The Rect into which the media will be fit.
/// Optional AnimationClock for rectangle.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void DrawVideo(
MediaPlayer player,
Rect rectangle,
AnimationClock rectangleAnimations)
{
VerifyApiNonstructuralChange();
if (player == null)
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawVideo(animate)");
#endif
unsafe
{
EnsureRenderData();
UInt32 hRectangleAnimations = CompositionResourceManager.InvalidResourceHandle;
hRectangleAnimations = UseAnimations(rectangle, rectangleAnimations);
MILCMD_DRAW_VIDEO_ANIMATE record =
new MILCMD_DRAW_VIDEO_ANIMATE (
_renderData.AddDependentResource(player),
rectangle,
hRectangleAnimations
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_VIDEO_ANIMATE) == 40);
_renderData.WriteDataRecord(MILCMD.MilDrawVideoAnimate,
(byte*)&record,
40 /* sizeof(MILCMD_DRAW_VIDEO_ANIMATE) */);
}
}
///
/// DrawScene3D -
/// Draw a Scene3D (internal object encapsulating a 3D scene)
///
/// The Scene3D to draw.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
internal override void DrawScene3D(
Scene3D scene3D)
{
VerifyApiNonstructuralChange();
if (scene3D == null)
{
return;
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("DrawScene3D(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_DRAW_SCENE3D record =
new MILCMD_DRAW_SCENE3D (
_renderData.AddDependentResource(scene3D)
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_DRAW_SCENE3D) == 8);
_renderData.WriteDataRecord(MILCMD.MilDrawScene3D,
(byte*)&record,
8 /* sizeof(MILCMD_DRAW_SCENE3D) */);
}
}
///
/// PushClip -
/// Push a clip region, which will apply to all drawing primitives until the
/// corresponding Pop call.
///
/// The Geometry to which we will clip.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void PushClip(
Geometry clipGeometry)
{
VerifyApiNonstructuralChange();
#if DEBUG
MediaTrace.DrawingContextOp.Trace("PushClip(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_PUSH_CLIP record =
new MILCMD_PUSH_CLIP (
_renderData.AddDependentResource(clipGeometry)
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_PUSH_CLIP) == 8);
_renderData.WriteDataRecord(MILCMD.MilPushClip,
(byte*)&record,
8 /* sizeof(MILCMD_PUSH_CLIP) */);
}
_stackDepth++;
}
///
/// PushOpacityMask -
/// Push an opacity mask which will blend the composite of all drawing primitives added
/// until the corresponding Pop call.
///
/// The opacity mask
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void PushOpacityMask(
Brush opacityMask)
{
VerifyApiNonstructuralChange();
#if DEBUG
MediaTrace.DrawingContextOp.Trace("PushOpacityMask(const)");
#endif
unsafe
{
EnsureRenderData();
// Always assume visual and drawing brushes need realization updates
MILCMD_PUSH_OPACITY_MASK record =
new MILCMD_PUSH_OPACITY_MASK (
_renderData.AddDependentResource(opacityMask)
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_PUSH_OPACITY_MASK) == 24);
_renderData.WriteDataRecord(MILCMD.MilPushOpacityMask,
(byte*)&record,
24 /* sizeof(MILCMD_PUSH_OPACITY_MASK) */);
}
_stackDepth++;
}
///
/// PushOpacity -
/// Push an opacity which will blend the composite of all drawing primitives added
/// until the corresponding Pop call.
///
///
/// The opacity with which to blend - 0 is transparent, 1 is opaque.
///
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void PushOpacity(
Double opacity)
{
VerifyApiNonstructuralChange();
#if DEBUG
MediaTrace.DrawingContextOp.Trace("PushOpacity(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_PUSH_OPACITY record =
new MILCMD_PUSH_OPACITY (
opacity
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_PUSH_OPACITY) == 8);
_renderData.WriteDataRecord(MILCMD.MilPushOpacity,
(byte*)&record,
8 /* sizeof(MILCMD_PUSH_OPACITY) */);
}
_stackDepth++;
}
///
/// PushOpacity -
/// Push an opacity which will blend the composite of all drawing primitives added
/// until the corresponding Pop call.
///
///
/// The opacity with which to blend - 0 is transparent, 1 is opaque.
///
/// Optional AnimationClock for opacity.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void PushOpacity(
Double opacity,
AnimationClock opacityAnimations)
{
VerifyApiNonstructuralChange();
#if DEBUG
MediaTrace.DrawingContextOp.Trace("PushOpacity(animate)");
#endif
unsafe
{
EnsureRenderData();
UInt32 hOpacityAnimations = CompositionResourceManager.InvalidResourceHandle;
hOpacityAnimations = UseAnimations(opacity, opacityAnimations);
MILCMD_PUSH_OPACITY_ANIMATE record =
new MILCMD_PUSH_OPACITY_ANIMATE (
opacity,
hOpacityAnimations
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_PUSH_OPACITY_ANIMATE) == 16);
_renderData.WriteDataRecord(MILCMD.MilPushOpacityAnimate,
(byte*)&record,
16 /* sizeof(MILCMD_PUSH_OPACITY_ANIMATE) */);
}
_stackDepth++;
}
///
/// PushTransform -
/// Push a Transform which will apply to all drawing operations until the corresponding
/// Pop.
///
/// The Transform to push.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void PushTransform(
Transform transform)
{
VerifyApiNonstructuralChange();
#if DEBUG
MediaTrace.DrawingContextOp.Trace("PushTransform(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_PUSH_TRANSFORM record =
new MILCMD_PUSH_TRANSFORM (
_renderData.AddDependentResource(transform)
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_PUSH_TRANSFORM) == 8);
_renderData.WriteDataRecord(MILCMD.MilPushTransform,
(byte*)&record,
8 /* sizeof(MILCMD_PUSH_TRANSFORM) */);
}
_stackDepth++;
}
///
/// PushGuidelineSet -
/// Push a set of guidelines which will apply to all drawing operations until the
/// corresponding Pop.
///
/// The GuidelineSet to push.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void PushGuidelineSet(
GuidelineSet guidelines)
{
VerifyApiNonstructuralChange();
#if DEBUG
MediaTrace.DrawingContextOp.Trace("PushGuidelineSet(const)");
#endif
unsafe
{
EnsureRenderData();
if (guidelines != null && guidelines.IsFrozen && guidelines.IsDynamic)
{
DoubleCollection guidelinesX = guidelines.GuidelinesX;
DoubleCollection guidelinesY = guidelines.GuidelinesY;
int countX = guidelinesX == null ? 0 : guidelinesX.Count;
int countY = guidelinesY == null ? 0 : guidelinesY.Count;
if (countX == 0 && (countY == 1 || countY == 2)
)
{
if (countY == 1)
{
MILCMD_PUSH_GUIDELINE_Y1 record =
new MILCMD_PUSH_GUIDELINE_Y1(
guidelinesY[0]
);
_renderData.WriteDataRecord(
MILCMD.MilPushGuidelineY1,
(byte*)&record,
sizeof(MILCMD_PUSH_GUIDELINE_Y1)
);
}
else
{
MILCMD_PUSH_GUIDELINE_Y2 record =
new MILCMD_PUSH_GUIDELINE_Y2(
guidelinesY[0],
guidelinesY[1] - guidelinesY[0]
);
_renderData.WriteDataRecord(
MILCMD.MilPushGuidelineY2,
(byte*)&record,
sizeof(MILCMD_PUSH_GUIDELINE_Y2)
);
}
}
}
else
{
MILCMD_PUSH_GUIDELINE_SET record =
new MILCMD_PUSH_GUIDELINE_SET (
_renderData.AddDependentResource(guidelines)
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_PUSH_GUIDELINE_SET) == 8);
_renderData.WriteDataRecord(MILCMD.MilPushGuidelineSet,
(byte*)&record,
8 /* sizeof(MILCMD_PUSH_GUIDELINE_SET) */);
}
}
_stackDepth++;
}
///
/// PushGuidelineY1 -
/// Explicitly push one horizontal guideline.
///
/// The coordinate of leading guideline.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
internal override void PushGuidelineY1(
Double coordinate)
{
VerifyApiNonstructuralChange();
#if DEBUG
MediaTrace.DrawingContextOp.Trace("PushGuidelineY1(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_PUSH_GUIDELINE_Y1 record =
new MILCMD_PUSH_GUIDELINE_Y1 (
coordinate
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_PUSH_GUIDELINE_Y1) == 8);
_renderData.WriteDataRecord(MILCMD.MilPushGuidelineY1,
(byte*)&record,
8 /* sizeof(MILCMD_PUSH_GUIDELINE_Y1) */);
}
_stackDepth++;
}
///
/// PushGuidelineY2 -
/// Explicitly push a pair of horizontal guidelines.
///
///
/// The coordinate of leading guideline.
///
///
/// The offset from leading guideline to driven guideline.
///
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
internal override void PushGuidelineY2(
Double leadingCoordinate,
Double offsetToDrivenCoordinate)
{
VerifyApiNonstructuralChange();
#if DEBUG
MediaTrace.DrawingContextOp.Trace("PushGuidelineY2(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_PUSH_GUIDELINE_Y2 record =
new MILCMD_PUSH_GUIDELINE_Y2 (
leadingCoordinate,
offsetToDrivenCoordinate
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_PUSH_GUIDELINE_Y2) == 16);
_renderData.WriteDataRecord(MILCMD.MilPushGuidelineY2,
(byte*)&record,
16 /* sizeof(MILCMD_PUSH_GUIDELINE_Y2) */);
}
_stackDepth++;
}
///
/// PushEffect -
/// Push a BitmapEffect which will apply to all drawing operations until the
/// corresponding Pop.
///
/// The BitmapEffect to push.
/// The BitmapEffectInput.
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void PushEffect(
BitmapEffect effect,
BitmapEffectInput effectInput)
{
VerifyApiNonstructuralChange();
#if DEBUG
MediaTrace.DrawingContextOp.Trace("PushEffect(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_PUSH_EFFECT record =
new MILCMD_PUSH_EFFECT (
_renderData.AddDependentResource(effect),
_renderData.AddDependentResource(effectInput)
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
Debug.Assert(sizeof(MILCMD_PUSH_EFFECT) == 8);
_renderData.WriteDataRecord(MILCMD.MilPushEffect,
(byte*)&record,
8 /* sizeof(MILCMD_PUSH_EFFECT) */);
}
_stackDepth++;
if (_renderData.BitmapEffectStackDepth == 0)
{
_renderData.BeginTopLevelBitmapEffect(_stackDepth);
}
}
///
/// Pop
///
///
/// Critical:This code calls into unsafe code
/// TreatAsSafe: This code is ok to expose. Writing a record is a safe operation as long as the size and pointer are valid.
///
[SecurityCritical,SecurityTreatAsSafe]
public override void Pop(
)
{
VerifyApiNonstructuralChange();
if (_stackDepth <= 0)
{
throw new InvalidOperationException(SR.Get(SRID.DrawingContext_TooManyPops));
}
#if DEBUG
MediaTrace.DrawingContextOp.Trace("Pop(const)");
#endif
unsafe
{
EnsureRenderData();
MILCMD_POP record =
new MILCMD_POP (
);
// Assert that the calculated packet size is the same as the size returned by sizeof().
// Note that since sizeof(emptyStruct) returns 1, we compare against 1 for empty structs.
Debug.Assert(sizeof(MILCMD_POP) == 1);
_renderData.WriteDataRecord(MILCMD.MilPop,
(byte*)&record,
0 /* sizeof(MILCMD_POP) */);
}
_stackDepth--;
// end the top level effect, if we are popping the top
// level push effect instruction
if (_renderData.BitmapEffectStackDepth == (_stackDepth + 1))
{
_renderData.EndTopLevelBitmapEffect();
}
}
private UInt32 UseAnimations(
Double baseValue,
AnimationClock animations)
{
if (animations == null)
{
return 0;
}
else
{
return _renderData.AddDependentResource(
new DoubleAnimationClockResource(
baseValue,
animations));
}
}
private UInt32 UseAnimations(
Point baseValue,
AnimationClock animations)
{
if (animations == null)
{
return 0;
}
else
{
return _renderData.AddDependentResource(
new PointAnimationClockResource(
baseValue,
animations));
}
}
private UInt32 UseAnimations(
Size baseValue,
AnimationClock animations)
{
if (animations == null)
{
return 0;
}
else
{
return _renderData.AddDependentResource(
new SizeAnimationClockResource(
baseValue,
animations));
}
}
private UInt32 UseAnimations(
Rect baseValue,
AnimationClock animations)
{
if (animations == null)
{
return 0;
}
else
{
return _renderData.AddDependentResource(
new RectAnimationClockResource(
baseValue,
animations));
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HttpPostedFileBase.cs
- HitTestWithGeometryDrawingContextWalker.cs
- VirtualizedContainerService.cs
- PathNode.cs
- DataGridItemCollection.cs
- XmlCharCheckingReader.cs
- HMACSHA512.cs
- HtmlInputCheckBox.cs
- PageContentCollection.cs
- DrawToolTipEventArgs.cs
- GenerateScriptTypeAttribute.cs
- HostedBindingBehavior.cs
- _SslState.cs
- SslStream.cs
- SafeSecurityHelper.cs
- CssTextWriter.cs
- FigureHelper.cs
- SatelliteContractVersionAttribute.cs
- SignatureHelper.cs
- ImageInfo.cs
- QilTargetType.cs
- CSharpCodeProvider.cs
- BreakRecordTable.cs
- TypePresenter.xaml.cs
- XappLauncher.cs
- AsymmetricSignatureFormatter.cs
- XPathItem.cs
- CfgSemanticTag.cs
- FrameworkContentElement.cs
- Span.cs
- MD5CryptoServiceProvider.cs
- _IPv6Address.cs
- DataStreamFromComStream.cs
- XmlTextAttribute.cs
- DesignerRegionMouseEventArgs.cs
- HostVisual.cs
- ThreadStartException.cs
- MatrixCamera.cs
- EntityViewContainer.cs
- AnonymousIdentificationSection.cs
- HtmlInputButton.cs
- SqlConnectionPoolProviderInfo.cs
- ApplicationBuildProvider.cs
- SqlCommand.cs
- ParseHttpDate.cs
- BatchServiceHost.cs
- WebConvert.cs
- WaitHandle.cs
- ZoneMembershipCondition.cs
- ResponseStream.cs
- ColorKeyFrameCollection.cs
- _SslStream.cs
- Scheduling.cs
- DbConnectionFactory.cs
- DataBindingExpressionBuilder.cs
- InheritanceContextChangedEventManager.cs
- StorageConditionPropertyMapping.cs
- TagPrefixAttribute.cs
- PrimaryKeyTypeConverter.cs
- RegexGroupCollection.cs
- DesignerToolboxInfo.cs
- TableAutomationPeer.cs
- TransformProviderWrapper.cs
- MsmqMessage.cs
- WebPartConnectionsCloseVerb.cs
- _NegoState.cs
- HttpCookiesSection.cs
- ScalarConstant.cs
- XmlUTF8TextWriter.cs
- CanonicalXml.cs
- SmiMetaData.cs
- XmlAutoDetectWriter.cs
- DataGridViewButtonCell.cs
- LocatorBase.cs
- LinkConverter.cs
- Helper.cs
- TreeBuilderXamlTranslator.cs
- SoapTypeAttribute.cs
- StrokeNodeOperations.cs
- ProjectedSlot.cs
- SpeechSynthesizer.cs
- MediaScriptCommandRoutedEventArgs.cs
- MetadataPropertyCollection.cs
- ChangeNode.cs
- Model3DCollection.cs
- JsonServiceDocumentSerializer.cs
- TagMapInfo.cs
- COM2IDispatchConverter.cs
- DataSourceGroupCollection.cs
- GenerateScriptTypeAttribute.cs
- LinkArea.cs
- CodePageUtils.cs
- ParameterRetriever.cs
- IndexerHelper.cs
- Variable.cs
- EntityContainerRelationshipSet.cs
- ListSourceHelper.cs
- SoapServerMessage.cs
- ProtectedConfiguration.cs
- SQLByte.cs