1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
|
/*
Copyright (C) 2001-2003 KSVG Team
This file is part of the KDE project
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
aint with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "CanvasItem.h"
#include "CanvasItems.h"
#include "KSVGCanvas.moc"
#include "SVGRectImpl.h"
#include "SVGSVGElementImpl.h"
#include "SVGStringListImpl.h"
#include "SVGClipPathElementImpl.h"
#include "SVGImageElementImpl.h"
#include "SVGDocumentImpl.h"
#include <kdebug.h>
#include <kglobal.h>
#include <tqstring.h>
#include <tqdatetime.h>
#include <tqpaintdevicemetrics.h>
#include <tqwmatrix.h>
#include <X11/Xlib.h>
#include <math.h>
#include <libs/xrgbrender/gdk-pixbuf-xlibrgb.h>
#include <Font.h>
#include <fontconfig/fontconfig.h>
#define USE_TIMER
using namespace KSVG;
KSVGCanvas::KSVGCanvas(unsigned int width, unsigned int height) : m_viewportWidth(width), m_viewportHeight(height), m_width(width), m_height(height)
{
m_fontContext = 0;
m_items.setAutoDelete(true);
m_chunkSizeVer = CHUNK_SIZE_VERTICAL;
m_chunkSizeHor = CHUNK_SIZE_HORIZONTAL;
m_zoom = 1;
m_buffer = 0;
m_backgroundColor = TQColor(250, 250, 250);
m_immediateUpdate = false;
}
void KSVGCanvas::setup(TQPaintDevice *drawWindow, TQPaintDevice *directWindow)
{
m_drawWindow = drawWindow;
m_directWindow = directWindow;
m_buffer = 0;
m_nrChannels = 3;
setRenderBufferSize(m_width, m_height);
xlib_rgb_init_with_depth(m_drawWindow->x11Display(), XScreenOfDisplay(m_drawWindow->x11Display(), m_drawWindow->x11Screen()), m_drawWindow->x11Depth());
m_gc = XCreateGC(m_drawWindow->x11Display(), m_drawWindow->handle(), 0, 0);
}
void KSVGCanvas::setViewportDimension(unsigned int w, unsigned int h)
{
m_viewportWidth = w;
m_viewportHeight = h;
setRenderBufferSize(w, h);
}
void KSVGCanvas::setup(unsigned char *buffer, unsigned int width, unsigned int height)
{
setBuffer(buffer);
m_drawWindow = 0;
m_directWindow = 0;
m_nrChannels = 4;
if(height > 0)
{
m_width = width;
m_height = height;
}
setRenderBufferSize(m_width, m_height);
m_gc = 0;
}
void KSVGCanvas::setBuffer(unsigned char *buffer)
{
m_buffer = buffer;
}
KSVGCanvas::~KSVGCanvas()
{
if(m_fontContext)
delete m_fontContext;
if(m_buffer && m_gc)
delete []m_buffer;
if(m_gc)
XFreeGC(m_drawWindow->x11Display(), m_gc);
reset();
}
void KSVGCanvas::retune(unsigned int csh, unsigned int csv)
{
m_chunkSizeHor = csh;
m_chunkSizeVer = csv;
}
void KSVGCanvas::resize(unsigned int w, unsigned int h)
{
if(m_buffer && (m_width != int(w) || m_height != int(h)))
{
unsigned char *oldbuffer = m_buffer;
m_buffer = new unsigned char[w * h * m_nrChannels];
int minw = kMin(int(w), m_width);
int minh = kMin(int(h), m_height);
int origstride = m_width * m_nrChannels;
int newstride = w * m_nrChannels;
// Redraw new areas, if any
int diffw = w - m_width;
int diffh = h - m_height;
TQRect r(m_width, 0, diffw, m_height + diffh);
TQRect r3(0, m_height, m_width + diffw, diffh);
TQWMatrix mtx;
mtx.translate(m_pan.x(), m_pan.y());
mtx.scale(m_zoom, m_zoom);
m_width = w;
m_height = h;
setBuffer(m_buffer);
fill();
if(diffw > 0 || diffh > 0)
{
CanvasItemList drawables;
if(diffw > 0)
{
TQRect r2 = mtx.invert().map(r);
// Recalc items
for(int j = r2.top() / int(m_chunkSizeVer); j <= r2.bottom() / int(m_chunkSizeVer); j++)
{
for(int i = r2.left() / int(m_chunkSizeHor); i <= r2.right() / int(m_chunkSizeHor); i++)
{
CanvasChunk *chunk = m_chunkManager.getChunk(i, j);
if(chunk)
{
for(CanvasItemList::ConstIterator it = chunk->list().begin(); it != chunk->list().end(); ++it)
{
if(!drawables.contains(*it))
drawables.append(*it);
}
}
}
}
}
if(diffh > 0)
{
TQRect r4 = mtx.invert().map(r3);
// Recalc items
for(int j = r4.top() / int(m_chunkSizeVer); j <= r4.bottom() / int(m_chunkSizeVer); j++)
{
for(int i = r4.left() / int(m_chunkSizeHor); i <= r4.right() / int(m_chunkSizeHor); i++)
{
CanvasChunk *chunk = m_chunkManager.getChunk(i, j);
if(chunk)
{
for(CanvasItemList::ConstIterator it = chunk->list().begin(); it != chunk->list().end(); ++it)
{
if(!drawables.contains(*it))
drawables.append(*it);
}
}
}
}
}
drawables.sort();
for(CanvasItemList::Iterator it = drawables.begin(); it != drawables.end(); ++it)
(*it)->draw();
}
for(int y = 0; y < minh; y++)
memcpy(m_buffer + y * newstride, oldbuffer + y * origstride, minw * m_nrChannels);
delete []oldbuffer;
}
}
void KSVGCanvas::setRenderBufferSize(int w, int h)
{
kdDebug(26005) << k_funcinfo << endl;
if(m_drawWindow)
{
bool needsRedraw = (!m_buffer) || (m_width != w || m_height != h);
if(needsRedraw)
{
TQPaintDeviceMetrics metrics(m_drawWindow);
m_width = kMin(int(w), metrics.width());
m_height = kMin(int(h), metrics.height());
if(m_buffer)
delete []m_buffer;
m_buffer = new unsigned char[m_width * m_height * m_nrChannels];
}
}
fill();
}
void KSVGCanvas::clear(const TQRect &r)
{
TQRect r2 = r & TQRect(0, 0, m_width, m_height);
if(!r2.isEmpty() && m_buffer)
{
for(int i = 0; i < r2.height(); i++)
memset(m_buffer + int(r2.x() * m_nrChannels) + int((r2.y() + i) * (m_width * m_nrChannels)), tqRgba(250, 250, 250, 250), r2.width() * m_nrChannels);
}
}
void KSVGCanvas::fill()
{
if(m_buffer)
{
unsigned char r = m_backgroundColor.red();
unsigned char g = m_backgroundColor.green();
unsigned char b = m_backgroundColor.blue();
if(m_nrChannels == 3)
{
if(r == g && r == b)
memset(m_buffer, r, m_width * m_height * m_nrChannels);
else
{
unsigned char *p = m_buffer;
for(int i = 0; i < m_width * m_height; i++)
{
*p++ = r;
*p++ = g;
*p++ = b;
}
}
}
else
{
TQ_UINT32 *p = reinterpret_cast<TQ_UINT32 *>(m_buffer);
unsigned char a = tqAlpha(m_backgroundColor.rgb());
#if X_BYTE_ORDER == X_LITTLE_ENDIAN
TQ_UINT32 rgba = (a << 24) | (b << 16) | (g << 8) | r;
#else
TQ_UINT32 rgba = (r << 24) | (g << 16) | (b << 8) | a;
#endif
for(int i = 0; i < m_width * m_height; i++)
*p++ = rgba;
}
}
}
// Clipping
void KSVGCanvas::clipToBuffer(int &x0, int &y0, int &x1, int &y1) const
{
// clamp to viewport
x0 = TQMAX(x0, 0);
x0 = TQMIN(x0, int(m_width - 1));
y0 = TQMAX(y0, 0);
y0 = TQMIN(y0, int(m_height - 1));
x1 = TQMAX(x1, 0);
x1 = TQMIN(x1, int(m_width - 1));
y1 = TQMAX(y1, 0);
y1 = TQMIN(y1, int(m_height - 1));
}
T2P::FontVisualParams *KSVGCanvas::fontVisualParams(SVGStylableImpl *style) const
{
T2P::FontVisualParams *fontVisualParams = new T2P::FontVisualParams();
// Calc weight & slant
int weight = 0, slant = 0;
EFontStyle fontStyle = style->getFontStyle();
TQString fontWeight = style->getFontWeight();
if(fontWeight.contains("bold"))
weight |= FC_WEIGHT_DEMIBOLD;
if(fontWeight.contains("bolder"))
weight |= FC_WEIGHT_BOLD;
if(fontWeight.contains("lighter"))
weight |= FC_WEIGHT_LIGHT;
bool ok = true;
int weightNumber = fontWeight.toInt(&ok);
if(ok)
weight = weightNumber;
if(fontStyle == FSNORMAL)
slant |= FC_SLANT_ROMAN;
else if(fontStyle == ITALIC)
slant |= FC_SLANT_ITALIC;
else if(fontStyle == OBLITQUE)
slant |= FC_SLANT_OBLIQUE;
// Calc font names
SVGStringListImpl *fontList = style->getFontFamily();
for(unsigned int i = 0; i <= fontList->numberOfItems(); i++)
{
DOM::DOMString *string = fontList->getItem(i);
if(string)
fontVisualParams->fontList().push_back(string->string().latin1());
}
fontVisualParams->setWeight(weight);
fontVisualParams->setSlant(slant);
fontVisualParams->setSize(style->getFontSize());
return fontVisualParams;
}
void KSVGCanvas::tqinvalidate(CanvasItem *item, bool recalc)
{
if(m_chunksByItem.find(item) != m_chunksByItem.end())
{
if(recalc)
{
removeFromChunks(item);
addToChunks(item);
}
TQPtrListIterator<CanvasChunk> it = m_chunksByItem[item];
for(it.toFirst(); it.current(); ++it)
{
(*it)->setDirty();
if(!m_dirtyChunks.contains(*it))
m_dirtyChunks.append(*it);
}
}
else
addToChunks(item);
}
void KSVGCanvas::insert(CanvasItem *item, int z)
{
if(z == -1)
{
item->setZIndex(m_chunksByItem.size());
m_chunksByItem[item] = TQPtrList<CanvasChunk>();
addToChunks(item);
m_items.append(item);
bool visible = item->isVisible();
if(visible)
tqinvalidate(item, false);
if(m_immediateUpdate)
{
if(visible)
{
item->draw();
TQRect bbox = item->bbox();
blit(bbox, true);
}
}
}
else
{
// make some space
for(unsigned int i = z; i < m_items.count(); i++)
m_items.at(i)->setZIndex(m_items.at(i)->zIndex() + 1);
item->setZIndex(z);
}
}
void KSVGCanvas::removeItem(CanvasItem *item)
{
removeFromChunks(item);
m_items.remove(item);
}
void KSVGCanvas::removeFromChunks(CanvasItem *item)
{
TQPtrListIterator<CanvasChunk> it = m_chunksByItem[item];
for(it.toFirst(); it.current(); ++it)
{
(*it)->remove(item);
if(!m_dirtyChunks.contains(*it))
m_dirtyChunks.append(*it);
}
m_chunksByItem.remove(item);
}
void KSVGCanvas::addToChunks(CanvasItem *item)
{
TQRect bbox = item->bbox();
TQWMatrix mtx;
mtx.translate(m_pan.x(), m_pan.y());
mtx.scale(m_zoom, m_zoom);
bbox = mtx.invert().map(bbox);
for(int j = bbox.top() / m_chunkSizeVer; j <= (bbox.bottom() / m_chunkSizeVer); j++)
{
for(int i = bbox.left() / int(m_chunkSizeHor); i <= (bbox.right() / m_chunkSizeHor); i++)
{
CanvasChunk *chunk = m_chunkManager.getChunk(i, j);
if(!chunk)
{
chunk = new CanvasChunk(i, j);
m_chunkManager.addChunk(chunk);
}
chunk->add(item);
m_chunksByItem[item].append(chunk);
}
}
}
unsigned int KSVGCanvas::setElementItemZIndexRecursive(SVGElementImpl *element, unsigned int z)
{
SVGShapeImpl *tqshape = dynamic_cast<SVGShapeImpl *>(element);
if(tqshape)
{
CanvasItem *item = tqshape->item();
if(item)
{
SVGImageElementImpl *image = dynamic_cast<SVGImageElementImpl *>(tqshape);
if(image && image->svgImageRootElement())
{
// Set the z for all items in the svg image, since they live in the
// same canvas.
z = setElementItemZIndexRecursive(image->svgImageRootElement(), z);
}
else
{
item->setZIndex(z);
tqinvalidate(item, false);
z++;
}
}
}
for(DOM::Node node = element->firstChild(); !node.isNull(); node = node.nextSibling())
{
SVGElementImpl *e = element->ownerDoc()->getElementFromHandle(node.handle());
if(e)
z = setElementItemZIndexRecursive(e, z);
}
return z;
}
void KSVGCanvas::update(const TQPoint &panPoint, bool erase)
{
#ifdef USE_TIMER
TQTime t;
t.start();
#endif
int dx = panPoint.x() - m_pan.x();
int dy = panPoint.y() - m_pan.y();
m_pan = panPoint;
if(erase)
fill();
// reset clip paths
TQDictIterator<CanvasClipPath> itr(m_clipPaths);
for(; itr.current(); ++itr)
(*itr)->update(UPDATE_TRANSFORM);
TQWMatrix mtx;
mtx.translate(m_pan.x(), m_pan.y());
mtx.scale(m_zoom, m_zoom);
TQRect r(0, 0, m_width, m_height);
TQRect r2 = mtx.invert().map(r);
// pan all items
for(unsigned int i = 0; i < m_items.count(); i++)
m_items.at(i)->update(UPDATE_PAN, dx, dy);
// recalc items
CanvasItemList drawables;
TQPtrListIterator<CanvasItem> it = m_items;
for(int j = r2.top() / m_chunkSizeVer; j <= (r2.bottom() / m_chunkSizeVer); j++)
{
for(int i = r2.left() / m_chunkSizeHor; i <= (r2.right() / m_chunkSizeHor); i++)
{
CanvasChunk *chunk = m_chunkManager.getChunk(i, j);
if(chunk)
{
for(CanvasItemList::ConstIterator it = chunk->list().begin(); it != chunk->list().end(); ++it)
{
if(!drawables.contains(*it))
drawables.append(*it);
}
}
}
}
drawables.sort();
for(CanvasItemList::Iterator it = drawables.begin(); it != drawables.end(); ++it)
(*it)->draw();
if(m_drawWindow)
blit(TQRect(0, 0, m_width, m_height), false);
m_dirtyChunks.clear();
#ifdef USE_TIMER
kdDebug(26000) << k_funcinfo << " Total time: " << t.elapsed() << endl;
#endif
}
void KSVGCanvas::update(float zoomFactor)
{
#ifdef USE_TIMER
TQTime t;
t.start();
#endif
if(zoomFactor >= 1)
{
int newWidth = static_cast<int>(m_viewportWidth * zoomFactor);
int newHeight = static_cast<int>(m_viewportHeight * zoomFactor);
setRenderBufferSize(newWidth, newHeight);
}
else
fill();
// reset clip paths
TQDictIterator<CanvasClipPath> itr(m_clipPaths);
for(; itr.current(); ++itr)
(*itr)->update(UPDATE_TRANSFORM);
m_zoom = zoomFactor;
TQWMatrix mtx;
mtx.translate(m_pan.x(), m_pan.y());
mtx.scale(m_zoom, m_zoom);
TQRect r(0, 0, m_width, m_height);
TQRect r2 = mtx.invert().map(r);
// zoom all items
for(unsigned int i = 0; i < m_items.count(); i++)
m_items.at(i)->update(UPDATE_ZOOM);
// recalc items
CanvasItemList drawables;
TQPtrListIterator<CanvasItem> it = m_items;
for(int j = r2.top() / m_chunkSizeVer; j <= (r2.bottom() / m_chunkSizeVer); j++)
{
for(int i = r2.left() / m_chunkSizeHor; i <= (r2.right() / m_chunkSizeHor); i++)
{
CanvasChunk *chunk = m_chunkManager.getChunk(i, j);
if(chunk)
{
for(CanvasItemList::ConstIterator it = chunk->list().begin(); it != chunk->list().end(); ++it)
{
if(!drawables.contains(*it))
drawables.append(*it);
}
}
}
}
drawables.sort();
for(CanvasItemList::Iterator it = drawables.begin(); it != drawables.end(); ++it)
(*it)->draw();
if(m_drawWindow)
blit(TQRect(0, 0, m_width, m_height), false);
m_dirtyChunks.clear();
#ifdef USE_TIMER
kdDebug(26000) << k_funcinfo << " Total time: " << t.elapsed() << endl;
#endif
}
void KSVGCanvas::reset()
{
m_items.clear();
m_chunkManager.clear();
m_chunksByItem.clear();
m_dirtyChunks.clear();
m_pan.setX(0);
m_pan.setY(0);
m_zoom = 1;
}
void KSVGCanvas::update()
{
#ifdef USE_TIMER
TQTime t;
t.start();
#endif
TQWMatrix mtx;
mtx.translate(m_pan.x(), m_pan.y());
mtx.scale(m_zoom, m_zoom);
// Process dirty chunks
TQPtrList<CanvasChunk> chunkList;
CanvasItemList drawables;
for(unsigned int i = 0; i < m_dirtyChunks.count(); i++)
{
CanvasChunk *chunk = m_dirtyChunks[i];
Q_ASSERT(chunk->isDirty());
TQRect r = chunk->bbox();
TQRect chunkbox(mtx.map(r.topLeft()), mtx.map(r.bottomRight()));
clear(chunkbox);
chunkList.append(chunk);
for(CanvasItemList::ConstIterator it = chunk->list().begin(); it != chunk->list().end(); ++it)
{
// kdDebug(26005) << k_funcinfo << " Checking: " << *it << endl;
if(!drawables.contains(*it))
{
// kdDebug(26005) << k_funcinfo << " Yes, appending to update list!" << endl;
drawables.append(*it);
}
}
chunk->unsetDirty();
}
drawables.sort();
// Draw dirty chunks
for(CanvasItemList::Iterator it = drawables.begin(); it != drawables.end(); ++it)
{
// kdDebug(26005) << " Need to redraw dirty : " << (*it) << " with z : " << (*it)->zIndex() << endl;
(*it)->draw();
}
// Blit dirty chunks
TQPtrListIterator<CanvasChunk> it = chunkList;
for(it.toFirst(); it.current(); ++it)
{
TQRect r = (*it)->bbox();
TQRect chunkbox(mtx.map(r.topLeft()), mtx.map(r.bottomRight()));
blit(chunkbox, false);
}
m_dirtyChunks.clear();
#ifdef USE_TIMER
kdDebug(26005) << k_funcinfo << " Total time: " << t.elapsed() << endl;
#endif
}
CanvasItemList KSVGCanvas::collisions(const TQPoint &p, bool exact) const
{
TQWMatrix mtx;
mtx.translate(m_pan.x(), m_pan.y());
mtx.scale(m_zoom, m_zoom);
TQPoint p2 = mtx.invert().map(p);
if(p2.x() < 0 || p2.y() < 0)
return CanvasItemList();
unsigned int x = p2.x() / int(m_chunkSizeHor);
unsigned int y = p2.y() / int(m_chunkSizeVer);
CanvasItemList result;
CanvasChunk *chunk = m_chunkManager.getChunk(x, y);
if(!chunk)
return result;
CanvasItemList list = chunk->list();
if(exact)
{
for(CanvasItemList::Iterator it = list.begin(); it != list.end(); ++it)
{
if((*it)->fillContains(p) || (*it)->strokeContains(p) || (*it)->bbox().contains(p))
result.append(*it);
}
return result;
}
else
return list;
}
void KSVGCanvas::blit(const TQRect &rect, bool direct)
{
if(m_drawWindow && m_width && m_height)
{
// clamp to viewport
int x0 = rect.x();
x0 = TQMAX(x0, 0);
x0 = TQMIN(x0, int(m_width - 1));
int y0 = rect.y();
y0 = TQMAX(y0, 0);
y0 = TQMIN(y0, int(m_height - 1));
int x1 = rect.x() + rect.width() + 1;
x1 = TQMAX(x1, 0);
x1 = TQMIN(x1, int(m_width));
int y1 = rect.y() + rect.height() + 1;
y1 = TQMAX(y1, 0);
y1 = TQMIN(y1, int(m_height));
xlib_draw_rgb_image(direct ? m_directWindow->handle() : m_drawWindow->handle(), m_gc, x0, y0, x1 - x0, y1 - y0, XLIB_RGB_DITHER_NONE, m_buffer + (m_width * y0 + x0) * m_nrChannels, m_width * m_nrChannels);
}
}
void KSVGCanvas::blit()
{
return blit(TQRect(0, 0, m_width, m_height), false);
}
void KSVGCanvas::ChunkManager::addChunk(CanvasChunk *chunk)
{
TQString key = TQString("%1 %2").tqarg(chunk->x()).tqarg(chunk->y());
// kdDebug(26005) << k_funcinfo << "Adding chunk : " << chunk << endl;
m_chunks.insert(key, chunk);
}
CanvasChunk *KSVGCanvas::ChunkManager::getChunk(short x, short y) const
{
// kdDebug(26005) << k_funcinfo << "getting chunk from : " << x << ", " << y << endl;
TQString key = TQString("%1 %2").tqarg(x).tqarg(y);
return m_chunks[key];
}
void KSVGCanvas::ChunkManager::clear()
{
m_chunks.clear();
}
// vim:ts=4:noet
|