OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WINDOW_MANAGER_COMPOSITOR_XRENDER_XRENDER_VISITOR_H_ |
| 6 #define WINDOW_MANAGER_COMPOSITOR_XRENDER_XRENDER_VISITOR_H_ |
| 7 |
| 8 #include "base/logging.h" |
| 9 #include "base/scoped_ptr.h" |
| 10 #include "window_manager/compositor/compositor.h" |
| 11 #include "window_manager/compositor/real_compositor.h" |
| 12 #include "window_manager/compositor/texture_data.h" |
| 13 #include "window_manager/x11/x_connection.h" |
| 14 |
| 15 namespace window_manager { |
| 16 |
| 17 class ImageContainer; |
| 18 |
| 19 // This class visits an actor tree and draws it using the XRender extension. |
| 20 class XRenderDrawVisitor : virtual public RealCompositor::ActorVisitor { |
| 21 public: |
| 22 XRenderDrawVisitor(RealCompositor* compositor, |
| 23 Compositor::StageActor* stage); |
| 24 virtual ~XRenderDrawVisitor(); |
| 25 |
| 26 void set_has_fullscreen_actor(bool has_fullscreen_actor) { |
| 27 has_fullscreen_actor_ = has_fullscreen_actor; |
| 28 } |
| 29 void set_damaged_region(Rect damaged_region) { |
| 30 damaged_region_ = damaged_region; |
| 31 } |
| 32 |
| 33 void BindImage(const ImageContainer& container, |
| 34 RealCompositor::ImageActor* actor); |
| 35 |
| 36 virtual void VisitActor(RealCompositor::Actor* actor) {} |
| 37 virtual void VisitStage(RealCompositor::StageActor* actor); |
| 38 virtual void VisitContainer(RealCompositor::ContainerActor* actor); |
| 39 virtual void VisitImage(RealCompositor::ImageActor* actor); |
| 40 virtual void VisitTexturePixmap(RealCompositor::TexturePixmapActor* actor); |
| 41 virtual void VisitQuad(RealCompositor::QuadActor* actor); |
| 42 |
| 43 private: |
| 44 // So it can get access to the config data. |
| 45 friend class XRenderPixmapData; |
| 46 |
| 47 virtual bool FreeXResources(); |
| 48 virtual bool AllocateXResources(Compositor::StageActor* stage); |
| 49 |
| 50 XWindow root_window_; |
| 51 XConnection::WindowGeometry root_geometry_; |
| 52 |
| 53 // |back_picture_| the corresponding |back_pixmap_| are used to |
| 54 // implement a back/front buffer system. |
| 55 XPicture back_picture_; |
| 56 XPixmap back_pixmap_; |
| 57 |
| 58 // |stage_picture_| is the picture for the front buffer. |
| 59 // We don't need a stage_pixmap_ here as it is provided |
| 60 // by the common code already. |
| 61 XPicture stage_picture_; |
| 62 |
| 63 // The visitor should not change settings in the compositor while visiting |
| 64 // actors throughout the drawing process because the compositor may decide |
| 65 // to skip drawing frames as an optimization. |
| 66 RealCompositor* compositor_; // Not owned. |
| 67 XConnection* xconn_; // Not owned. |
| 68 RealCompositor::StageActor* stage_; // Not owned. |
| 69 |
| 70 // This is the cumulative opacity of all the ancestors of the |
| 71 // currently visited node. It is recalculated each time we enter or |
| 72 // leave a container node. |
| 73 float ancestor_opacity_; |
| 74 |
| 75 // The rectangular region of the screen that is damaged in the frame. |
| 76 // This information allows the draw visitor to perform partial updates. |
| 77 Rect damaged_region_; |
| 78 |
| 79 // This is used to indicate whether the entire screen will be covered by an |
| 80 // actor so we can optimize by not clearing the back buffer. |
| 81 bool has_fullscreen_actor_; |
| 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(XRenderDrawVisitor); |
| 84 }; |
| 85 |
| 86 } // namespace window_manager |
| 87 |
| 88 #endif // WINDOW_MANAGER_COMPOSITOR_XRENDER_XRENDER_VISITOR_H_ |
OLD | NEW |