Changeset View
Changeset View
Standalone View
Standalone View
scene.h
Show First 20 Lines • Show All 326 Lines • ▼ Show 20 Line(s) | 317 | enum { | |||
---|---|---|---|---|---|
327 | PAINT_DISABLED_BY_ACTIVITY = 1 << 5 | 327 | PAINT_DISABLED_BY_ACTIVITY = 1 << 5 | ||
328 | }; | 328 | }; | ||
329 | void enablePainting(int reason); | 329 | void enablePainting(int reason); | ||
330 | void disablePainting(int reason); | 330 | void disablePainting(int reason); | ||
331 | // is the window visible at all | 331 | // is the window visible at all | ||
332 | bool isVisible() const; | 332 | bool isVisible() const; | ||
333 | // is the window fully opaque | 333 | // is the window fully opaque | ||
334 | bool isOpaque() const; | 334 | bool isOpaque() const; | ||
335 | // is the window shaded | ||||
336 | bool isShaded() const; | ||||
335 | // shape of the window | 337 | // shape of the window | ||
336 | QRegion bufferShape() const; | 338 | QRegion bufferShape() const; | ||
337 | QRegion clientShape() const; | 339 | QRegion clientShape() const; | ||
338 | QRegion decorationShape() const; | 340 | QRegion decorationShape() const; | ||
339 | QPoint bufferOffset() const; | 341 | QPoint bufferOffset() const; | ||
340 | void discardShape(); | 342 | void discardShape(); | ||
341 | void updateToplevel(Toplevel* c); | 343 | void updateToplevel(Toplevel* c); | ||
342 | // creates initial quad list for the window | 344 | // creates initial quad list for the window | ||
343 | virtual WindowQuadList buildQuads(bool force = false) const; | 345 | virtual WindowQuadList buildQuads(bool force = false) const; | ||
344 | void updateShadow(Shadow* shadow); | 346 | void updateShadow(Shadow* shadow); | ||
345 | const Shadow* shadow() const; | 347 | const Shadow* shadow() const; | ||
346 | Shadow* shadow(); | 348 | Shadow* shadow(); | ||
347 | void referencePreviousPixmap(); | 349 | void referencePreviousPixmap(); | ||
348 | void unreferencePreviousPixmap(); | 350 | void unreferencePreviousPixmap(); | ||
349 | void invalidateQuadsCache(); | 351 | void invalidateQuadsCache(); | ||
352 | void preprocess(); | ||||
350 | protected: | 353 | protected: | ||
351 | WindowQuadList makeDecorationQuads(const QRect *rects, const QRegion ®ion, qreal textureScale = 1.0) const; | 354 | WindowQuadList makeDecorationQuads(const QRect *rects, const QRegion ®ion, qreal textureScale = 1.0) const; | ||
352 | WindowQuadList makeContentsQuads() const; | 355 | WindowQuadList makeContentsQuads() const; | ||
353 | /** | 356 | /** | ||
354 | * @brief Returns the WindowPixmap for this Window. | 357 | * @brief Returns the WindowPixmap for this Window. | ||
355 | * | 358 | * | ||
356 | * If the WindowPixmap does not yet exist, this method will invoke createWindowPixmap. | 359 | * If the WindowPixmap does not yet exist, this method will invoke createWindowPixmap. | ||
357 | * If the WindowPixmap is not valid it tries to create it, in case this succeeds the WindowPixmap is | 360 | * If the WindowPixmap is not valid it tries to create it, in case this succeeds the WindowPixmap is | ||
358 | * returned. In case it fails, the previous (and still valid) WindowPixmap is returned. | 361 | * returned. In case it fails, the previous (and still valid) WindowPixmap is returned. | ||
359 | * | 362 | * | ||
360 | * @note This method can return @c NULL as there might neither be a valid previous nor current WindowPixmap | 363 | * @note This method can return @c NULL as there might neither be a valid previous nor current WindowPixmap | ||
361 | * around. | 364 | * around. | ||
362 | * | 365 | * | ||
363 | * The WindowPixmap gets casted to the type passed in as a template parameter. That way this class does not | 366 | * The WindowPixmap gets casted to the type passed in as a template parameter. That way this class does not | ||
364 | * need to know the actual WindowPixmap subclass used by the concrete Scene implementations. | 367 | * need to know the actual WindowPixmap subclass used by the concrete Scene implementations. | ||
365 | * | 368 | * | ||
366 | * @return The WindowPixmap casted to T* or @c NULL if there is no valid window pixmap. | 369 | * @return The WindowPixmap casted to T* or @c NULL if there is no valid window pixmap. | ||
367 | */ | 370 | */ | ||
368 | template<typename T> T *windowPixmap(); | 371 | template<typename T> T *windowPixmap() const; | ||
369 | template<typename T> T *previousWindowPixmap(); | 372 | template<typename T> T *previousWindowPixmap() const; | ||
370 | /** | 373 | /** | ||
371 | * @brief Factory method to create a WindowPixmap. | 374 | * @brief Factory method to create a WindowPixmap. | ||
372 | * | 375 | * | ||
373 | * The inheriting classes need to implement this method to create a new instance of their WindowPixmap subclass. | 376 | * The inheriting classes need to implement this method to create a new instance of their WindowPixmap subclass. | ||
374 | * @note Do not use WindowPixmap::create on the created instance. The Scene will take care of that. | 377 | * @note Do not use WindowPixmap::create on the created instance. The Scene will take care of that. | ||
375 | */ | 378 | */ | ||
376 | virtual WindowPixmap *createWindowPixmap() = 0; | 379 | virtual WindowPixmap *createWindowPixmap() = 0; | ||
377 | Toplevel* toplevel; | 380 | Toplevel* toplevel; | ||
Show All 36 Lines | 412 | public: | |||
414 | * In case this method succeeds in creating the pixmap for the window, isValid will return @c true otherwise | 417 | * In case this method succeeds in creating the pixmap for the window, isValid will return @c true otherwise | ||
415 | * @c false. | 418 | * @c false. | ||
416 | * | 419 | * | ||
417 | * Inheriting classes should re-implement this method in case they need to add further functionality for mapping the | 420 | * Inheriting classes should re-implement this method in case they need to add further functionality for mapping the | ||
418 | * native pixmap to the rendering format. | 421 | * native pixmap to the rendering format. | ||
419 | */ | 422 | */ | ||
420 | virtual void create(); | 423 | virtual void create(); | ||
421 | /** | 424 | /** | ||
425 | * @brief Recursively updates the mapping between the WindowPixmap and the buffer. | ||||
426 | */ | ||||
427 | virtual void update(); | ||||
428 | /** | ||||
422 | * @return @c true if the pixmap has been created and is valid, @c false otherwise | 429 | * @return @c true if the pixmap has been created and is valid, @c false otherwise | ||
423 | */ | 430 | */ | ||
424 | virtual bool isValid() const; | 431 | virtual bool isValid() const; | ||
425 | /** | 432 | /** | ||
433 | * Returns @c true if this is the root window pixmap; otherwise returns @c false. | ||||
434 | */ | ||||
435 | bool isRoot() const; | ||||
436 | /** | ||||
426 | * @return The native X11 pixmap handle | 437 | * @return The native X11 pixmap handle | ||
427 | */ | 438 | */ | ||
428 | xcb_pixmap_t pixmap() const; | 439 | xcb_pixmap_t pixmap() const; | ||
429 | /** | 440 | /** | ||
430 | * @return The Wayland BufferInterface for this WindowPixmap. | 441 | * @return The Wayland BufferInterface for this WindowPixmap. | ||
431 | */ | 442 | */ | ||
432 | QPointer<KWayland::Server::BufferInterface> buffer() const; | 443 | QPointer<KWayland::Server::BufferInterface> buffer() const; | ||
433 | const QSharedPointer<QOpenGLFramebufferObject> &fbo() const; | 444 | const QSharedPointer<QOpenGLFramebufferObject> &fbo() const; | ||
Show All 9 Lines | |||||
443 | /** | 454 | /** | ||
444 | * @brief Marks this WindowPixmap as discarded. From now on isDiscarded will return @c true. This method should | 455 | * @brief Marks this WindowPixmap as discarded. From now on isDiscarded will return @c true. This method should | ||
445 | * only be used by the Window when it changes in a way that a new pixmap is required. | 456 | * only be used by the Window when it changes in a way that a new pixmap is required. | ||
446 | * | 457 | * | ||
447 | * @see isDiscarded | 458 | * @see isDiscarded | ||
448 | */ | 459 | */ | ||
449 | void markAsDiscarded(); | 460 | void markAsDiscarded(); | ||
450 | /** | 461 | /** | ||
462 | * Returns the position of the WindowPixmap relative to the upper left corner of the parent. | ||||
463 | * | ||||
464 | * This method returns the position of the WindowPixmap relative to the upper left corner | ||||
465 | * of the window pixmap if parent() is @c null. | ||||
466 | * | ||||
467 | * The upper left corner of the parent window pixmap corresponds to (0, 0). | ||||
468 | */ | ||||
469 | QPoint position() const; | ||||
470 | /** | ||||
471 | * Returns the position of the WindowPixmap relative to the upper left corner of the window | ||||
472 | * frame. Note that position() returns the position relative to the parent WindowPixmap. | ||||
473 | * | ||||
474 | * The upper left corner of the window frame corresponds to (0, 0). | ||||
475 | */ | ||||
476 | QPoint framePosition() const; | ||||
477 | /** | ||||
451 | * The size of the pixmap. | 478 | * The size of the pixmap. | ||
452 | */ | 479 | */ | ||
453 | const QSize &size() const; | 480 | const QSize &size() const; | ||
454 | /** | 481 | /** | ||
482 | * Returns the device pixel ratio for the attached buffer. This is the ratio between device | ||||
483 | * pixels and logical pixels. | ||||
484 | */ | ||||
485 | qreal scale() const; | ||||
486 | /** | ||||
487 | * Returns the region that specifies the area inside the attached buffer with the actual | ||||
488 | * client's contents. | ||||
489 | * | ||||
490 | * The upper left corner of the attached buffer corresponds to (0, 0). | ||||
491 | */ | ||||
492 | QRegion shape() const; | ||||
493 | /** | ||||
455 | * The geometry of the Client's content inside the pixmap. In case of a decorated Client the | 494 | * The geometry of the Client's content inside the pixmap. In case of a decorated Client the | ||
456 | * pixmap also contains the decoration which is not rendered into this pixmap, though. This | 495 | * pixmap also contains the decoration which is not rendered into this pixmap, though. This | ||
457 | * contentsRect tells where inside the complete pixmap the real content is. | 496 | * contentsRect tells where inside the complete pixmap the real content is. | ||
458 | */ | 497 | */ | ||
459 | const QRect &contentsRect() const; | 498 | const QRect &contentsRect() const; | ||
460 | /** | 499 | /** | ||
461 | * @brief Returns the Toplevel this WindowPixmap belongs to. | 500 | * @brief Returns the Toplevel this WindowPixmap belongs to. | ||
462 | * Note: the Toplevel can change over the lifetime of the WindowPixmap in case the Toplevel is copied to Deleted. | 501 | * Note: the Toplevel can change over the lifetime of the WindowPixmap in case the Toplevel is copied to Deleted. | ||
463 | */ | 502 | */ | ||
464 | Toplevel *toplevel() const; | 503 | Toplevel *toplevel() const; | ||
504 | /** | ||||
505 | * Returns @c true if the attached buffer has an alpha channel; otherwise returns @c false. | ||||
506 | */ | ||||
507 | bool hasAlphaChannel() const; | ||||
465 | 508 | | |||
466 | /** | 509 | /** | ||
467 | * @returns the parent WindowPixmap in the sub-surface tree | 510 | * @returns the parent WindowPixmap in the sub-surface tree | ||
468 | */ | 511 | */ | ||
469 | WindowPixmap *parent() const { | 512 | WindowPixmap *parent() const { | ||
470 | return m_parent; | 513 | return m_parent; | ||
471 | } | 514 | } | ||
472 | 515 | | |||
Show All 21 Lines | 535 | protected: | |||
494 | explicit WindowPixmap(const QPointer<KWayland::Server::SubSurfaceInterface> &subSurface, WindowPixmap *parent); | 537 | explicit WindowPixmap(const QPointer<KWayland::Server::SubSurfaceInterface> &subSurface, WindowPixmap *parent); | ||
495 | virtual WindowPixmap *createChild(const QPointer<KWayland::Server::SubSurfaceInterface> &subSurface); | 538 | virtual WindowPixmap *createChild(const QPointer<KWayland::Server::SubSurfaceInterface> &subSurface); | ||
496 | /** | 539 | /** | ||
497 | * @return The Window this WindowPixmap belongs to | 540 | * @return The Window this WindowPixmap belongs to | ||
498 | */ | 541 | */ | ||
499 | Scene::Window *window(); | 542 | Scene::Window *window(); | ||
500 | 543 | | |||
501 | /** | 544 | /** | ||
502 | * Should be called by the implementing subclasses when the Wayland Buffer changed and needs | | |||
503 | * updating. | | |||
504 | */ | | |||
505 | virtual void updateBuffer(); | | |||
506 | | ||||
507 | /** | | |||
508 | * Sets the sub-surface tree to @p children. | 545 | * Sets the sub-surface tree to @p children. | ||
509 | */ | 546 | */ | ||
510 | void setChildren(const QVector<WindowPixmap*> &children) { | 547 | void setChildren(const QVector<WindowPixmap*> &children) { | ||
511 | m_children = children; | 548 | m_children = children; | ||
512 | } | 549 | } | ||
513 | 550 | | |||
514 | private: | 551 | private: | ||
515 | Scene::Window *m_window; | 552 | Scene::Window *m_window; | ||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Line(s) | |||||
629 | inline | 666 | inline | ||
630 | QImage WindowPixmap::internalImage() const | 667 | QImage WindowPixmap::internalImage() const | ||
631 | { | 668 | { | ||
632 | return m_internalImage; | 669 | return m_internalImage; | ||
633 | } | 670 | } | ||
634 | 671 | | |||
635 | template <typename T> | 672 | template <typename T> | ||
636 | inline | 673 | inline | ||
637 | T* Scene::Window::windowPixmap() | 674 | T *Scene::Window::windowPixmap() const | ||
638 | { | 675 | { | ||
639 | if (m_currentPixmap.isNull()) { | | |||
640 | m_currentPixmap.reset(createWindowPixmap()); | | |||
641 | } | | |||
642 | if (m_currentPixmap->isValid()) { | | |||
643 | return static_cast<T*>(m_currentPixmap.data()); | | |||
644 | } | | |||
645 | m_currentPixmap->create(); | | |||
646 | if (m_currentPixmap->isValid()) { | 676 | if (m_currentPixmap->isValid()) { | ||
647 | return static_cast<T*>(m_currentPixmap.data()); | 677 | return static_cast<T*>(m_currentPixmap.data()); | ||
648 | } else { | 678 | } else { | ||
649 | return static_cast<T*>(m_previousPixmap.data()); | 679 | return static_cast<T*>(m_previousPixmap.data()); | ||
650 | } | 680 | } | ||
651 | } | 681 | } | ||
652 | 682 | | |||
653 | template <typename T> | 683 | template <typename T> | ||
654 | inline | 684 | inline | ||
655 | T* Scene::Window::previousWindowPixmap() | 685 | T *Scene::Window::previousWindowPixmap() const | ||
656 | { | 686 | { | ||
657 | return static_cast<T*>(m_previousPixmap.data()); | 687 | return static_cast<T*>(m_previousPixmap.data()); | ||
658 | } | 688 | } | ||
659 | 689 | | |||
660 | inline | 690 | inline | ||
661 | Toplevel* WindowPixmap::toplevel() const | 691 | Toplevel* WindowPixmap::toplevel() const | ||
662 | { | 692 | { | ||
663 | return m_window->window(); | 693 | return m_window->window(); | ||
Show All 38 Lines |