[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] pnetlib ./ChangeLog System.Windows.Forms/Contro...
From: |
Heiko Weiss |
Subject: |
[dotgnu-pnet-commits] pnetlib ./ChangeLog System.Windows.Forms/Contro... |
Date: |
Fri, 02 Jun 2006 10:26:12 +0000 |
CVSROOT: /sources/dotgnu-pnet
Module name: pnetlib
Branch:
Changes by: Heiko Weiss <address@hidden> 06/06/02 10:26:12
Modified files:
. : ChangeLog
System.Windows.Forms: Control.cs
System.Drawing/Drawing2D: RegionData.cs
Log message:
optimized performance
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/ChangeLog.diff?tr1=1.2414&tr2=1.2415&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Windows.Forms/Control.cs.diff?tr1=1.122&tr2=1.123&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Drawing/Drawing2D/RegionData.cs.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
Patches:
Index: pnetlib/ChangeLog
diff -u pnetlib/ChangeLog:1.2414 pnetlib/ChangeLog:1.2415
--- pnetlib/ChangeLog:1.2414 Thu Jun 1 13:19:11 2006
+++ pnetlib/ChangeLog Fri Jun 2 10:26:12 2006
@@ -1,3 +1,9 @@
+2006-06-02 Heiko Weiss <address@hidden>
+
+ * System.Windows.Forms/Control.cs,
+ System.Drawing/Drawing2D/RegionData.cs:
+ optimized performance
+
2006-06-01 Deryk Robosson <address@hidden>
* System.Drawing/Graphics.cs: Use StringBuilder for concats
Index: pnetlib/System.Drawing/Drawing2D/RegionData.cs
diff -u pnetlib/System.Drawing/Drawing2D/RegionData.cs:1.4
pnetlib/System.Drawing/Drawing2D/RegionData.cs:1.5
--- pnetlib/System.Drawing/Drawing2D/RegionData.cs:1.4 Tue Nov 22 16:41:20 2005
+++ pnetlib/System.Drawing/Drawing2D/RegionData.cs Fri Jun 2 10:26:12 2006
@@ -73,6 +73,83 @@
private const Int32 CAP_MAX = 0x7FFFFFFF;
private const Int32 CAP_INC = 0x00000100;
+ static private byte[] dataRectangleF;
+ static private byte[] dataEmpty;
+ static private byte[] dataInfinite;
+
+ // Static constructor to initialize a default dataRectangleF to enhance
performance
+ static RegionData() {
+ dataRectangleF = CreateStaticData( 36, REG_RECT );
+ dataEmpty = CreateStaticData( 20, REG_EMPTY );
+ dataInfinite = CreateStaticData( 20, REG_INF );
+ }
+
+
+ static byte[] CreateStaticData( int size, int type ) {
+
+ byte [] data = new byte[size];
+
+ int index = HEADER_SIZE;
+
+ int value = type;
+
+ if( BitConverter.IsLittleEndian ) {
+ data[index+0] = (byte)(value );
+ data[index+1] = (byte)(value>> 8);
+ data[index+2] = (byte)(value>>16);
+ data[index+3] = (byte)(value>>24);
+ }
+ else {
+ data[index+3] = (byte)(value );
+ data[index+2] = (byte)(value>> 8);
+ data[index+1] = (byte)(value>>16);
+ data[index+0] = (byte)(value>>24);
+ }
+
+ value = size-8;
+
+ // WriteHeader( size - 8 , 0 );
+
+ if( BitConverter.IsLittleEndian ) {
+ data[0] = (byte)(value );
+ data[1] = (byte)(value>> 8);
+ data[2] = (byte)(value>>16);
+ data[3] = (byte)(value>>24);
+ }
+ else {
+ data[3] = (byte)(value );
+ data[2] = (byte)(value>> 8);
+ data[1] = (byte)(value>>16);
+ data[0] = (byte)(value>>24);
+ }
+
+ // TODO Checksum
+ data[4] = 0xFF;
+ data[5] = 0xFF;
+ data[6] = 0xFF;
+ data[7] = 0xFF;
+
+ // PutInt32( _MAGIC_ , 8 ) ;
+ value = _MAGIC_;
+
+ if( BitConverter.IsLittleEndian ) {
+ data[ 8] = (byte)(value );
+ data[ 9] = (byte)(value>> 8);
+ data[10] = (byte)(value>>16);
+ data[11] = (byte)(value>>24);
+ }
+ else {
+ data[11] = (byte)(value );
+ data[10] = (byte)(value>> 8);
+ data[ 9] = (byte)(value>>16);
+ data[ 8] = (byte)(value>>24);
+ }
+
+ // PutInt32( _2nrOps , 12 ) ;
+ // PutInt32( 0 , 12 ) ;
+ // not needed zero is zero !
+ return data;
+ }
/*
* Constructors, for internal use ( used by System.Drawing.Region )
*/
@@ -127,9 +204,19 @@
*/
private void InitializeRegionData( RectangleF rect )
{
+ /*
int size = AddRegionRectangle( rect , StartRegionData(36) ) ;
WriteHeader( size - 8 , 0 );
Resize( size ) ;
+ */
+ // optimize performance by cloning template
+ data = (byte[])dataRectangleF.Clone();
+
+ int index = HEADER_SIZE;
+ PutSingle( rect.X , index+=4 );
+ PutSingle( rect.Y , index+=4 );
+ PutSingle( rect.Width , index+=4 );
+ PutSingle( rect.Height , index+=4 );
}
private void InitializeRegionData( GraphicsPath path )
{
@@ -139,15 +226,25 @@
}
private void InitializeEmptyRegionData()
{
+ /*
int size = AddRegionEmpty( StartRegionData(20) ) ;
WriteHeader( size - 8 , 0 );
Resize( size ) ;
+ */
+
+ // optimize performance by cloning template
+ data = (byte[])dataEmpty.Clone();
}
private void InitializeInfiniteRegionData()
{
+ /*
int size = AddRegionInfinite( StartRegionData(20) ) ;
WriteHeader( size - 8 , 0 );
Resize( size ) ;
+ */
+
+ // optimize performance by cloning template
+ data = (byte[])dataInfinite.Clone();
}
/*
Index: pnetlib/System.Windows.Forms/Control.cs
diff -u pnetlib/System.Windows.Forms/Control.cs:1.122
pnetlib/System.Windows.Forms/Control.cs:1.123
--- pnetlib/System.Windows.Forms/Control.cs:1.122 Mon May 8 13:11:16 2006
+++ pnetlib/System.Windows.Forms/Control.cs Fri Jun 2 10:26:12 2006
@@ -790,6 +790,9 @@
{
get
{
+ // optimized performance
+ if( borderStyle == BorderStyle.None )
return new Size( width, height );
+
Size offset =
ClientToBounds(Size.Empty);
return new Size(width - offset.Width,
height - offset.Height);
}
@@ -1511,7 +1514,9 @@
// then that has changed as well.
if(bindingContext == null)
{
-
OnBindingContextChanged(EventArgs.Empty);
+ if( Created ) {
+
OnBindingContextChanged(EventArgs.Empty);
+ }
}
// Initialize layout for calculating
the anchor.
@@ -2652,24 +2657,30 @@
}
// TODO Inefficient
- int xOrigin = ClientOrigin.X;
- int yOrigin = ClientOrigin.Y;
- // The rectangle relative to the toolkit that
is the bounds for this control.
- Rectangle parentInvalidateBounds = new
Rectangle(xOrigin, yOrigin, ClientSize.Width, ClientSize.Height);
RectangleF[] rs = region.GetRegionScans(new
Drawing.Drawing2D.Matrix());
- for(int i = 0; i < rs.Length; i++)
- {
- Rectangle b = Rectangle.Truncate(rs[i]);
- // Get in local coordinates.
- b.Offset(xOrigin, yOrigin);
- b.Intersect(parentInvalidateBounds);
- if(!b.IsEmpty)
+ if( rs.Length > 0 ) {
+ // TODO Inefficient
+ Point p = ClientOrigin;
+ Size s = ClientSize;
+ int xOrigin = p.X;
+ int yOrigin = p.Y;
+ // The rectangle relative to the toolkit that
is the bounds for this control.
+ Rectangle parentInvalidateBounds = new
Rectangle(xOrigin, yOrigin, s.Width, s.Height);
+
+ for(int i = 0; i < rs.Length; i++)
{
- if(toolkitWindow == null)
+ Rectangle b =
Rectangle.Truncate(rs[i]);
+ // Get in local coordinates.
+ b.Offset(xOrigin, yOrigin);
+
b.Intersect(parentInvalidateBounds);
+ if(!b.IsEmpty)
{
- CreateControl();
+ if(toolkitWindow ==
null)
+ {
+ CreateControl();
+ }
+
toolkitWindow.Invalidate(b.X, b.Y, b.Width, b.Height);
}
- toolkitWindow.Invalidate(b.X,
b.Y, b.Width, b.Height);
}
}
}
@@ -2889,10 +2900,16 @@
Control child;
// If our height is less than the height of an
empty control, then we have probably been minimized and we must not layout.
- Size offset = ClientToBounds(Size.Empty);
- if(height < offset.Height)
- {
- return;
+
+ // optimized performance
+ if( borderStyle == BorderStyle.None ) {
+ }
+ else {
+ Size offset =
ClientToBounds(Size.Empty);
+ if(height < offset.Height)
+ {
+ return;
+ }
}
// Start with the display rectangle.
@@ -2906,7 +2923,7 @@
for(posn = numChildren - 1; posn >= 0; --posn)
{
child = children[posn];
- if(child.Visible)
+ if(child.visible)
{
switch(child.Dock)
{
@@ -2959,7 +2976,7 @@
for(posn = numChildren - 1; posn >= 0; --posn)
{
child = children[posn];
- if(child.Visible)
+ if(child.visible)
{
if (child.Dock ==
DockStyle.None)
{
@@ -3533,8 +3550,14 @@
#endif
protected virtual void SetClientSizeCore(int x, int y)
{
- Size client = ClientToBounds(new Size(x, y));
- SetBoundsCore(left, top, client.Width,
client.Height, BoundsSpecified.Size);
+ // optimized performance
+ if( borderStyle == BorderStyle.None ) {
+ SetBoundsCore(left, top, x, y,
BoundsSpecified.Size);
+ }
+ else {
+ Size client = ClientToBounds(new
Size(x, y));
+ SetBoundsCore(left, top, client.Width,
client.Height, BoundsSpecified.Size);
+ }
}
// Set a control flag.
@@ -5290,7 +5313,7 @@
#endif
protected virtual void OnParentVisibleChanged(EventArgs e)
{
- OnVisibleChanged(e);
+ if( visible ) OnVisibleChanged(e);
}
internal virtual void OnPrimaryEnter(EventArgs e)
{
@@ -6470,7 +6493,7 @@
case (BorderStyle.FixedSingle):
return new Size(size.Width + 2,
size.Height + 2);
default: //BorderStyle.None
- return new Size(size.Width,
size.Height);
+ return size; // new
Size(size.Width, size.Height);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] pnetlib ./ChangeLog System.Windows.Forms/Contro...,
Heiko Weiss <=