Qt 4.8
qscreen_qws.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qplatformdefs.h"
43 #include "qscreen_qws.h"
44 
45 #include "qcolormap.h"
47 #include "qwindowsystem_qws.h"
48 #include "qwidget.h"
49 #include "qcolor.h"
50 #include "qpixmap.h"
51 #include "qvarlengtharray.h"
52 #include "qwsdisplay_qws.h"
53 #include "qpainter.h"
54 #include <private/qdrawhelper_p.h>
55 #include <private/qpaintengine_raster_p.h>
56 #include <private/qpixmap_raster_p.h>
57 #include <private/qwindowsurface_qws_p.h>
58 #include <private/qpainter_p.h>
59 #include <private/qwidget_p.h>
60 #include <private/qgraphicssystem_qws_p.h>
61 
63 
64 // #define QT_USE_MEMCPY_DUFF
65 
66 #ifndef QT_NO_QWS_CURSOR
68 #endif
70 
72 
73 #ifndef QT_NO_QWS_CURSOR
74 
128 {
130  size = QSize(0,0);
131  enable = true;
132  hwaccel = false;
133  supportsAlpha = true;
134 }
135 
140 {
141 }
142 
149 {
150  if (enable) {
151  enable = false;
152  if (!hwaccel)
154  }
155 }
156 
163 {
164  if (!enable) {
165  enable = true;
166  if (!hwaccel)
168  }
169 }
170 
180 void QScreenCursor::set(const QImage &image, int hotx, int hoty)
181 {
182  const QRect r = boundingRect();
183 
184  hotspot = QPoint(hotx, hoty);
185  // These are in almost all cases the fastest formats to blend
186  QImage::Format f;
187  switch (qt_screen->depth()) {
188  case 12:
190  break;
191  case 15:
193  break;
194  case 16:
196  break;
197  case 18:
199  break;
200  default:
202  }
203 
204  cursor = image.convertToFormat(f);
205 
206  size = image.size();
207 
208  if (enable && !hwaccel)
210 }
211 
221 void QScreenCursor::move(int x, int y)
222 {
223  QRegion r = boundingRect();
224  pos = QPoint(x,y);
225  if (enable && !hwaccel) {
226  r |= boundingRect();
227  qt_screen->exposeRegion(r, 0);
228  }
229 }
230 
231 
248 {
250 }
251 
252 
253 #endif // QT_NO_QWS_CURSOR
254 
255 
303 /*
304  \variable QScreenCursor::cursor
305 
306  \brief the cursor's image.
307 
308  \sa image()
309 */
310 
311 /*
312  \variable QScreenCursor::size
313 
314  \brief the cursor's size
315 */
316 
317 /*
318  \variable QScreenCursor::pos
319 
320  \brief the cursor's position, i.e., the position of the top-left
321  corner of the crsor's image
322 
323  \sa set(), move()
324 */
325 
326 /*
327  \variable QScreenCursor::hotspot
328 
329  \brief the cursor's hotspot, i.e., the point within the cursor's
330  image that will be the position of the associated mouse events.
331 
332  \sa set(), move()
333 */
334 
335 /*
336  \variable QScreenCursor::enable
337 
338  \brief whether the cursor is visible or not
339 
340  \sa isVisible()
341 */
342 
343 /*
344  \variable QScreenCursor::hwaccel
345 
346  \brief holds whether the cursor is accelerated or not
347 
348  If the cursor is not accelerated, its image will be included by
349  the screen when it composites the window surfaces.
350 
351  \sa isAccelerated()
352 
353 */
354 
355 /*
356  \variable QScreenCursor::supportsAlpha
357 */
358 
375 {
376 public:
378  ~QScreenPrivate();
379 
380  inline QImage::Format preferredImageFormat() const;
381 
382  typedef void (*SolidFillFunc)(QScreen*, const QColor&, const QRegion&);
383  typedef void (*BlitFunc)(QScreen*, const QImage&, const QPoint&, const QRegion&);
384 
385  SolidFillFunc solidFill;
387 
388  QPoint offset;
394 #if Q_BYTE_ORDER == Q_BIG_ENDIAN
396 #endif
397 #ifdef QT_QWS_CLIENTBLIT
398  bool supportsBlitInClients;
399 #endif
400  int classId;
401  QScreen *q_ptr;
402 };
403 
404 template <typename T>
405 static void solidFill_template(QScreen *screen, const QColor &color,
406  const QRegion &region)
407 {
408  T *dest = reinterpret_cast<T*>(screen->base());
409  const T c = qt_colorConvert<T, quint32>(color.rgba(), 0);
410  const int stride = screen->linestep();
411  const QVector<QRect> rects = region.rects();
412 
413  for (int i = 0; i < rects.size(); ++i) {
414  const QRect r = rects.at(i);
415  qt_rectfill(dest, c, r.x(), r.y(), r.width(), r.height(), stride);
416  }
417 }
418 
419 #ifdef QT_QWS_DEPTH_GENERIC
420 static void solidFill_rgb_32bpp(QScreen *screen, const QColor &color,
421  const QRegion &region)
422 {
423  quint32 *dest = reinterpret_cast<quint32*>(screen->base());
424  const quint32 c = qt_convertToRgb<quint32>(color.rgba());
425 
426  const int stride = screen->linestep();
427  const QVector<QRect> rects = region.rects();
428 
429  for (int i = 0; i < rects.size(); ++i) {
430  const QRect r = rects.at(i);
431  qt_rectfill(dest, c, r.x(), r.y(), r.width(), r.height(), stride);
432  }
433 }
434 
435 static void solidFill_rgb_16bpp(QScreen *screen, const QColor &color,
436  const QRegion &region)
437 {
438  quint16 *dest = reinterpret_cast<quint16*>(screen->base());
439  const quint16 c = qt_convertToRgb<quint32>(color.rgba());
440 
441  const int stride = screen->linestep();
442  const QVector<QRect> rects = region.rects();
443 
444  for (int i = 0; i < rects.size(); ++i) {
445  const QRect r = rects.at(i);
446  qt_rectfill(dest, c, r.x(), r.y(), r.width(), r.height(), stride);
447  }
448 }
449 #endif // QT_QWS_DEPTH_GENERIC
450 
451 #ifdef QT_QWS_DEPTH_4
452 static inline void qt_rectfill_gray4(quint8 *dest, quint8 value,
453  int x, int y, int width, int height,
454  int stride)
455 {
456  const int pixelsPerByte = 2;
457  dest += y * stride + x / pixelsPerByte;
458  const int doAlign = x & 1;
459  const int doTail = (width - doAlign) & 1;
460  const int width8 = (width - doAlign) / pixelsPerByte;
461 
462  for (int j = 0; j < height; ++j) {
463  if (doAlign)
464  *dest = (*dest & 0xf0) | (value & 0x0f);
465  if (width8)
466  qt_memfill<quint8>(dest + doAlign, value, width8);
467  if (doTail) {
468  quint8 *d = dest + doAlign + width8;
469  *d = (*d & 0x0f) | (value & 0xf0);
470  }
471  dest += stride;
472  }
473 }
474 
475 static void solidFill_gray4(QScreen *screen, const QColor &color,
476  const QRegion &region)
477 {
478  quint8 *dest = reinterpret_cast<quint8*>(screen->base());
479  const quint8 c = qGray(color.rgba()) >> 4;
480  const quint8 c8 = (c << 4) | c;
481 
482  const int stride = screen->linestep();
483  const QVector<QRect> rects = region.rects();
484 
485  for (int i = 0; i < rects.size(); ++i) {
486  const QRect r = rects.at(i);
487  qt_rectfill_gray4(dest, c8, r.x(), r.y(), r.width(), r.height(),
488  stride);
489  }
490 }
491 #endif // QT_QWS_DEPTH_4
492 
493 #ifdef QT_QWS_DEPTH_1
494 static inline void qt_rectfill_mono(quint8 *dest, quint8 value,
495  int x, int y, int width, int height,
496  int stride)
497 {
498  const int pixelsPerByte = 8;
499  const int alignWidth = qMin(width, (8 - (x & 7)) & 7);
500  const int doAlign = (alignWidth > 0 ? 1 : 0);
501  const int alignStart = pixelsPerByte - 1 - (x & 7);
502  const int alignStop = alignStart - (alignWidth - 1);
503  const quint8 alignMask = ((1 << alignWidth) - 1) << alignStop;
504  const int tailWidth = (width - alignWidth) & 7;
505  const int doTail = (tailWidth > 0 ? 1 : 0);
506  const quint8 tailMask = (1 << (pixelsPerByte - tailWidth)) - 1;
507  const int width8 = (width - alignWidth) / pixelsPerByte;
508 
509  dest += y * stride + x / pixelsPerByte;
510  stride -= (doAlign + width8);
511 
512  for (int j = 0; j < height; ++j) {
513  if (doAlign) {
514  *dest = (*dest & ~alignMask) | (value & alignMask);
515  ++dest;
516  }
517  if (width8) {
518  qt_memfill<quint8>(dest, value, width8);
519  dest += width8;
520  }
521  if (doTail)
522  *dest = (*dest & tailMask) | (value & ~tailMask);
523  dest += stride;
524  }
525 }
526 
527 static void solidFill_mono(QScreen *screen, const QColor &color,
528  const QRegion &region)
529 {
530  quint8 *dest = reinterpret_cast<quint8*>(screen->base());
531  const quint8 c8 = (qGray(color.rgba()) >> 7) * 0xff;
532 
533  const int stride = screen->linestep();
534  const QVector<QRect> rects = region.rects();
535 
536  for (int i = 0; i < rects.size(); ++i) {
537  const QRect r = rects.at(i);
538  qt_rectfill_mono(dest, c8, r.x(), r.y(), r.width(), r.height(),
539  stride);
540  }
541 }
542 #endif // QT_QWS_DEPTH_1
543 
544 void qt_solidFill_setup(QScreen *screen, const QColor &color,
545  const QRegion &region)
546 {
547  switch (screen->depth()) {
548 #ifdef QT_QWS_DEPTH_32
549  case 32:
550  if (screen->pixelType() == QScreen::NormalPixel)
551  screen->d_ptr->solidFill = solidFill_template<quint32>;
552  else
553  screen->d_ptr->solidFill = solidFill_template<qabgr8888>;
554  break;
555 #endif
556 #ifdef QT_QWS_DEPTH_24
557  case 24:
558  if (screen->pixelType() == QScreen::NormalPixel)
559  screen->d_ptr->solidFill = solidFill_template<qrgb888>;
560  else
561  screen->d_ptr->solidFill = solidFill_template<quint24>;
562  break;
563 #endif
564 #ifdef QT_QWS_DEPTH_18
565  case 18:
566  screen->d_ptr->solidFill = solidFill_template<quint18>;
567  break;
568 #endif
569 #ifdef QT_QWS_DEPTH_16
570  case 16:
571  if (screen->pixelType() == QScreen::NormalPixel)
572  screen->d_ptr->solidFill = solidFill_template<quint16>;
573  else
574  screen->d_ptr->solidFill = solidFill_template<qbgr565>;
575  break;
576 #endif
577 #ifdef QT_QWS_DEPTH_15
578  case 15:
579  if (screen->pixelType() == QScreen::NormalPixel)
580  screen->d_ptr->solidFill = solidFill_template<qrgb555>;
581  else
582  screen->d_ptr->solidFill = solidFill_template<qbgr555>;
583  break;
584 #endif
585 #ifdef QT_QWS_DEPTH_12
586  case 12:
587  screen->d_ptr->solidFill = solidFill_template<qrgb444>;
588  break;
589 #endif
590 #ifdef QT_QWS_DEPTH_8
591  case 8:
592  screen->d_ptr->solidFill = solidFill_template<quint8>;
593  break;
594 #endif
595 #ifdef QT_QWS_DEPTH_4
596  case 4:
597  screen->d_ptr->solidFill = solidFill_gray4;
598  break;
599 #endif
600 #ifdef QT_QWS_DEPTH_1
601  case 1:
602  screen->d_ptr->solidFill = solidFill_mono;
603  break;
604 #endif
605  default:
606  qFatal("solidFill_setup(): Screen depth %d not supported!",
607  screen->depth());
608  screen->d_ptr->solidFill = 0;
609  break;
610  }
611  screen->d_ptr->solidFill(screen, color, region);
612 }
613 
614 template <typename DST, typename SRC>
615 static void blit_template(QScreen *screen, const QImage &image,
616  const QPoint &topLeft, const QRegion &region)
617 {
618  DST *dest = reinterpret_cast<DST*>(screen->base());
619  const int screenStride = screen->linestep();
620  const int imageStride = image.bytesPerLine();
621 
622  if (region.rectCount() == 1) {
623  const QRect r = region.boundingRect();
624  const SRC *src = reinterpret_cast<const SRC*>(image.scanLine(r.y()))
625  + r.x();
626  qt_rectconvert<DST, SRC>(dest, src,
627  r.x() + topLeft.x(), r.y() + topLeft.y(),
628  r.width(), r.height(),
629  screenStride, imageStride);
630  } else {
631  const QVector<QRect> rects = region.rects();
632 
633  for (int i = 0; i < rects.size(); ++i) {
634  const QRect r = rects.at(i);
635  const SRC *src = reinterpret_cast<const SRC*>(image.scanLine(r.y()))
636  + r.x();
637  qt_rectconvert<DST, SRC>(dest, src,
638  r.x() + topLeft.x(), r.y() + topLeft.y(),
639  r.width(), r.height(),
640  screenStride, imageStride);
641  }
642  }
643 }
644 
645 #ifdef QT_QWS_DEPTH_32
646 static void blit_32(QScreen *screen, const QImage &image,
647  const QPoint &topLeft, const QRegion &region)
648 {
649  switch (image.format()) {
653  blit_template<quint32, quint32>(screen, image, topLeft, region);
654  return;
655 #ifdef QT_QWS_DEPTH_16
657  blit_template<quint32, quint16>(screen, image, topLeft, region);
658  return;
659 #endif
660  default:
661  qCritical("blit_32(): Image format %d not supported!", image.format());
662  }
663 }
664 #endif // QT_QWS_DEPTH_32
665 
666 #ifdef QT_QWS_DEPTH_24
667 static void blit_24(QScreen *screen, const QImage &image,
668  const QPoint &topLeft, const QRegion &region)
669 {
670  switch (image.format()) {
674  blit_template<quint24, quint32>(screen, image, topLeft, region);
675  return;
677  blit_template<quint24, qrgb888>(screen, image, topLeft, region);
678  return;
679 #ifdef QT_QWS_DEPTH_16
681  blit_template<quint24, quint16>(screen, image, topLeft, region);
682  return;
683 #endif
684  default:
685  qCritical("blit_24(): Image format %d not supported!", image.format());
686  }
687 }
688 
689 static void blit_qrgb888(QScreen *screen, const QImage &image,
690  const QPoint &topLeft, const QRegion &region)
691 {
692  switch (image.format()) {
696  blit_template<qrgb888, quint32>(screen, image, topLeft, region);
697  return;
699  blit_template<qrgb888, qrgb888>(screen, image, topLeft, region);
700  return;
701 #ifdef QT_QWS_DEPTH_16
703  blit_template<qrgb888, quint16>(screen, image, topLeft, region);
704  return;
705 #endif
706  default:
707  qCritical("blit_24(): Image format %d not supported!", image.format());
708  break;
709  }
710 }
711 #endif // QT_QWS_DEPTH_24
712 
713 #ifdef QT_QWS_DEPTH_18
714 static void blit_18(QScreen *screen, const QImage &image,
715  const QPoint &topLeft, const QRegion &region)
716 {
717  switch (image.format()) {
721  blit_template<qrgb666, quint32>(screen, image, topLeft, region);
722  return;
724  blit_template<qrgb666, qrgb666>(screen, image, topLeft, region);
725  return;
726 #ifdef QT_QWS_DEPTH_16
728  blit_template<qrgb666, quint16>(screen, image, topLeft, region);
729  return;
730 #endif
731  default:
732  qCritical("blit_18(): Image format %d not supported!", image.format());
733  }
734 }
735 #endif // QT_QWS_DEPTH_18
736 
737 #if (Q_BYTE_ORDER == Q_BIG_ENDIAN) && (defined(QT_QWS_DEPTH_16) || defined(QT_QWS_DEPTH_15))
738 class quint16LE
739 {
740 public:
741  inline quint16LE(quint32 v) {
742  data = ((v & 0xff00) >> 8) | ((v & 0x00ff) << 8);
743  }
744 
745  inline quint16LE(int v) {
746  data = ((v & 0xff00) >> 8) | ((v & 0x00ff) << 8);
747  }
748 
749  inline quint16LE(quint16 v) {
750  data = ((v & 0xff00) >> 8) | ((v & 0x00ff) << 8);
751  }
752 
753  inline quint16LE(qrgb555 v) {
754  data = (( (quint16)v & 0xff00) >> 8) |
755  (( (quint16)v & 0x00ff) << 8);
756  }
757 
758  inline bool operator==(const quint16LE &v) const
759  {
760  return data == v.data;
761  }
762 
763 private:
764  quint16 data;
765 };
766 #endif
767 
768 #ifdef QT_QWS_DEPTH_16
769 static void blit_16(QScreen *screen, const QImage &image,
770  const QPoint &topLeft, const QRegion &region)
771 {
772  switch (image.format()) {
776  // ### This probably doesn't work but it's a case which should never happen
777  blit_template<quint16, quint32>(screen, image, topLeft, region);
778  return;
780  blit_template<quint16, quint16>(screen, image, topLeft, region);
781  return;
782  default:
783  qCritical("blit_16(): Image format %d not supported!", image.format());
784  }
785 }
786 
787 #if Q_BYTE_ORDER == Q_BIG_ENDIAN
788 static void blit_16_bigToLittleEndian(QScreen *screen, const QImage &image,
789  const QPoint &topLeft,
790  const QRegion &region)
791 {
792  switch (image.format()) {
796  blit_template<quint16LE, quint32>(screen, image, topLeft, region);
797  return;
799  blit_template<quint16LE, quint16>(screen, image, topLeft, region);
800  return;
801  default:
802  qCritical("blit_16_bigToLittleEndian(): Image format %d not supported!", image.format());
803  }
804 }
805 
806 #endif // Q_BIG_ENDIAN
807 #endif // QT_QWS_DEPTH_16
808 
809 #ifdef QT_QWS_DEPTH_15
810 static void blit_15(QScreen *screen, const QImage &image,
811  const QPoint &topLeft, const QRegion &region)
812 {
813  switch (image.format()) {
817  blit_template<qrgb555, quint32>(screen, image, topLeft, region);
818  return;
820  blit_template<qrgb555, qrgb555>(screen, image, topLeft, region);
821  return;
823  blit_template<qrgb555, quint16>(screen, image, topLeft, region);
824  return;
825  default:
826  qCritical("blit_15(): Image format %d not supported!", image.format());
827  }
828 }
829 
830 #if Q_BYTE_ORDER == Q_BIG_ENDIAN
831 static void blit_15_bigToLittleEndian(QScreen *screen, const QImage &image,
832  const QPoint &topLeft,
833  const QRegion &region)
834 {
835  switch (image.format()) {
837  blit_template<quint16LE, qrgb555>(screen, image, topLeft, region);
838  return;
839  default:
840  qCritical("blit_15_bigToLittleEndian(): Image format %d not supported!", image.format());
841  }
842 }
843 #endif // Q_BIG_ENDIAN
844 #endif // QT_QWS_DEPTH_15
845 
846 
847 #ifdef QT_QWS_DEPTH_12
848 static void blit_12(QScreen *screen, const QImage &image,
849  const QPoint &topLeft, const QRegion &region)
850 {
851  switch (image.format()) {
853  blit_template<qrgb444, qargb4444>(screen, image, topLeft, region);
854  return;
856  blit_template<qrgb444, qrgb444>(screen, image, topLeft, region);
857  return;
858  default:
859  qCritical("blit_12(): Image format %d not supported!", image.format());
860  }
861 }
862 #endif // QT_QWS_DEPTH_12
863 
864 #ifdef QT_QWS_DEPTH_8
865 static void blit_8(QScreen *screen, const QImage &image,
866  const QPoint &topLeft, const QRegion &region)
867 {
868  switch (image.format()) {
872  blit_template<quint8, quint32>(screen, image, topLeft, region);
873  return;
875  blit_template<quint8, quint16>(screen, image, topLeft, region);
876  return;
878  blit_template<quint8, qargb4444>(screen, image, topLeft, region);
879  return;
881  blit_template<quint8, qrgb444>(screen, image, topLeft, region);
882  return;
883  default:
884  qCritical("blit_8(): Image format %d not supported!", image.format());
885  }
886 }
887 #endif // QT_QWS_DEPTH_8
888 
889 #ifdef QT_QWS_DEPTH_4
890 
891 struct qgray4 { quint8 dummy; } Q_PACKED;
892 
893 template <typename SRC>
894 Q_STATIC_TEMPLATE_FUNCTION inline quint8 qt_convertToGray4(SRC color);
895 
896 template <>
897 inline quint8 qt_convertToGray4(quint32 color)
898 {
899  return qGray(color) >> 4;
900 }
901 
902 template <>
903 inline quint8 qt_convertToGray4(quint16 color)
904 {
905  const int r = (color & 0xf800) >> 11;
906  const int g = (color & 0x07e0) >> 6; // only keep 5 bit
907  const int b = (color & 0x001f);
908  return (r * 11 + g * 16 + b * 5) >> 6;
909 }
910 
911 template <>
912 inline quint8 qt_convertToGray4(qrgb444 color)
913 {
914  return qt_convertToGray4(quint32(color));
915 }
916 
917 template <>
918 inline quint8 qt_convertToGray4(qargb4444 color)
919 {
920  return qt_convertToGray4(quint32(color));
921 }
922 
923 template <typename SRC>
924 Q_STATIC_TEMPLATE_FUNCTION inline void qt_rectconvert_gray4(qgray4 *dest4, const SRC *src,
925  int x, int y, int width, int height,
926  int dstStride, int srcStride)
927 {
928  const int pixelsPerByte = 2;
929  quint8 *dest8 = reinterpret_cast<quint8*>(dest4)
930  + y * dstStride + x / pixelsPerByte;
931  const int doAlign = x & 1;
932  const int doTail = (width - doAlign) & 1;
933  const int width8 = (width - doAlign) / pixelsPerByte;
934  const int count8 = (width8 + 3) / 4;
935 
936  srcStride = srcStride / sizeof(SRC) - width;
937  dstStride -= (width8 + doAlign);
938 
939  for (int i = 0; i < height; ++i) {
940  if (doAlign) {
941  *dest8 = (*dest8 & 0xf0) | qt_convertToGray4<SRC>(*src++);
942  ++dest8;
943  }
944  if (count8) {
945  int n = count8;
946  switch (width8 & 0x03) // duff's device
947  {
948  case 0: do { *dest8++ = qt_convertToGray4<SRC>(src[0]) << 4
949  | qt_convertToGray4<SRC>(src[1]);
950  src += 2;
951  case 3: *dest8++ = qt_convertToGray4<SRC>(src[0]) << 4
952  | qt_convertToGray4<SRC>(src[1]);
953  src += 2;
954  case 2: *dest8++ = qt_convertToGray4<SRC>(src[0]) << 4
955  | qt_convertToGray4<SRC>(src[1]);
956  src += 2;
957  case 1: *dest8++ = qt_convertToGray4<SRC>(src[0]) << 4
958  | qt_convertToGray4<SRC>(src[1]);
959  src += 2;
960  } while (--n > 0);
961  }
962  }
963 
964  if (doTail)
965  *dest8 = qt_convertToGray4<SRC>(*src++) << 4 | (*dest8 & 0x0f);
966 
967  dest8 += dstStride;
968  src += srcStride;
969  }
970 }
971 
972 template <>
973 void qt_rectconvert(qgray4 *dest, const quint32 *src,
974  int x, int y, int width, int height,
975  int dstStride, int srcStride)
976 {
977  qt_rectconvert_gray4<quint32>(dest, src, x, y, width, height,
978  dstStride, srcStride);
979 }
980 
981 template <>
982 void qt_rectconvert(qgray4 *dest, const quint16 *src,
983  int x, int y, int width, int height,
984  int dstStride, int srcStride)
985 {
986  qt_rectconvert_gray4<quint16>(dest, src, x, y, width, height,
987  dstStride, srcStride);
988 }
989 
990 template <>
991 void qt_rectconvert(qgray4 *dest, const qrgb444 *src,
992  int x, int y, int width, int height,
993  int dstStride, int srcStride)
994 {
995  qt_rectconvert_gray4<qrgb444>(dest, src, x, y, width, height,
996  dstStride, srcStride);
997 }
998 
999 template <>
1000 void qt_rectconvert(qgray4 *dest, const qargb4444 *src,
1001  int x, int y, int width, int height,
1002  int dstStride, int srcStride)
1003 {
1004  qt_rectconvert_gray4<qargb4444>(dest, src, x, y, width, height,
1005  dstStride, srcStride);
1006 }
1007 
1008 static void blit_4(QScreen *screen, const QImage &image,
1009  const QPoint &topLeft, const QRegion &region)
1010 {
1011  switch (image.format()) {
1013  blit_template<qgray4, quint32>(screen, image, topLeft, region);
1014  return;
1015  case QImage::Format_RGB16:
1016  blit_template<qgray4, quint16>(screen, image, topLeft, region);
1017  return;
1018  case QImage::Format_RGB444:
1019  blit_template<qgray4, qrgb444>(screen, image, topLeft, region);
1020  return;
1022  blit_template<qgray4, qargb4444>(screen, image, topLeft, region);
1023  return;
1024  default:
1025  qCritical("blit_4(): Image format %d not supported!", image.format());
1026  }
1027 }
1028 #endif // QT_QWS_DEPTH_4
1029 
1030 #ifdef QT_QWS_DEPTH_1
1031 
1032 struct qmono { quint8 dummy; } Q_PACKED;
1033 
1034 template <typename SRC>
1035 Q_STATIC_TEMPLATE_FUNCTION inline quint8 qt_convertToMono(SRC color);
1036 
1037 template <>
1038 inline quint8 qt_convertToMono(quint32 color)
1039 {
1040  return qGray(color) >> 7;
1041 }
1042 
1043 template <>
1044 inline quint8 qt_convertToMono(quint16 color)
1045 {
1046  return (qGray(qt_colorConvert<quint32, quint16>(color, 0)) >> 7);
1047 }
1048 
1049 template <>
1050 inline quint8 qt_convertToMono(qargb4444 color)
1051 {
1052  return (qGray(quint32(color)) >> 7);
1053 }
1054 
1055 template <>
1056 inline quint8 qt_convertToMono(qrgb444 color)
1057 {
1058  return (qGray(quint32(color)) >> 7);
1059 }
1060 
1061 template <typename SRC>
1062 inline void qt_rectconvert_mono(qmono *dest, const SRC *src,
1063  int x, int y, int width, int height,
1064  int dstStride, int srcStride)
1065 {
1066  const int pixelsPerByte = 8;
1067  quint8 *dest8 = reinterpret_cast<quint8*>(dest)
1068  + y * dstStride + x / pixelsPerByte;
1069  const int alignWidth = qMin(width, (8 - (x & 7)) & 7);
1070  const int doAlign = (alignWidth > 0 ? 1 : 0);
1071  const int alignStart = pixelsPerByte - 1 - (x & 7);
1072  const int alignStop = alignStart - (alignWidth - 1);
1073  const quint8 alignMask = ((1 << alignWidth) - 1) << alignStop;
1074  const int tailWidth = (width - alignWidth) & 7;
1075  const int doTail = (tailWidth > 0 ? 1 : 0);
1076  const quint8 tailMask = (1 << (pixelsPerByte - tailWidth)) - 1;
1077  const int width8 = (width - alignWidth) / pixelsPerByte;
1078 
1079  srcStride = srcStride / sizeof(SRC) - (width8 * 8 + alignWidth);
1080  dstStride -= (width8 + doAlign);
1081 
1082  for (int j = 0; j < height; ++j) {
1083  if (doAlign) {
1084  quint8 d = *dest8 & ~alignMask;
1085  for (int i = alignStart; i >= alignStop; --i)
1086  d |= qt_convertToMono<SRC>(*src++) << i;
1087  *dest8++ = d;
1088  }
1089  for (int i = 0; i < width8; ++i) {
1090  *dest8 = (qt_convertToMono<SRC>(src[0]) << 7)
1091  | (qt_convertToMono<SRC>(src[1]) << 6)
1092  | (qt_convertToMono<SRC>(src[2]) << 5)
1093  | (qt_convertToMono<SRC>(src[3]) << 4)
1094  | (qt_convertToMono<SRC>(src[4]) << 3)
1095  | (qt_convertToMono<SRC>(src[5]) << 2)
1096  | (qt_convertToMono<SRC>(src[6]) << 1)
1097  | (qt_convertToMono<SRC>(src[7]));
1098  src += 8;
1099  ++dest8;
1100  }
1101  if (doTail) {
1102  quint8 d = *dest8 & tailMask;
1103  switch (tailWidth) {
1104  case 7: d |= qt_convertToMono<SRC>(src[6]) << 1;
1105  case 6: d |= qt_convertToMono<SRC>(src[5]) << 2;
1106  case 5: d |= qt_convertToMono<SRC>(src[4]) << 3;
1107  case 4: d |= qt_convertToMono<SRC>(src[3]) << 4;
1108  case 3: d |= qt_convertToMono<SRC>(src[2]) << 5;
1109  case 2: d |= qt_convertToMono<SRC>(src[1]) << 6;
1110  case 1: d |= qt_convertToMono<SRC>(src[0]) << 7;
1111  }
1112  *dest8 = d;
1113  }
1114 
1115  dest8 += dstStride;
1116  src += srcStride;
1117  }
1118 }
1119 
1120 template <>
1121 void qt_rectconvert(qmono *dest, const quint32 *src,
1122  int x, int y, int width, int height,
1123  int dstStride, int srcStride)
1124 {
1125  qt_rectconvert_mono<quint32>(dest, src, x, y, width, height,
1126  dstStride, srcStride);
1127 }
1128 
1129 template <>
1130 void qt_rectconvert(qmono *dest, const quint16 *src,
1131  int x, int y, int width, int height,
1132  int dstStride, int srcStride)
1133 {
1134  qt_rectconvert_mono<quint16>(dest, src, x, y, width, height,
1135  dstStride, srcStride);
1136 }
1137 
1138 template <>
1139 void qt_rectconvert(qmono *dest, const qrgb444 *src,
1140  int x, int y, int width, int height,
1141  int dstStride, int srcStride)
1142 {
1143  qt_rectconvert_mono<qrgb444>(dest, src, x, y, width, height,
1144  dstStride, srcStride);
1145 }
1146 
1147 template <>
1148 void qt_rectconvert(qmono *dest, const qargb4444 *src,
1149  int x, int y, int width, int height,
1150  int dstStride, int srcStride)
1151 {
1152  qt_rectconvert_mono<qargb4444>(dest, src, x, y, width, height,
1153  dstStride, srcStride);
1154 }
1155 
1156 static void blit_1(QScreen *screen, const QImage &image,
1157  const QPoint &topLeft, const QRegion &region)
1158 {
1159  switch (image.format()) {
1161  blit_template<qmono, quint32>(screen, image, topLeft, region);
1162  return;
1163  case QImage::Format_RGB16:
1164  blit_template<qmono, quint16>(screen, image, topLeft, region);
1165  return;
1166  case QImage::Format_RGB444:
1167  blit_template<qmono, qrgb444>(screen, image, topLeft, region);
1168  return;
1170  blit_template<qmono, qargb4444>(screen, image, topLeft, region);
1171  return;
1172  default:
1173  qCritical("blit_1(): Image format %d not supported!", image.format());
1174  }
1175 }
1176 #endif // QT_QWS_DEPTH_1
1177 
1178 #ifdef QT_QWS_DEPTH_GENERIC
1179 
1180 static void blit_rgb(QScreen *screen, const QImage &image,
1181  const QPoint &topLeft, const QRegion &region)
1182 {
1183  switch (image.format()) {
1185  blit_template<qrgb, quint32>(screen, image, topLeft, region);
1186  return;
1187  case QImage::Format_RGB16:
1188  blit_template<qrgb, quint16>(screen, image, topLeft, region);
1189  return;
1190  default:
1191  qCritical("blit_rgb(): Image format %d not supported!", image.format());
1192  }
1193 }
1194 
1195 void qt_set_generic_blit(QScreen *screen, int bpp,
1196  int len_red, int len_green, int len_blue, int len_alpha,
1197  int off_red, int off_green, int off_blue, int off_alpha)
1198 {
1199  qrgb::bpp = bpp / 8;
1200  qrgb::len_red = len_red;
1201  qrgb::len_green = len_green;
1202  qrgb::len_blue = len_blue;
1203  qrgb::len_alpha = len_alpha;
1204  qrgb::off_red = off_red;
1205  qrgb::off_green = off_green;
1206  qrgb::off_blue = off_blue;
1207  qrgb::off_alpha = off_alpha;
1208  screen->d_ptr->blit = blit_rgb;
1209  if (bpp == 16)
1210  screen->d_ptr->solidFill = solidFill_rgb_16bpp;
1211  else if (bpp == 32)
1212  screen->d_ptr->solidFill = solidFill_rgb_32bpp;
1213 }
1214 
1215 #endif // QT_QWS_DEPTH_GENERIC
1216 
1217 void qt_blit_setup(QScreen *screen, const QImage &image,
1218  const QPoint &topLeft, const QRegion &region)
1219 {
1220  switch (screen->depth()) {
1221 #ifdef QT_QWS_DEPTH_32
1222  case 32:
1223  if (screen->pixelType() == QScreen::NormalPixel)
1224  screen->d_ptr->blit = blit_32;
1225  else
1226  screen->d_ptr->blit = blit_template<qabgr8888, quint32>;
1227  break;
1228 #endif
1229 #ifdef QT_QWS_DEPTH_24
1230  case 24:
1231  if (screen->pixelType() == QScreen::NormalPixel)
1232  screen->d_ptr->blit = blit_qrgb888;
1233  else
1234  screen->d_ptr->blit = blit_24;
1235  break;
1236 #endif
1237 #ifdef QT_QWS_DEPTH_18
1238  case 18:
1239  screen->d_ptr->blit = blit_18;
1240  break;
1241 #endif
1242 #ifdef QT_QWS_DEPTH_16
1243  case 16:
1244 #if Q_BYTE_ORDER == Q_BIG_ENDIAN
1245  if (screen->d_ptr->fb_is_littleEndian)
1246  screen->d_ptr->blit = blit_16_bigToLittleEndian;
1247  else
1248 #endif
1249  if (screen->pixelType() == QScreen::NormalPixel)
1250  screen->d_ptr->blit = blit_16;
1251  else
1252  screen->d_ptr->blit = blit_template<qbgr565, quint16>;
1253  break;
1254 #endif
1255 #ifdef QT_QWS_DEPTH_15
1256  case 15:
1257 #if Q_BYTE_ORDER == Q_BIG_ENDIAN
1258  if (screen->d_ptr->fb_is_littleEndian)
1259  screen->d_ptr->blit = blit_15_bigToLittleEndian;
1260  else
1261 #endif // Q_BIG_ENDIAN
1262  if (screen->pixelType() == QScreen::NormalPixel)
1263  screen->d_ptr->blit = blit_15;
1264  else
1265  screen->d_ptr->blit = blit_template<qbgr555, qrgb555>;
1266  break;
1267 #endif
1268 #ifdef QT_QWS_DEPTH_12
1269  case 12:
1270  screen->d_ptr->blit = blit_12;
1271  break;
1272 #endif
1273 #ifdef QT_QWS_DEPTH_8
1274  case 8:
1275  screen->d_ptr->blit = blit_8;
1276  break;
1277 #endif
1278 #ifdef QT_QWS_DEPTH_4
1279  case 4:
1280  screen->d_ptr->blit = blit_4;
1281  break;
1282 #endif
1283 #ifdef QT_QWS_DEPTH_1
1284  case 1:
1285  screen->d_ptr->blit = blit_1;
1286  break;
1287 #endif
1288  default:
1289  qFatal("blit_setup(): Screen depth %d not supported!",
1290  screen->depth());
1291  screen->d_ptr->blit = 0;
1292  break;
1293  }
1294  screen->d_ptr->blit(screen, image, topLeft, region);
1295 }
1296 
1298  : defaultGraphicsSystem(QWSGraphicsSystem(parent)),
1299  pixelFormat(QImage::Format_Invalid),
1300 #ifdef QT_QWS_CLIENTBLIT
1301  supportsBlitInClients(false),
1302 #endif
1303  classId(id), q_ptr(parent)
1304 {
1306  blit = qt_blit_setup;
1307 #if Q_BYTE_ORDER == Q_BIG_ENDIAN
1308  fb_is_littleEndian = false;
1309 #endif
1310  pixmapFactory = 0;
1312 }
1313 
1315 {
1316 }
1317 
1319 {
1321  return pixelFormat;
1322 
1323  if (q_ptr->depth() <= 16)
1324  return QImage::Format_RGB16;
1325  else
1327 }
1328 
2099 // Unaccelerated screen/driver setup. Can be overridden by accelerated
2100 // drivers
2101 
2164  : screencols(0), data(0), entries(0), entryp(0), lowest(0),
2165  w(0), lstep(0), h(0), d(1), pixeltype(NormalPixel), grayscale(false),
2166  dw(0), dh(0), size(0), mapsize(0), displayId(display_id),
2167  physWidth(0), physHeight(0), d_ptr(new QScreenPrivate(this, classId))
2168 {
2169  clearCacheFunc = 0;
2170 }
2171 
2172 QScreen::QScreen(int display_id)
2173  : screencols(0), data(0), entries(0), entryp(0), lowest(0),
2174  w(0), lstep(0), h(0), d(1), pixeltype(NormalPixel), grayscale(false),
2175  dw(0), dh(0), size(0), mapsize(0), displayId(display_id),
2176  physWidth(0), physHeight(0), d_ptr(new QScreenPrivate(this))
2177 {
2178  clearCacheFunc = 0;
2179 }
2180 
2186 {
2187  delete d_ptr;
2188 }
2189 
2202 {
2203 #ifndef QT_NO_QWS_CURSOR
2204  if (qt_screencursor)
2205  qt_screencursor->hide();
2206 #endif
2207 }
2208 
2209 extern bool qws_accel; //in qapplication_qws.cpp
2210 
2226 {
2227  return d_ptr->pixelFormat;
2228 }
2229 
2234 {
2236 }
2237 
2238 
2255 int QScreen::alloc(unsigned int r,unsigned int g,unsigned int b)
2256 {
2257  int ret = 0;
2258  if (d == 8) {
2259  if (grayscale)
2260  return qGray(r, g, b);
2261 
2262  // First we look to see if we match a default color
2263  const int pos = (r + 25) / 51 * 36 + (g + 25) / 51 * 6 + (b + 25) / 51;
2264  if (pos < screencols && screenclut[pos] == qRgb(r, g, b)) {
2265  return pos;
2266  }
2267 
2268  // search for nearest color
2269  unsigned int mindiff = 0xffffffff;
2270  unsigned int diff;
2271  int dr,dg,db;
2272 
2273  for (int loopc = 0; loopc < screencols; ++loopc) {
2274  dr = qRed(screenclut[loopc]) - r;
2275  dg = qGreen(screenclut[loopc]) - g;
2276  db = qBlue(screenclut[loopc]) - b;
2277  diff = dr*dr + dg*dg + db*db;
2278 
2279  if (diff < mindiff) {
2280  ret = loopc;
2281  if (!diff)
2282  break;
2283  mindiff = diff;
2284  }
2285  }
2286  } else if (d == 4) {
2287  ret = qGray(r, g, b) >> 4;
2288  } else if (d == 1) {
2289  ret = qGray(r, g, b) >= 128;
2290  } else {
2291  qFatal("cannot alloc %dbpp color", d);
2292  }
2293 
2294  return ret;
2295 }
2296 
2310 {
2311 }
2312 
2326 {
2327 }
2328 
2329 void QScreen::blank(bool)
2330 {
2331 }
2332 
2337 void QScreen::set(unsigned int, unsigned int, unsigned int, unsigned int)
2338 {
2339 }
2340 
2353 bool QScreen::supportsDepth(int d) const
2354 {
2355  if (false) {
2356  //Just to simplify the ifdeffery
2357 #ifdef QT_QWS_DEPTH_1
2358  } else if(d==1) {
2359  return true;
2360 #endif
2361 #ifdef QT_QWS_DEPTH_4
2362  } else if(d==4) {
2363  return true;
2364 #endif
2365 #ifdef QT_QWS_DEPTH_8
2366  } else if(d==8) {
2367  return true;
2368 #endif
2369 #ifdef QT_QWS_DEPTH_16
2370  } else if(d==16) {
2371  return true;
2372 #endif
2373 #ifdef QT_QWS_DEPTH_15
2374  } else if (d == 15) {
2375  return true;
2376 #endif
2377 #ifdef QT_QWS_DEPTH_18
2378  } else if(d==18 || d==19) {
2379  return true;
2380 #endif
2381 #ifdef QT_QWS_DEPTH_24
2382  } else if(d==24) {
2383  return true;
2384 #endif
2385 #ifdef QT_QWS_DEPTH_32
2386  } else if(d==32) {
2387  return true;
2388 #endif
2389  }
2390  return false;
2391 }
2392 
2402 bool QScreen::onCard(const unsigned char * p) const
2403 {
2404  long t=(unsigned long)p;
2405  long bmin=(unsigned long)data;
2406  if (t < bmin)
2407  return false;
2408  if(t >= bmin+mapsize)
2409  return false;
2410  return true;
2411 }
2412 
2423 bool QScreen::onCard(const unsigned char * p, ulong& offset) const
2424 {
2425  long t=(unsigned long)p;
2426  long bmin=(unsigned long)data;
2427  if (t < bmin)
2428  return false;
2429  long o = t - bmin;
2430  if (o >= mapsize)
2431  return false;
2432  offset = o;
2433  return true;
2434 }
2435 
2436 /*
2437 #if !defined(QT_NO_QWS_REPEATER)
2438  { "Repeater", qt_get_screen_repeater, 0 },
2439 #endif
2440 #if defined(QT_QWS_EE)
2441  { "EE", qt_get_screen_ee, 0 },
2442 #endif
2443 
2444 */
2445 
2446 /*
2447 Given a display_id (number of the \l{Qt for Embedded Linux} server to connect to)
2448 and a spec (e.g. Mach64:/dev/fb0) return a QScreen-descendant.
2449 The QScreenDriverFactory is queried for a suitable driver and, if found,
2450 asked to create a driver.
2451 People writing new graphics drivers should either hook their own
2452 QScreen-descendant into QScreenDriverFactory or use the QScreenDriverPlugin
2453 to make a dynamically loadable driver.
2454 */
2455 
2456 Q_GUI_EXPORT QScreen* qt_get_screen(int display_id, const char *spec)
2457 {
2458  QString displaySpec = QString::fromAscii(spec);
2459  QString driver = displaySpec;
2460  int colon = displaySpec.indexOf(QLatin1Char(':'));
2461  if (colon >= 0)
2462  driver.truncate(colon);
2463  driver = driver.trimmed();
2464 
2465  bool foundDriver = false;
2466  QString driverName = driver;
2467 
2468  QStringList driverList;
2469  if (!driver.isEmpty())
2470  driverList << driver;
2471  else
2472  driverList = QScreenDriverFactory::keys();
2473 
2474  for (int i = 0; i < driverList.size(); ++i) {
2475  const QString driverName = driverList.at(i);
2476  qt_screen = QScreenDriverFactory::create(driverName, display_id);
2477  if (qt_screen) {
2478  foundDriver = true;
2479  if (qt_screen->connect(displaySpec)) {
2480  return qt_screen;
2481  } else {
2482  delete qt_screen;
2483  qt_screen = 0;
2484  }
2485  }
2486  }
2487 
2488  if (driver.isNull())
2489  qFatal("No suitable driver found");
2490  else if (foundDriver)
2491  qFatal("%s: driver cannot connect", driver.toLatin1().constData());
2492  else
2493  qFatal("%s: driver not found", driver.toLatin1().constData());
2494 
2495  return 0;
2496 }
2497 
2498 #ifndef QT_NO_QWS_CURSOR
2499 static void blendCursor(QImage *dest, const QImage &cursor, const QPoint &offset)
2500 {
2501  QRasterBuffer rb;
2502  rb.prepare(dest);
2503 
2504  QSpanData spanData;
2505  spanData.init(&rb, 0);
2506  spanData.type = QSpanData::Texture;
2507  spanData.initTexture(&cursor, 256);
2508  spanData.dx = -offset.x();
2509  spanData.dy = -offset.y();
2510  if (!spanData.blend)
2511  return;
2512 
2513  const QRect rect = QRect(offset, cursor.size())
2514  & QRect(QPoint(0, 0), dest->size());
2515  const int w = rect.width();
2516  const int h = rect.height();
2517 
2519  for (int i = 0; i < h; ++i) {
2520  spans[i].x = rect.x();
2521  spans[i].len = w;
2522  spans[i].y = rect.y() + i;
2523  spans[i].coverage = 255;
2524  }
2525  spanData.blend(h, spans.constData(), &spanData);
2526 }
2527 #endif // QT_NO_QWS_CURSOR
2528 
2555 void QScreen::exposeRegion(QRegion r, int windowIndex)
2556 {
2557  r &= region();
2558  if (r.isEmpty())
2559  return;
2560 
2561  int changing = windowIndex;
2562  // when we have just lowered a window, we have to expose all the windows below where the
2563  // window used to be.
2564  if (changing && qwsServer->clientWindows().at(changing)->state() == QWSWindow::Lowering)
2565  changing = 0;
2566 #ifdef QTOPIA_PERFTEST
2567  static enum { PerfTestUnknown, PerfTestOn, PerfTestOff } perfTestState = PerfTestUnknown;
2568  if(PerfTestUnknown == perfTestState) {
2569  if(::getenv("QTOPIA_PERFTEST"))
2570  perfTestState = PerfTestOn;
2571  else
2572  perfTestState = PerfTestOff;
2573  }
2574  if(PerfTestOn == perfTestState) {
2575  QWSWindow *changed = qwsServer->clientWindows().at(changing);
2576  if(!changed->client()->identity().isEmpty())
2577  qDebug() << "Performance : expose_region :"
2578  << changed->client()->identity()
2579  << r.boundingRect() << ": "
2580  << qPrintable( QTime::currentTime().toString( "h:mm:ss.zzz" ) );
2581  }
2582 #endif
2583 
2584  const QRect bounds = r.boundingRect();
2585  QRegion blendRegion;
2586  QImage *blendBuffer = 0;
2587 
2588 #ifndef QT_NO_QWS_CURSOR
2590  blendRegion = r & qt_screencursor->boundingRect();
2591  }
2592 #endif
2593  compose(0, r, blendRegion, &blendBuffer, changing);
2594 
2595  if (blendBuffer && !blendBuffer->isNull()) {
2596  const QPoint offset = blendRegion.boundingRect().topLeft();
2597 #ifndef QT_NO_QWS_CURSOR
2599  const QRect cursorRect = qt_screencursor->boundingRect();
2600  if (blendRegion.intersects(cursorRect)) {
2601  blendCursor(blendBuffer, qt_screencursor->image(),
2602  cursorRect.topLeft() - offset);
2603  }
2604  }
2605 #endif // QT_NO_QWS_CURSOR
2606  blit(*blendBuffer, offset, blendRegion);
2607  delete blendBuffer;
2608  }
2609 
2610  if (r.rectCount() == 1) {
2611  setDirty(r.boundingRect());
2612  } else {
2613  const QVector<QRect> rects = r.rects();
2614  for (int i = 0; i < rects.size(); ++i)
2615  setDirty(rects.at(i));
2616  }
2617 }
2618 
2640 void QScreen::blit(const QImage &img, const QPoint &topLeft, const QRegion &reg)
2641 {
2642  const QRect bound = (region() & QRect(topLeft, img.size())).boundingRect();
2643  QWSDisplay::grab();
2644  d_ptr->blit(this, img, topLeft - offset(),
2645  (reg & bound).translated(-topLeft));
2647 }
2648 
2649 #ifdef QT_QWS_CLIENTBLIT
2650 
2660 bool QScreen::supportsBlitInClients() const
2661 {
2662  return d_ptr->supportsBlitInClients;
2663 }
2664 
2671 void QScreen::setSupportsBlitInClients(bool supported)
2672 {
2673  d_ptr->supportsBlitInClients = supported;
2674 }
2675 #endif
2676 
2681 void QScreen::blit(QWSWindow *win, const QRegion &clip)
2682 {
2683  QWSWindowSurface *surface = win->windowSurface();
2684  if (!surface)
2685  return;
2686 
2687  const QImage &img = surface->image();
2688  if (img.isNull())
2689  return;
2690 
2691  const QRegion rgn = clip & win->paintedRegion();
2692  if (rgn.isEmpty())
2693  return;
2694 
2695  surface->lock();
2696  blit(img, win->requestedRegion().boundingRect().topLeft(), rgn);
2697  surface->unlock();
2698 }
2699 
2700 struct fill_data {
2704  int x;
2705  int y;
2706  int w;
2707  int h;
2708 };
2709 
2726 // the base class implementation works in device coordinates, so that transformed drivers can use it
2727 void QScreen::solidFill(const QColor &color, const QRegion &region)
2728 {
2729  QWSDisplay::grab();
2730  d_ptr->solidFill(this, color,
2731  region.translated(-offset()) & QRect(0, 0, dw, dh));
2733 }
2734 
2757 {
2758 #ifndef QT_NO_PAINTONSCREEN
2759  if (key == QLatin1String("OnScreen"))
2760  return new QWSOnScreenSurface;
2761  else
2762 #endif
2763  if (key == QLatin1String("mem"))
2764  return new QWSLocalMemSurface;
2765 #ifndef QT_NO_QWS_MULTIPROCESS
2766  else if (key == QLatin1String("shm"))
2767  return new QWSSharedMemSurface;
2768 #endif
2769 #ifndef QT_NO_PAINT_DEBUG
2770  else if (key == QLatin1String("Yellow"))
2771  return new QWSYellowSurface;
2772 #endif
2773 #ifndef QT_NO_DIRECTPAINTER
2774  else if (key == QLatin1String("DirectPainter"))
2775  return new QWSDirectPainterSurface;
2776 #endif
2777 
2778  return 0;
2779 }
2780 
2781 #ifndef QT_NO_PAINTONSCREEN
2783 {
2784  static int doOnScreen = -1;
2785  if (doOnScreen == -1) {
2786  const QByteArray env = qgetenv("QT_ONSCREEN_PAINT");
2787  if (env == "force")
2788  doOnScreen = 2;
2789  else
2790  doOnScreen = (env.toInt() > 0 ? 1 : 0);
2791  }
2792 
2793  if (doOnScreen == 2) // force
2794  return true;
2795 
2796  if (doOnScreen == 0 && !w->testAttribute(Qt::WA_PaintOnScreen))
2797  return false;
2798 
2799  return w->d_func()->isOpaque;
2800 }
2801 #endif
2802 
2812 {
2813 #ifndef QT_NO_PAINTONSCREEN
2814  if (isWidgetPaintOnScreen(widget) && base())
2815  return new QWSOnScreenSurface(widget);
2816  else
2817 #endif
2819  return new QWSLocalMemSurface(widget);
2820 #ifndef QT_NO_QWS_MULTIPROCESS
2821  else
2822  return new QWSSharedMemSurface(widget);
2823 #endif
2824 
2825  return 0;
2826 }
2827 
2828 void QScreen::compose(int level, const QRegion &exposed, QRegion &blend,
2829  QImage **blendbuffer, int changing_level)
2830 {
2831  QRect exposed_bounds = exposed.boundingRect();
2832  QWSWindow *win = 0;
2833  do {
2834  win = qwsServer->clientWindows().value(level); // null is background
2835  ++level;
2836  } while (win && !win->paintedRegion().boundingRect().intersects(exposed_bounds));
2837 
2838  QWSWindowSurface *surface = (win ? win->windowSurface() : 0);
2839  bool above_changing = level <= changing_level; // 0 is topmost
2840 
2841  QRegion exposedBelow = exposed;
2842  bool opaque = true;
2843 
2844  if (win) {
2845  opaque = win->isOpaque() || !surface->isBuffered();
2846  if (opaque) {
2847  exposedBelow -= win->paintedRegion();
2848  if (above_changing || !surface->isBuffered())
2849  blend -= exposed & win->paintedRegion();
2850  } else {
2851  blend += exposed & win->paintedRegion();
2852  }
2853  }
2854  if (win && !exposedBelow.isEmpty()) {
2855  compose(level, exposedBelow, blend, blendbuffer, changing_level);
2856  } else {
2857  QSize blendSize = blend.boundingRect().size();
2858  if (!blendSize.isNull()) {
2859  *blendbuffer = new QImage(blendSize, d_ptr->preferredImageFormat());
2860  }
2861  }
2862 
2863  const QRegion blitRegion = exposed - blend;
2864  if (!win)
2865  paintBackground(blitRegion);
2866  else if (!above_changing && surface->isBuffered())
2867  blit(win, blitRegion);
2868 
2869  QRegion blendRegion = exposed & blend;
2870 
2871  if (win)
2872  blendRegion &= win->paintedRegion();
2873  if (!blendRegion.isEmpty()) {
2874 
2875  QPoint off = blend.boundingRect().topLeft();
2876 
2877  QRasterBuffer rb;
2878  rb.prepare(*blendbuffer);
2879  QSpanData spanData;
2880  spanData.init(&rb, 0);
2881  if (!win) {
2882  const QImage::Format format = (*blendbuffer)->format();
2883  switch (format) {
2885  case QImage::Format_ARGB32:
2891  break;
2892  default:
2893  break;
2894  }
2896  spanData.dx = off.x();
2897  spanData.dy = off.y();
2898  } else if (!surface->isBuffered()) {
2899  return;
2900  } else {
2901  const QImage &img = surface->image();
2902  QPoint winoff = off - win->requestedRegion().boundingRect().topLeft();
2903  // convert win->opacity() from scale [0..255] to [0..256]
2904  int const_alpha = win->opacity();
2905  const_alpha += (const_alpha >> 7);
2906  spanData.type = QSpanData::Texture;
2907  spanData.initTexture(&img, const_alpha);
2908  spanData.dx = winoff.x();
2909  spanData.dy = winoff.y();
2910  }
2911  if (!spanData.blend)
2912  return;
2913 
2914  if (surface)
2915  surface->lock();
2916  const QVector<QRect> rects = blendRegion.rects();
2917  const int nspans = 256;
2918  QT_FT_Span spans[nspans];
2919  for (int i = 0; i < rects.size(); ++i) {
2920  int y = rects.at(i).y() - off.y();
2921  int ye = y + rects.at(i).height();
2922  int x = rects.at(i).x() - off.x();
2923  int len = rects.at(i).width();
2924  while (y < ye) {
2925  int n = qMin(nspans, ye - y);
2926  int i = 0;
2927  while (i < n) {
2928  spans[i].x = x;
2929  spans[i].len = len;
2930  spans[i].y = y + i;
2931  spans[i].coverage = 255;
2932  ++i;
2933  }
2934  spanData.blend(n, spans, &spanData);
2935  y += n;
2936  }
2937  }
2938  if (surface)
2939  surface->unlock();
2940  }
2941 }
2942 
2944 {
2945  const QBrush &bg = qwsServer->backgroundBrush();
2946  Qt::BrushStyle bs = bg.style();
2947  if (bs == Qt::NoBrush || r.isEmpty())
2948  return;
2949 
2950  if (bs == Qt::SolidPattern) {
2951  solidFill(bg.color(), r);
2952  } else {
2953  const QRect br = r.boundingRect();
2954  QImage img(br.size(), d_ptr->preferredImageFormat());
2955  QPoint off = br.topLeft();
2956  QRasterBuffer rb;
2957  rb.prepare(&img);
2958  QSpanData spanData;
2959  spanData.init(&rb, 0);
2960  spanData.setup(bg, 256, QPainter::CompositionMode_Source);
2961  spanData.dx = off.x();
2962  spanData.dy = off.y();
2963  Q_ASSERT(spanData.blend);
2964 
2965  const QVector<QRect> rects = r.rects();
2966  const int nspans = 256;
2967  QT_FT_Span spans[nspans];
2968  for (int i = 0; i < rects.size(); ++i) {
2969  int y = rects.at(i).y() - off.y();
2970  int ye = y + rects.at(i).height();
2971  int x = rects.at(i).x() - off.x();
2972  int len = rects.at(i).width();
2973  while (y < ye) {
2974  int n = qMin(nspans, ye - y);
2975  int i = 0;
2976  while (i < n) {
2977  spans[i].x = x;
2978  spans[i].len = len;
2979  spans[i].y = y + i;
2980  spans[i].coverage = 255;
2981  ++i;
2982  }
2983  spanData.blend(n, spans, &spanData);
2984  y += n;
2985  }
2986  }
2987  blit(img, br.topLeft(), r);
2988  }
2989 }
2990 
3011 {
3012 }
3013 
3027 {
3028  return false;
3029 }
3030 
3048 {
3049  return false;//qws_screen_is_interlaced;;
3050 }
3051 
3069 {
3070  return s;
3071 }
3072 
3090 {
3091  return s;
3092 }
3093 
3107 QPoint QScreen::mapToDevice(const QPoint &p, const QSize &) const
3108 {
3109  return p;
3110 }
3111 
3125 QPoint QScreen::mapFromDevice(const QPoint &p, const QSize &) const
3126 {
3127  return p;
3128 }
3129 
3143 QRect QScreen::mapToDevice(const QRect &r, const QSize &) const
3144 {
3145  return r;
3146 }
3147 
3161 QRect QScreen::mapFromDevice(const QRect &r, const QSize &) const
3162 {
3163  return r;
3164 }
3165 
3179 {
3180  return i;
3181 }
3182 
3196 {
3197  return i;
3198 }
3199 
3213 QRegion QScreen::mapToDevice(const QRegion &r, const QSize &) const
3214 {
3215  return r;
3216 }
3217 
3232 {
3233  return r;
3234 }
3235 
3251 {
3252  return 0;
3253 }
3254 
3256 {
3257  return depth();
3258 }
3259 
3264 {
3265  return 0;
3266 }
3267 
3272 {
3273 }
3274 
3279 {
3280 }
3281 
3298 {
3299  d_ptr->offset = p;
3300 }
3301 
3312 {
3313  return d_ptr->offset;
3314 }
3315 
3316 #if Q_BYTE_ORDER == Q_BIG_ENDIAN
3318 {
3319  d_ptr->fb_is_littleEndian = littleEndian;
3320 }
3321 
3323 {
3324  return d_ptr->fb_is_littleEndian;
3325 }
3326 #endif
3327 
3344 {
3345  const QList<QScreen*> screens = subScreens();
3346  const int n = screens.count();
3347  for (int i = 0; i < n; ++i) {
3348  if (screens.at(i)->region().contains(p))
3349  return i;
3350  }
3351 
3352  return -1;
3353 }
3354 
3355 #if 0
3356 #ifdef QT_LOADABLE_MODULES
3357 #include <dlfcn.h>
3358 
3359 // ### needs update after driver init changes
3360 
3361 static QScreen * qt_dodriver(char * driver,char * a,unsigned char * b)
3362 
3363 {
3364  char buf[200];
3365  strcpy(buf,"/etc/qws/drivers/");
3366  qstrcpy(buf+17,driver);
3367  qDebug("Attempting driver %s",driver);
3368 
3369  void * handle;
3370  handle=dlopen(buf,RTLD_LAZY);
3371  if(handle==0) {
3372  qFatal("Module load error");
3373  }
3374  QScreen *(*qt_get_screen_func)(char *,unsigned char *);
3375  qt_get_screen_func=dlsym(handle,"qt_get_screen");
3376  if(qt_get_screen_func==0) {
3377  qFatal("Couldn't get symbol");
3378  }
3379  QScreen * ret=qt_get_screen_func(a,b);
3380  return ret;
3381 }
3382 
3383 static QScreen * qt_do_entry(char * entry)
3384 {
3385  unsigned char config[256];
3386 
3387  FILE * f=fopen(entry,"r");
3388  if(!f) {
3389  return 0;
3390  }
3391 
3392  int r=fread(config,256,1,f);
3393  if(r<1)
3394  return 0;
3395 
3396  fclose(f);
3397 
3398  unsigned short vendorid=*((unsigned short int *)config);
3399  unsigned short deviceid=*(((unsigned short int *)config)+1);
3400  if(config[0xb]!=3)
3401  return 0;
3402 
3403  if(vendorid==0x1002) {
3404  if(deviceid==0x4c4d) {
3405  qDebug("Compaq Armada/IBM Thinkpad's Mach64 card");
3406  return qt_dodriver("mach64.so",entry,config);
3407  } else if(deviceid==0x4742) {
3408  qDebug("Desktop Rage Pro Mach64 card");
3409  return qt_dodriver("mach64.so",entry,config);
3410  } else {
3411  qDebug("Unrecognised ATI card id %x",deviceid);
3412  return 0;
3413  }
3414  } else {
3415  qDebug("Unrecognised vendor");
3416  }
3417  return 0;
3418 }
3419 
3420 extern bool qws_accel;
3421 
3423 
3425 {
3426  if(!qws_accel) {
3427  return qt_dodriver("unaccel.so",0,0);
3428  }
3429 
3430  QT_DIR *dirptr = QT_OPENDIR("/proc/bus/pci");
3431  if(!dirptr)
3432  return qt_dodriver("unaccel.so",0,0);
3433  QT_DIR * dirptr2;
3434  QT_DIRENT *cards;
3435 
3436  QT_DIRENT *busses = QT_READDIR(dirptr);
3437 
3438  while(busses) {
3439  if(busses->d_name[0]!='.') {
3440  char buf[100];
3441  strcpy(buf,"/proc/bus/pci/");
3442  qstrcpy(buf+14,busses->d_name);
3443  int p=strlen(buf);
3444  dirptr2 = QT_OPENDIR(buf);
3445  if(dirptr2) {
3446  cards = QT_READDIR(dirptr2);
3447  while(cards) {
3448  if(cards->d_name[0]!='.') {
3449  buf[p]='/';
3450  qstrcpy(buf+p+1,cards->d_name);
3451  QScreen * ret=qt_do_entry(buf);
3452  if(ret)
3453  return ret;
3454  }
3455  cards = QT_READDIR(dirptr2);
3456  }
3457  QT_CLOSEDIR(dirptr2);
3458  }
3459  }
3460  busses = QT_READDIR(dirptr);
3461  }
3462  QT_CLOSEDIR(dirptr);
3463 
3464  return qt_dodriver("unaccel.so",0,0);
3465 }
3466 
3467 #else
3468 
3469 char *qt_qws_hardcoded_slot = "/proc/bus/pci/01/00.0";
3470 
3471 const unsigned char* qt_probe_bus()
3472 {
3473  const char * slot;
3474  slot=::getenv("QWS_CARD_SLOT");
3475  if(!slot)
3476  slot=qt_qws_hardcoded_slot;
3477  if (slot) {
3478  static unsigned char config[256];
3479  FILE * f=fopen(slot,"r");
3480  if(!f) {
3481  qDebug("Open failure for %s",slot);
3482  slot=0;
3483  } else {
3484  int r=fread((char*)config,256,1,f);
3485  fclose(f);
3486  if(r<1) {
3487  qDebug("Read failure");
3488  return 0;
3489  } else {
3490  return config;
3491  }
3492  }
3493  }
3494  return 0;
3495 }
3496 
3497 #endif
3498 
3499 #endif // 0
3500 
3506 {
3507  static bool shownWarning = false;
3508  if (!shownWarning) {
3509  qWarning("QScreen::setPixmapDataFactory() is deprecated - use setGraphicsSystem() instead");
3510  shownWarning = true;
3511  }
3512 
3513  d_ptr->pixmapFactory = factory;
3514 }
3515 
3521 {
3522  return d_ptr->pixmapFactory;
3523 }
3524 
3530 {
3531  d_ptr->graphicsSystem = system;
3532 }
3533 
3539 {
3540  return d_ptr->graphicsSystem;
3541 }
3542 
3552 {
3553  return static_cast<ClassId>(d_ptr->classId);
3554 }
3555 
Q_GUI_EXPORT QScreen * qt_screen
Definition: qscreen_qws.cpp:69
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
The QScreenCursor class is a base class for screen cursors in Qt for Embedded Linux.
Definition: qscreen_qws.h:135
double d
Definition: qnumeric_p.h:62
QGraphicsSystem * graphicsSystem
int screencols
the number of entries in the color table
Definition: qscreen_qws.h:309
const T * constData() const
void compose(int level, const QRegion &exposed, QRegion &blend, QImage **blendbuffer, int changing_level)
#define Q_PACKED
Definition: qglobal.h:815
The QWSWindowSurface class provides the drawing area for top-level windows in Qt for Embedded Linux...
virtual void move(int x, int y)
Moves the mouse cursor to the given position, i.e., (x, y).
Format
The following image formats are available in Qt.
Definition: qimage.h:91
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
BrushStyle
Definition: qnamespace.h:1162
int * entryp
Definition: qscreen_qws.h:321
bool frameBufferLittleEndian() const
Q_CORE_EXPORT char * qstrcpy(char *dst, const char *src)
unsigned char c[8]
Definition: qnumeric_p.h:62
void qt_rectconvert(DST *dest, const SRC *src, int x, int y, int width, int height, int dstStride, int srcStride)
void setOffset(const QPoint &p)
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
const QColor & color() const
Returns the brush color.
Definition: qbrush.h:183
unsigned char coverage
static void blendCursor(QImage *dest, const QImage &cursor, const QPoint &offset)
QPointer< QWidget > widget
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
int d
the pixel depth
Definition: qscreen_qws.h:327
QScreenPrivate(QScreen *parent, QScreen::ClassId id=QScreen::CustomClass)
QImage::Format pixelFormat
unsigned int * lowest
Definition: qscreen_qws.h:322
virtual ~QScreen()
Destroys this screen driver.
unsigned short len
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
static void solidFill_template(QScreen *screen, const QColor &color, const QRegion &region)
bool isNull() const
Returns true if it is a null image, otherwise returns false.
Definition: qimage.cpp:1542
void qt_solidFill_setup(QScreen *screen, const QColor &color, const QRegion &region)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
void qt_rectfill(T *dest, T value, int x, int y, int width, int height, int stride)
void paintBackground(const QRegion &)
bool qws_accel
QWSClient * client() const
Returns a reference to the QWSClient object that owns this window.
virtual bool connect(const QString &displaySpec)=0
This function is called by every Qt for Embedded Linux application on startup, and must be implemente...
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void(* ClearCacheFunc)(QScreen *obj, int)
Definition: qscreen_qws.h:189
virtual void restore()
Restores the previously saved state of the graphics card.
QRgb screenclut[256]
the color table
Definition: qscreen_qws.h:308
QList< QScreen * > subScreens
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
QPoint hotspot
Definition: qscreen_qws.h:163
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
Q_GUI_EXPORT QScreen * qt_get_screen(int display_id, const char *spec)
int deviceWidth() const
Returns the physical width of the framebuffer device in pixels.
Definition: qscreen_qws.h:233
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
QScreen * q_ptr
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
virtual QSize mapFromDevice(const QSize &) const
Maps the given size from the framebuffer coordinate system to the coordinate space used by the applic...
QRect boundingRect() const
Returns the bounding rectangle of this region.
Definition: qregion.cpp:4363
unsigned char quint8
Definition: qglobal.h:934
QScreenPrivate * d_ptr
Definition: qscreen_qws.h:374
bool isBuffered() const
Returns true if the QWSWindowSurface::Buffered is set; otherwise returns false.
static ClearCacheFunc clearCacheFunc
Definition: qscreen_qws.h:344
friend class QWSOnScreenSurface
Definition: qscreen_qws.h:351
int physHeight
the physical height of the screen in millimeters.
Definition: qscreen_qws.h:340
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define Q_STATIC_TEMPLATE_FUNCTION
Definition: qdrawhelper_p.h:85
The QString class provides a Unicode character string.
Definition: qstring.h:83
int size
the number of bytes in the visible region of the frame buffer
Definition: qscreen_qws.h:334
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
virtual bool lock(int timeout=-1)
virtual void setDirty(const QRect &)
Marks the given rectangle as dirty.
static void grayscale(const QImage &image, QImage &dest, const QRect &rect=QRect())
static void initSoftwareCursor()
Initializes the screen cursor.
QPainter::CompositionMode compositionMode
int rectCount() const
Returns the number of rectangles that will be returned in rects().
Definition: qregion.cpp:4461
Format format() const
Returns the format of the image.
Definition: qimage.cpp:2305
PixelType pixeltype
set to BGRPixel
Definition: qscreen_qws.h:328
int physWidth
the physical width of the screen in millimeters.
Definition: qscreen_qws.h:339
QImage image() const
Returns the cursor&#39;s image.
Definition: qscreen_qws.h:151
Q_GUI_EXPORT_INLINE int qRed(QRgb rgb)
Definition: qrgb.h:57
virtual QSize mapToDevice(const QSize &) const
Maps the given size from the coordinate space used by the application to the framebuffer coordinate s...
void setPixelFormat(QImage::Format format)
Sets the screen&#39;s pixel format to format.
virtual void blit(const QImage &img, const QPoint &topLeft, const QRegion &region)
Copies the given region in the given image to the point specified by topLeft using device coordinates...
ProcessSpans blend
Q_CORE_EXPORT void qDebug(const char *,...)
The QWSWindow class encapsulates a top-level window in Qt for Embedded Linux.
virtual QRegion region() const
Returns the region covered by this screen driver.
Definition: qscreen_qws.h:284
virtual int alloc(unsigned int, unsigned int, unsigned int)
Returns the index in the screen&#39;s palette which is the closest match to the given RGB value (red...
unsigned char uchar
Definition: qglobal.h:994
bool isAccelerated() const
Returns true if the cursor is accelerated; otherwise false.
Definition: qscreen_qws.h:153
static QString toString(Register *reg, int type, bool *ok=0)
uchar * data
points to the first visible pixel in the frame buffer.
Definition: qscreen_qws.h:311
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
PixelType pixelType() const
Returns the pixel storage format of the screen.
Definition: qscreen_qws.h:231
int linestep() const
Returns the length of each scanline of the framebuffer in bytes.
Definition: qscreen_qws.h:232
virtual void resumeUpdates()
QScreenCursor()
Constructs a screen cursor.
void truncate(int pos)
Truncates the string at the given position index.
Definition: qstring.cpp:4603
static void blit_template(QScreen *screen, const QImage &image, const QPoint &topLeft, const QRegion &region)
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
Definition: qstring.cpp:4506
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
int w
the logical width of the screen.
Definition: qscreen_qws.h:324
void setGraphicsSystem(QGraphicsSystem *system)
unsigned short quint16
Definition: qglobal.h:936
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
bool contains(const QPoint &p) const
Returns true if the region contains the point p; otherwise returns false.
Definition: qregion.cpp:4104
static const char * data(const QByteArray &arr)
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
static Bigint * diff(Bigint *a, Bigint *b)
static QScreen * create(const QString &, int)
uchar * data
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:68
T value(int i) const
Returns the value at index position i in the list.
Definition: qlist.h:661
virtual ~QScreenCursor()
Destroys the screen cursor.
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
int displayId
Definition: qscreen_qws.h:337
static QStringList keys()
Returns the list of valid keys, i.e.
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
static void grab()
unsigned long ulong
Definition: qglobal.h:997
void initTexture(const QImage *image, int alpha, QTextureData::Type=QTextureData::Plain, const QRect &sourceRect=QRect())
QImage::Format prepare(QImage *image)
QScreen(int display_id, ClassId classId)
Constructs a new screen driver.
Q_GUI_EXPORT_INLINE int qBlue(QRgb rgb)
Definition: qrgb.h:63
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
uint opacity() const
Returns the window&#39;s alpha channel value.
QSize size() const
Returns the size of the image, i.
Definition: qimage.cpp:1587
QWSGraphicsSystem defaultGraphicsSystem
virtual void hide()
Hides the cursor from the screen.
virtual QWSWindowSurface * createSurface(QWidget *widget) const
Creates and returns a new window surface for the given widget.
SolidFillFunc solidFill
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
static const MacSpecialKey entries[NumEntries]
Q_GUI_EXPORT_INLINE int qGray(int r, int g, int b)
Definition: qrgb.h:75
uchar * base() const
Returns a pointer to the beginning of the framebuffer.
Definition: qscreen_qws.h:235
int subScreenIndexAt(const QPoint &p) const
Returns the index of the subscreen at the given position; returns -1 if no screen is found...
QString identity() const
Returns the name of this client&#39;s running application.
int dw
the device width
Definition: qscreen_qws.h:331
Q_CORE_EXPORT void qFatal(const char *,...)
QGraphicsSystem * graphicsSystem() const
QPoolEntry * entries
Definition: qscreen_qws.h:320
int dh
the device height
Definition: qscreen_qws.h:332
void qt_blit_setup(QScreen *screen, const QImage &image, const QPoint &topLeft, const QRegion &region)
virtual void blank(bool on)
Prevents the screen driver form displaying any content on the screen.
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
Definition: qimage.cpp:3966
QImage::Format pixelFormat() const
Returns the pixel format of the screen, or QImage::Format_Invalid if the pixel format is not a suppor...
virtual void save()
Saves the current state of the graphics card.
void setup(const QBrush &brush, int alpha, QPainter::CompositionMode compositionMode)
State state() const
Returns the current state of the window.
void init(QRasterBuffer *rb, const QRasterPaintEngine *pe)
virtual int memoryNeeded(const QString &)
int deviceHeight() const
Returns the full height of the framebuffer device in pixels.
Definition: qscreen_qws.h:234
virtual void haltUpdates()
const QBrush & backgroundBrush() const
Returns the brush used as background in the absence of obscuring windows.
const QRegion & requestedRegion() const
Returns the region that the window has requested to draw onto, including any window decorations...
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
QRasterBuffer * rasterBuffer
static QTime currentTime()
Returns the current time as reported by the system clock.
Definition: qdatetime.cpp:3125
ClassId
This enum defines the class identifiers for the known screen subclasses.
Definition: qscreen_qws.h:194
virtual bool isInterlaced() const
Returns true if the display is interlaced (i.
void setFrameBufferLittleEndian(bool littleEndian)
QImage::Format preferredImageFormat() const
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QRect boundingRect() const
Returns the cursor&#39;s bounding rectangle.
Definition: qscreen_qws.h:150
int toInt(bool *ok=0, int base=10) const
Returns the byte array converted to an int using base base, which is 10 by default and must be betwee...
virtual QList< QScreen * > subScreens() const
Definition: qscreen_qws.h:283
virtual bool isTransformed() const
Returns true if the screen is transformed (for instance, rotated 90 degrees); otherwise returns false...
Q_GUI_EXPORT_INLINE QRgb qRgb(int r, int g, int b)
Definition: qrgb.h:69
int key
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
Definition: qregion.cpp:4412
unsigned int quint32
Definition: qglobal.h:938
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QPixmapDataFactory * pixmapDataFactory() const
if(void) toggleToolbarShown
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
bool grayscale
the gray scale screen mode flag
Definition: qscreen_qws.h:329
QWSWindowSurface * windowSurface() const
The QScreen class is a base class for screen drivers in Qt for Embedded Linux.
Definition: qscreen_qws.h:191
virtual void shutdownDevice()
This function is called by the Qt for Embedded Linux server before it calls the disconnect() function...
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
virtual int transformOrientation() const
Returns the current rotation as an integer value.
bool intersects(const QRegion &r) const
Returns true if this region intersects with region, otherwise returns false.
Definition: qregion.cpp:766
Q_GUI_EXPORT_INLINE int qGreen(QRgb rgb)
Definition: qrgb.h:60
virtual bool onCard(const unsigned char *) const
Returns true if the specified buffer is within the graphics card&#39;s memory; otherwise returns false (i...
int lstep
the number of bytes representing a line in the frame buffer.
Definition: qscreen_qws.h:325
bool isNull() const
Returns true if both the width and height is 0; otherwise returns false.
Definition: qsize.h:117
uint supportsAlpha
Definition: qscreen_qws.h:166
ClassId classId() const
Returns the class identifier for the screen object.
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QPixmapDataFactory * pixmapFactory
QRegion translated(int dx, int dy) const
Returns a copy of the region that is translated dx along the x axis and dy along the y axis...
Definition: qregion.cpp:743
bool intersects(const QRect &r) const
Returns true if this rectangle intersects with the given rectangle (i.
Definition: qrect.cpp:1429
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128
int h
the logical height of the screen.
Definition: qscreen_qws.h:326
void setPixmapDataFactory(QPixmapDataFactory *factory)
virtual void set(unsigned int, unsigned int, unsigned int, unsigned int)
QRgb rgba() const
Returns the RGB value of the color, including its alpha.
Definition: qcolor.cpp:1019
Q_GUI_EXPORT QScreenCursor * qt_screencursor
Definition: qscreen_qws.cpp:67
static void ungrab()
bool isOpaque() const
Returns true if the window is opaque, i.
virtual bool supportsDepth(int) const
Returns true if the screen supports the specified color depth; otherwise returns false.
virtual void exposeRegion(QRegion r, int changing)
This function is called by the Qt for Embedded Linux server whenever a screen update is required...
quint32 color
const unsigned char * qt_probe_bus()
int mapsize
the total number of bytes in the frame buffer
Definition: qscreen_qws.h:335
virtual void show()
Shows the mouse cursor.
static bool isWidgetPaintOnScreen(const QWidget *w)
virtual QImage image() const =0
Implement this function to return an image of the top-level window.
#define qPrintable(string)
Definition: qglobal.h:1750
static Type type()
Returns the type of application (Tty , GuiClient, or GuiServer).
QRegion paintedRegion() const
Returns the region that the window is known to have drawn into.
enum QSpanData::Type type
bool operator==(QBool b1, bool b2)
Definition: qglobal.h:2023
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
virtual int pixmapDepth() const
Returns the preferred depth for pixmaps, in bits per pixel.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
virtual void solidFill(const QColor &color, const QRegion &region)
Fills the given region of the screen with the specified color.
virtual void set(const QImage &image, int hotx, int hoty)
Sets the cursor&#39;s image to be the given image.
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
Definition: qimage.cpp:1886
Q_CORE_EXPORT void qCritical(const char *,...)
QPoint offset() const
Returns the logical offset of the screen, i.
QWSServer Q_GUI_EXPORT * qwsServer
int depth() const
Returns the depth of the framebuffer, in bits per pixel.
Definition: qscreen_qws.h:229
void(* BlitFunc)(QScreen *, const QImage &, const QRect &, const QPoint &)
const QList< QWSWindow * > & clientWindows()
Returns the list of current top-level windows.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288