gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GUI/back changes in CVS


From: Fred Kiefer
Subject: Re: GUI/back changes in CVS
Date: Wed, 13 Jul 2005 00:51:43 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.7) Gecko/20050414

Fred Kiefer wrote:
> What I was planning to do was add a simple (and of course slow) pattern
> drawing mechanism for the gsc classes and perhaps overwrite this with a
> faster one for the xlib backend.
> 

I had promissed a simple drawing mechanism, here it is (from GSGState.m):

- (NSBezierPath*)clipPath
{
  return nil;
}

- (void) _fillRect: (NSRect)rect withPattern: (NSImage*)colour_pattern
{
  NSSize size;
  float x;
  float y;

  size = [colour_pattern size];
  y = floor(NSMinY(rect) / size.height) * size.height;
  while (y < NSMaxY(rect))
    {
      x = floor(NSMinX(rect) / size.width) * size.width;
      while (x < NSMaxX(rect))
      {
          [colour_pattern compositeToPoint: NSMakePoint(x, y)
                                 operation: NSCompositeSourceOver];
          x += size.width;
      }
      y += size.height;
    }

}

- (void) fillRect: (NSRect)rect withPattern: (NSImage*)colour_pattern
{
  NSBezierPath *oldPath = path;
  NSBezierPath *oldClip;

  oldClip = [self clipPath];
  path = [NSBezierPath bezierPathWithRect: rect];
  [self DPSclip];

  [self _fillRect: rect withPattern: pattern];

  path = oldClip;
  [self DPSclip];
  path = oldPath;
}

- (void) fillPath: (NSBezierPath*)fillPath withPattern:
(NSImage*)colour_pattern
{
  NSBezierPath *oldPath = path;
  NSBezierPath *oldClip;
  NSRect rect;

  oldClip = [self clipPath];
  rect = [fillPath bounds];
  path = fillPath;
  [self DPSclip];

  [self _fillRect: rect withPattern: pattern];

  path = oldClip;
  [self DPSclip];
  path = oldPath;
}

in XGGState.m I then call:
  if (pattern != nil)
    {
      NSRect rect = NSMakeRect(x, y, w, h);
      [self fillRect: rect withPattern: pattern];
      return;
    }

and

  if (pattern != nil)
    {
      [self fillPath: path withPattern: pattern];
      return;
    }


All of this works fine. Of course EOFill is currently not supported, but
simple to do (would require a call to DPSeoclip instead of DPSclip). And
the clipping is what stops me from merging this code into CVS. As I need
to change the clipping, and restore it afterwards, I could either
implement this separately for each backend and not share any code or
implement that clipPath method, used in the current implementation, for
all backends. As this method is also not that easy, I could fake it by
storing the current clip path in another slot of the GState (and keep
the EO state within this path, as we need that as well when reseting the
old clip). But perhaps somebody out there has a better idea for this?

Cheers
Fred





reply via email to

[Prev in Thread] Current Thread [Next in Thread]