From fa592c1040039e6dd0e83bc5d77aecd7d1c0a4e5 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 6 Dec 2004 19:35:05 +0000 Subject: [PATCH] remove GraphicsChannel and GraphicsLayer --- direct/src/showbase/ShowBase.py | 75 ++-- panda/src/display/Sources.pp | 11 - panda/src/display/config_display.cxx | 6 - panda/src/display/displayRegion.I | 22 ++ panda/src/display/displayRegion.cxx | 110 +++--- panda/src/display/displayRegion.h | 23 +- panda/src/display/display_composite1.cxx | 2 - panda/src/display/display_composite2.cxx | 1 - panda/src/display/display_headers.h | 38 --- panda/src/display/graphicsChannel.I | 29 -- panda/src/display/graphicsChannel.cxx | 301 ---------------- panda/src/display/graphicsChannel.h | 108 ------ panda/src/display/graphicsEngine.cxx | 16 +- panda/src/display/graphicsLayer.I | 50 --- panda/src/display/graphicsLayer.cxx | 315 ----------------- panda/src/display/graphicsLayer.h | 118 ------- panda/src/display/graphicsOutput.I | 59 ++-- panda/src/display/graphicsOutput.cxx | 320 +++++++----------- panda/src/display/graphicsOutput.h | 41 ++- panda/src/display/graphicsWindow.cxx | 27 +- panda/src/display/hardwareChannel.I | 67 ---- panda/src/display/hardwareChannel.cxx | 65 ---- panda/src/display/hardwareChannel.h | 84 ----- panda/src/distort/nonlinearImager.cxx | 3 +- panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx | 23 -- panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx | 27 -- panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx | 27 -- panda/src/framework/windowFramework.cxx | 26 +- .../glstuff/glGraphicsStateGuardian_src.cxx | 19 -- panda/src/grutil/frameRateMeter.I | 23 +- panda/src/grutil/frameRateMeter.cxx | 41 +-- panda/src/grutil/frameRateMeter.h | 14 +- panda/src/grutil/multitexReducer.cxx | 6 +- 33 files changed, 346 insertions(+), 1751 deletions(-) delete mode 100644 panda/src/display/display_headers.h delete mode 100644 panda/src/display/graphicsChannel.I delete mode 100644 panda/src/display/graphicsChannel.cxx delete mode 100644 panda/src/display/graphicsChannel.h delete mode 100644 panda/src/display/graphicsLayer.I delete mode 100644 panda/src/display/graphicsLayer.cxx delete mode 100644 panda/src/display/graphicsLayer.h delete mode 100644 panda/src/display/hardwareChannel.I delete mode 100644 panda/src/display/hardwareChannel.cxx delete mode 100644 panda/src/display/hardwareChannel.h diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 54333ec309..f93e631a27 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -595,10 +595,10 @@ class ShowBase(DirectObject.DirectObject): if flag: if not self.frameRateMeter: self.frameRateMeter = FrameRateMeter('frameRateMeter') - self.frameRateMeter.setupLayer(self.win) + self.frameRateMeter.setupWindow(self.win) else: if self.frameRateMeter: - self.frameRateMeter.clearLayer() + self.frameRateMeter.clearWindow() self.frameRateMeter = None @@ -645,11 +645,12 @@ class ShowBase(DirectObject.DirectObject): self.render2d.setMaterialOff(1) self.render2d.setTwoSided(1) - # The normal 2-d layer has an aspect ratio that matches the - # window, but its coordinate system is square. This means - # anything we parent to render2d gets stretched. For things - # where that makes a difference, we set up aspect2d, which - # scales things back to the right aspect ratio. + # The normal 2-d DisplayRegoin has an aspect ratio that + # matches the window, but its coordinate system is square. + # This means anything we parent to render2d gets stretched. + # For things where that makes a difference, we set up + # aspect2d, which scales things back to the right aspect + # ratio. aspectRatio = self.getAspectRatio() self.aspect2d = self.render2d.attachNewNode(PGTop("aspect2d")) self.aspect2d.setScale(1.0 / aspectRatio, 1.0, 1.0) @@ -691,11 +692,13 @@ class ShowBase(DirectObject.DirectObject): self.render2dp.setMaterialOff(1) self.render2dp.setTwoSided(1) - # The normal 2-d layer has an aspect ratio that matches the - # window, but its coordinate system is square. This means - # anything we parent to render2d gets stretched. For things - # where that makes a difference, we set up aspect2d, which - # scales things back to the right aspect ratio. + # The normal 2-d DisplayRegion has an aspect ratio that + # matches the window, but its coordinate system is square. + # This means anything we parent to render2d gets stretched. + # For things where that makes a difference, we set up + # aspect2d, which scales things back to the right aspect + # ratio. + aspectRatio = self.getAspectRatio() self.aspect2dp = self.render2dp.attachNewNode(PGTop("aspect2d")) self.aspect2dp.setScale(1.0 / aspectRatio, 1.0, 1.0) @@ -731,26 +734,20 @@ class ShowBase(DirectObject.DirectObject): return aspectRatio - def makeCamera(self, win, chan = None, layer = None, layerSort = 0, - scene = None, - displayRegion = (0, 1, 0, 1), aspectRatio = None, camName = 'cam'): + def makeCamera(self, win, sort = 0, scene = None, + displayRegion = (0, 1, 0, 1), aspectRatio = None, + camName = 'cam'): """ Makes a new 3-d camera associated with the indicated window, and creates a display region in the indicated subrectangle. """ - if chan == None: - chan = win.getChannel(0) - - if layer == None: - # Make a new layer on the window. - layer = chan.makeLayer(layerSort) - if scene == None: scene = self.render - # And make a display region on this layer of the requested + # Make a display region on this window of the requested # area. - dr = layer.makeDisplayRegion(*displayRegion) + dr = win.makeDisplayRegion(*displayRegion) + dr.setSort(sort) # By default, we do not clear 3-d display regions (the entire # window will be cleared, which is normally sufficient). @@ -784,22 +781,16 @@ class ShowBase(DirectObject.DirectObject): return cam - def makeCamera2d(self, win, chan = None, layer = None, layerSort = 10, + def makeCamera2d(self, win, sort = 10, displayRegion = (0, 1, 0, 1), coords = (-1, 1, -1, 1)): """ Makes a new camera2d associated with the indicated window, and assigns it to render the indicated subrectangle of render2d. """ - if chan == None: - chan = win.getChannel(0) - - if layer == None: - # Make a new layer on the window. - layer = chan.makeLayer(layerSort) - - # And make a display region on this layer of the requested + # Make a display region on this window of the requested # area. - dr = layer.makeDisplayRegion(*displayRegion) + dr = win.makeDisplayRegion(*displayRegion) + dr.setSort(sort) # Enable clearing of the depth buffer on this new display # region (see the comment in setupRender2d, above). @@ -826,22 +817,16 @@ class ShowBase(DirectObject.DirectObject): return camera2d - def makeCamera2dp(self, win, chan = None, layer = None, layerSort = 20, - displayRegion = (0, 1, 0, 1), coords = (-1, 1, -1, 1)): + def makeCamera2dp(self, win, sort = 20, + displayRegion = (0, 1, 0, 1), coords = (-1, 1, -1, 1)): """ Makes a new camera2dp associated with the indicated window, and assigns it to render the indicated subrectangle of render2dp. """ - if chan == None: - chan = win.getChannel(0) - - if layer == None: - # Make a new layer on the window. - layer = chan.makeLayer(layerSort) - - # And make a display region on this layer of the requested + # Make a display region on this window of the requested # area. - dr = layer.makeDisplayRegion(*displayRegion) + dr = win.makeDisplayRegion(*displayRegion) + dr.setSort(sort) # Enable clearing of the depth buffer on this new display # region (see the comment in setupRender2d, above). diff --git a/panda/src/display/Sources.pp b/panda/src/display/Sources.pp index 567ed5fc0f..f959adb12d 100644 --- a/panda/src/display/Sources.pp +++ b/panda/src/display/Sources.pp @@ -18,10 +18,7 @@ displayRegionStack.h \ frameBufferProperties.I frameBufferProperties.h \ frameBufferStack.I frameBufferStack.h \ - graphicsChannel.I graphicsChannel.h \ graphicsEngine.I graphicsEngine.h \ - graphicsLayer.I \ - graphicsLayer.h \ graphicsOutput.I graphicsOutput.h \ graphicsBuffer.I graphicsBuffer.h \ graphicsPipe.I graphicsPipe.h \ @@ -35,8 +32,6 @@ graphicsDevice.h graphicsDevice.I \ parasiteBuffer.I parasiteBuffer.h \ windowProperties.I windowProperties.h \ - hardwareChannel.I \ - hardwareChannel.h \ lensStack.I lensStack.h \ savedFrameBuffer.I savedFrameBuffer.h @@ -45,9 +40,7 @@ drawableRegion.cxx \ displayRegion.cxx \ frameBufferProperties.cxx \ - graphicsChannel.cxx \ graphicsEngine.cxx \ - graphicsLayer.cxx \ graphicsOutput.cxx \ graphicsBuffer.cxx \ graphicsPipe.cxx \ @@ -58,7 +51,6 @@ graphicsDevice.cxx \ parasiteBuffer.cxx \ windowProperties.cxx \ - hardwareChannel.cxx \ savedFrameBuffer.cxx #define INSTALL_HEADERS \ @@ -68,9 +60,7 @@ displayRegionStack.h \ frameBufferProperties.I frameBufferProperties.h \ frameBufferStack.I frameBufferStack.h \ - graphicsChannel.I graphicsChannel.h \ graphicsEngine.I graphicsEngine.h \ - graphicsLayer.I graphicsLayer.h \ graphicsOutput.I graphicsOutput.h \ graphicsBuffer.I graphicsBuffer.h \ graphicsPipe.I graphicsPipe.h \ @@ -83,7 +73,6 @@ graphicsDevice.I graphicsDevice.h \ parasiteBuffer.I parasiteBuffer.h \ windowProperties.I windowProperties.h \ - hardwareChannel.I hardwareChannel.h \ lensStack.I lensStack.h \ renderBuffer.h \ savedFrameBuffer.I savedFrameBuffer.h diff --git a/panda/src/display/config_display.cxx b/panda/src/display/config_display.cxx index effad09c8f..bdd7df7a09 100644 --- a/panda/src/display/config_display.cxx +++ b/panda/src/display/config_display.cxx @@ -24,10 +24,7 @@ #include "graphicsOutput.h" #include "graphicsBuffer.h" #include "graphicsWindow.h" -#include "graphicsChannel.h" -#include "graphicsLayer.h" #include "parasiteBuffer.h" -#include "hardwareChannel.h" #include "textureContext.h" ConfigureDef(config_display); @@ -127,9 +124,6 @@ init_libdisplay() { GraphicsOutput::init_type(); GraphicsWindow::init_type(); GraphicsBuffer::init_type(); - GraphicsChannel::init_type(); - GraphicsLayer::init_type(); - HardwareChannel::init_type(); ParasiteBuffer::init_type(); TextureContext::init_type(); } diff --git a/panda/src/display/displayRegion.I b/panda/src/display/displayRegion.I index ae6ebe605d..dadfb6364f 100644 --- a/panda/src/display/displayRegion.I +++ b/panda/src/display/displayRegion.I @@ -17,6 +17,17 @@ //////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////// +// Function: DisplayRegion::operator < +// Access: Public +// Description: Returns true if this DisplayRegion should be sorted +// before the other one, false otherwise. +//////////////////////////////////////////////////////////////////// +INLINE bool DisplayRegion:: +operator < (const DisplayRegion &other) const { + return _sort < other._sort; +} + //////////////////////////////////////////////////////////////////// // Function: DisplayRegion::is_active // Access: Published @@ -28,6 +39,17 @@ is_active() const { return _active; } +//////////////////////////////////////////////////////////////////// +// Function: DisplayRegion::get_sort +// Access: Published +// Description: Returns the sort value associated with the +// DisplayRegion. +//////////////////////////////////////////////////////////////////// +INLINE int DisplayRegion:: +get_sort() const { + return _sort; +} + //////////////////////////////////////////////////////////////////// // Function: DisplayRegion::do_compute_pixels // Access: Private diff --git a/panda/src/display/displayRegion.cxx b/panda/src/display/displayRegion.cxx index e38c7d1921..9a8b402b2d 100644 --- a/panda/src/display/displayRegion.cxx +++ b/panda/src/display/displayRegion.cxx @@ -17,8 +17,6 @@ //////////////////////////////////////////////////////////////////// #include "displayRegion.h" -#include "graphicsLayer.h" -#include "graphicsChannel.h" #include "graphicsOutput.h" #include "config_display.h" #include "pixelBuffer.h" @@ -33,12 +31,12 @@ // Description: //////////////////////////////////////////////////////////////////// DisplayRegion:: -DisplayRegion(GraphicsLayer *layer) : +DisplayRegion(GraphicsOutput *window) : _l(0.), _r(1.), _b(0.), _t(1.), - _layer(layer), - _window(layer->get_window()), + _window(window), _camera_node((Camera *)NULL), - _active(true) + _active(true), + _sort(0) { compute_pixels(); } @@ -49,33 +47,15 @@ DisplayRegion(GraphicsLayer *layer) : // Description: //////////////////////////////////////////////////////////////////// DisplayRegion:: -DisplayRegion(GraphicsLayer *layer, const float l, +DisplayRegion(GraphicsOutput *window, const float l, const float r, const float b, const float t) : _l(l), _r(r), _b(b), _t(t), - _layer(layer), - _window(layer->get_window()), - _camera_node((Camera *)NULL), - _active(true) -{ - compute_pixels(); -} - -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::Constructor -// Access: Public -// Description: This constructor makes a DisplayRegion that is not -// associated with any particular layer; this is -// typically for rendering a temporary pass. -//////////////////////////////////////////////////////////////////// -DisplayRegion:: -DisplayRegion(GraphicsOutput *window, int xsize, int ysize) : - _l(0.), _r(1.), _b(0.), _t(1.), - _pl(0), _pr(xsize), _pb(0), _pt(ysize), _pbi(ysize), _pti(0), - _layer((GraphicsLayer *)NULL), _window(window), _camera_node((Camera *)NULL), - _active(true) + _active(true), + _sort(0) { + compute_pixels(); } //////////////////////////////////////////////////////////////////// @@ -106,13 +86,18 @@ operator = (const DisplayRegion&) { DisplayRegion:: ~DisplayRegion() { set_camera(NodePath()); + + // The window pointer should already have been cleared by the time + // the DisplayRegion destructs (since the GraphicsOutput class keeps + // a reference count on the DisplayRegion). + nassertv(_window == (GraphicsOutput *)NULL); } //////////////////////////////////////////////////////////////////// // Function: DisplayRegion::get_dimensions // Access: Published // Description: Retrieves the coordinates of the DisplayRegion's -// rectangle within its GraphicsLayer. These numbers +// rectangle within its GraphicsOutput. These numbers // will be in the range [0..1]. //////////////////////////////////////////////////////////////////// void DisplayRegion:: @@ -128,7 +113,7 @@ get_dimensions(float &l, float &r, float &b, float &t) const { // Function: DisplayRegion::get_left // Access: Published // Description: Retrieves the x coordinate of the left edge of the -// rectangle within its GraphicsLayer. This number +// rectangle within its GraphicsOutput. This number // will be in the range [0..1]. //////////////////////////////////////////////////////////////////// float DisplayRegion:: @@ -141,7 +126,7 @@ get_left() const { // Function: DisplayRegion::get_right // Access: Published // Description: Retrieves the x coordinate of the right edge of the -// rectangle within its GraphicsLayer. This number +// rectangle within its GraphicsOutput. This number // will be in the range [0..1]. //////////////////////////////////////////////////////////////////// float DisplayRegion:: @@ -154,7 +139,7 @@ get_right() const { // Function: DisplayRegion::get_bottom // Access: Published // Description: Retrieves the y coordinate of the bottom edge of -// the rectangle within its GraphicsLayer. This +// the rectangle within its GraphicsOutput. This // number will be in the range [0..1]. //////////////////////////////////////////////////////////////////// float DisplayRegion:: @@ -167,7 +152,7 @@ get_bottom() const { // Function: DisplayRegion::get_top // Access: Published // Description: Retrieves the y coordinate of the top edge of the -// rectangle within its GraphicsLayer. This number +// rectangle within its GraphicsOutput. This number // will be in the range [0..1]. //////////////////////////////////////////////////////////////////// float DisplayRegion:: @@ -199,32 +184,6 @@ set_dimensions(float l, float r, float b, float t) { } } -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_layer -// Access: Published -// Description: Returns the layer associated with this particular -// DisplayRegion, or NULL if no layer is associated -// (or if the layer was deleted). -//////////////////////////////////////////////////////////////////// -GraphicsLayer *DisplayRegion:: -get_layer() const { - MutexHolder holder(_lock); - return _layer; -} - -//////////////////////////////////////////////////////////////////// -// Function: DisplayRegion::get_channel -// Access: Published -// Description: Returns the GraphicsChannel that this DisplayRegion is -// ultimately associated with, or NULL if no channel is -// associated. -//////////////////////////////////////////////////////////////////// -GraphicsChannel *DisplayRegion:: -get_channel() const { - MutexHolder holder(_lock); - return (_layer != (GraphicsLayer *)NULL) ? _layer->get_channel() : NULL; -} - //////////////////////////////////////////////////////////////////// // Function: DisplayRegion::get_window // Access: Published @@ -315,12 +274,29 @@ set_active(bool active) { } } +//////////////////////////////////////////////////////////////////// +// Function: DisplayRegion::set_sort +// Access: Published +// Description: Sets the sort value associated with the +// DisplayRegion. Within a window, DisplayRegions will +// be rendered in order from the lowest sort value to +// the highest. +//////////////////////////////////////////////////////////////////// +void DisplayRegion:: +set_sort(int sort) { + MutexHolder holder(_lock); + if (sort != _sort) { + _sort = sort; + win_display_regions_changed(); + } +} + //////////////////////////////////////////////////////////////////// // Function: DisplayRegion::compute_pixels // Access: Published // Description: Computes the pixel locations of the DisplayRegion -// within its layer. The DisplayRegion will request the -// size from the window. +// within its window. The DisplayRegion will request +// the size from the window. //////////////////////////////////////////////////////////////////// void DisplayRegion:: compute_pixels() { @@ -336,7 +312,7 @@ compute_pixels() { // Function: DisplayRegion::compute_pixels // Access: Published // Description: Computes the pixel locations of the DisplayRegion -// within its layer, given the size of the layer in +// within its window, given the size of the window in // pixels. //////////////////////////////////////////////////////////////////// void DisplayRegion:: @@ -349,7 +325,7 @@ compute_pixels(int x_size, int y_size) { // Function: DisplayRegion::get_pixels // Access: Published // Description: Retrieves the coordinates of the DisplayRegion within -// its layer, in pixels. +// its window, in pixels. //////////////////////////////////////////////////////////////////// void DisplayRegion:: get_pixels(int &pl, int &pr, int &pb, int &pt) const { @@ -364,7 +340,7 @@ get_pixels(int &pl, int &pr, int &pb, int &pt) const { // Function: DisplayRegion::get_region_pixels // Access: Published // Description: Retrieves the coordinates of the DisplayRegion within -// its layer, as the pixel location of its bottom-left +// its window, as the pixel location of its bottom-left // corner, along with a pixel width and height. //////////////////////////////////////////////////////////////////// void DisplayRegion:: @@ -435,7 +411,7 @@ output(ostream &out) const { // filename, and returns the filename, or empty string // if the screenshot failed. The default filename is // generated from the supplied prefix and from the -// Configrc variable screenshot-filename, which contains +// Config variable screenshot-filename, which contains // the following strings: // // %~p - the supplied prefix @@ -573,7 +549,7 @@ get_screenshot(PNMImage &image) { //////////////////////////////////////////////////////////////////// void DisplayRegion:: win_display_regions_changed() { - if (_layer != (GraphicsLayer *)NULL) { - _layer->win_display_regions_changed(); + if (_window != (GraphicsOutput *)NULL) { + _window->win_display_regions_changed(); } } diff --git a/panda/src/display/displayRegion.h b/panda/src/display/displayRegion.h index 2711674788..79f8b1f528 100644 --- a/panda/src/display/displayRegion.h +++ b/panda/src/display/displayRegion.h @@ -30,8 +30,6 @@ #include "plist.h" -class GraphicsLayer; -class GraphicsChannel; class GraphicsOutput; class GraphicsPipe; class CullHandler; @@ -45,14 +43,16 @@ class PNMImage; // covers the whole window, but you may also create // smaller DisplayRegions for having different regions // within the window that represent different scenes. +// You may also stack up DisplayRegions like panes of +// glass, usually for layering 2-d interfaces on top of +// a 3-d scene. //////////////////////////////////////////////////////////////////// class EXPCL_PANDA DisplayRegion : public ReferenceCount, public DrawableRegion { -public: - DisplayRegion(GraphicsLayer *layer); - DisplayRegion(GraphicsLayer *layer, +protected: + DisplayRegion(GraphicsOutput *window); + DisplayRegion(GraphicsOutput *window, const float l, const float r, const float b, const float t); - DisplayRegion(GraphicsOutput *window, int xsize, int ysize); private: DisplayRegion(const DisplayRegion ©); void operator = (const DisplayRegion ©); @@ -60,6 +60,8 @@ private: public: ~DisplayRegion(); + INLINE bool operator < (const DisplayRegion &other) const; + PUBLISHED: void get_dimensions(float &l, float &r, float &b, float &t) const; float get_left() const; @@ -68,8 +70,6 @@ PUBLISHED: float get_top() const; void set_dimensions(float l, float r, float b, float t); - GraphicsLayer *get_layer() const; - GraphicsChannel *get_channel() const; GraphicsOutput *get_window() const; GraphicsPipe *get_pipe() const; @@ -79,6 +79,9 @@ PUBLISHED: void set_active(bool active); INLINE bool is_active() const; + void set_sort(int sort); + INLINE int get_sort() const; + void compute_pixels(); void compute_pixels(int x_size, int y_size); void get_pixels(int &pl, int &pr, int &pb, int &pt) const; @@ -111,7 +114,6 @@ private: int _pbi; int _pti; - GraphicsLayer *_layer; GraphicsOutput *_window; NodePath _camera; @@ -120,14 +122,15 @@ private: PT(Camera) _camera_node; bool _active; + int _sort; // This is used to cache the culling result from last frame's // drawing into this display region. It should only be accessed or // modified by the GraphicsEngine, during the cull traversal. PT(CullResult) _cull_result; - friend class GraphicsLayer; friend class GraphicsEngine; + friend class GraphicsOutput; }; INLINE ostream &operator << (ostream &out, const DisplayRegion &dr); diff --git a/panda/src/display/display_composite1.cxx b/panda/src/display/display_composite1.cxx index 9b46213368..31609ad0ac 100644 --- a/panda/src/display/display_composite1.cxx +++ b/panda/src/display/display_composite1.cxx @@ -1,8 +1,6 @@ #include "drawableRegion.cxx" #include "displayRegion.cxx" -#include "graphicsChannel.cxx" #include "graphicsEngine.cxx" -#include "graphicsLayer.cxx" #include "graphicsPipe.cxx" #include "graphicsStateGuardian.cxx" #include "graphicsWindowInputDevice.cxx" diff --git a/panda/src/display/display_composite2.cxx b/panda/src/display/display_composite2.cxx index b3796ae60c..5b89f1f1e9 100644 --- a/panda/src/display/display_composite2.cxx +++ b/panda/src/display/display_composite2.cxx @@ -3,7 +3,6 @@ #include "graphicsPipeSelection.cxx" #include "graphicsThreadingModel.cxx" #include "graphicsDevice.cxx" -#include "hardwareChannel.cxx" #include "savedFrameBuffer.cxx" #include "windowProperties.cxx" #include "graphicsWindow.cxx" diff --git a/panda/src/display/display_headers.h b/panda/src/display/display_headers.h deleted file mode 100644 index 4b62ae96ef..0000000000 --- a/panda/src/display/display_headers.h +++ /dev/null @@ -1,38 +0,0 @@ -// Filename: xxx_headers.h -// Created by: georges (30May01) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// - -#include "keyboardButton.h" -#include "mouseButton.h" - -#include "config_display.h" -#include "graphicsChannel.h" -#include "graphicsLayer.h" -#include "graphicsPipe.h" -#include "graphicsStateGuardian.h" -#include "graphicsWindow.h" -#include "hardwareChannel.h" -#include "interactiveGraphicsPipe.h" -#include "noninteractiveGraphicsPipe.h" -#include "savedFrameBuffer.h" -#include "textureContext.h" - -#include -#include "pmap.h" - -#pragma hdrstop - diff --git a/panda/src/display/graphicsChannel.I b/panda/src/display/graphicsChannel.I deleted file mode 100644 index c9513c9a8b..0000000000 --- a/panda/src/display/graphicsChannel.I +++ /dev/null @@ -1,29 +0,0 @@ -// Filename: graphicsChannel.I -// Created by: frang (07Mar99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// - - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsChannel::is_active -// Access: Public -// Description: Returns the active flag on the channel. -//////////////////////////////////////////////////////////////////// -INLINE bool GraphicsChannel:: -is_active() const { - return _is_active; -} - diff --git a/panda/src/display/graphicsChannel.cxx b/panda/src/display/graphicsChannel.cxx deleted file mode 100644 index 9b38a80387..0000000000 --- a/panda/src/display/graphicsChannel.cxx +++ /dev/null @@ -1,301 +0,0 @@ -// Filename: graphicsChannel.cxx -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// - -#include "graphicsChannel.h" -#include "graphicsOutput.h" -#include "graphicsLayer.h" -#include "config_display.h" -#include "mutexHolder.h" - -#include "pmap.h" - -TypeHandle GraphicsChannel::_type_handle; - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsChannel::Constructor -// Access: Protected -// Description: -//////////////////////////////////////////////////////////////////// -GraphicsChannel:: -GraphicsChannel() { - _window = NULL; - _is_active = true; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsChannel::Constructor -// Access: Public -// Description: This is public just so derived window types can -// easily call it. Don't call it directly; instead, use -// GraphicsOutput::get_channel() to get a channel. -//////////////////////////////////////////////////////////////////// -GraphicsChannel:: -GraphicsChannel(GraphicsOutput *window) - : _window(window) -{ - _is_active = true; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsChannel::Copy Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// -INLINE GraphicsChannel:: -GraphicsChannel(const GraphicsChannel &) { - nassertv(false); -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsChannel::Copy Assignment Operator -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// -INLINE void GraphicsChannel:: -operator = (const GraphicsChannel &) { - nassertv(false); -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsChannel::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -GraphicsChannel:: -~GraphicsChannel() { - // We don't have to destruct our child display regions explicitly, - // since they are all reference-counted and will go away when their - // pointers do. However, we do need to zero out their pointers to - // us. - GraphicsLayers::iterator li; - for (li = _layers.begin(); - li != _layers.end(); - ++li) { - GraphicsLayer *layer = (*li); - MutexHolder holder(layer->_lock); - layer->_channel = NULL; - } - - // We don't need to remove ourself from the windows's list of - // channels. We must have already been removed, or we wouldn't be - // destructing! -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsChannel::make_layer -// Access: Published -// Description: Creates a new GraphicsLayer, associated with the -// window, with the indicated sort value. The sort -// value is an arbitrary integer, and may be zero or -// negative. The graphics layers are rendered in order -// from lower sort value to higher sort value; within -// layers of the same sort value, they are ordered in -// sequence from the first added to the last added. -//////////////////////////////////////////////////////////////////// -GraphicsLayer *GraphicsChannel:: -make_layer(int sort) { - MutexHolder holder(_lock); - PT(GraphicsLayer) layer = new GraphicsLayer(this, sort); - _layers.insert(layer); - - return layer; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsChannel::remove_layer -// Access: Published -// Description: Removes the indicated GraphicsLayer. Returns true if -// it was successfully removed, false if it was not a -// member of the channel in the first place. -//////////////////////////////////////////////////////////////////// -bool GraphicsChannel:: -remove_layer(GraphicsLayer *layer) { - MutexHolder holder(_lock); - GraphicsLayers::iterator li = find_layer(layer); - - if (li == _layers.end()) { - return false; - } - - _layers.erase(li); - win_display_regions_changed(); - return true; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsChannel::move_layer -// Access: Published -// Description: Reinserts the indicated layer into the list with the -// indicated sort value. The layer will be rendered -// last among all of the previously-added layers with -// the same sort value. If the new sort value is the -// same as the previous sort value, the layer will be -// moved to the end of the list of layers with this sort -// value. -// -// Returns true if the layer is successfully moved, -// false if it is not a member of this channel. -//////////////////////////////////////////////////////////////////// -bool GraphicsChannel:: -move_layer(GraphicsLayer *layer, int sort) { - MutexHolder holder(_lock); - - GraphicsLayers::iterator li = find_layer(layer); - if (li == _layers.end()) { - return false; - } - - PT(GraphicsLayer) hold_layer = layer; - _layers.erase(li); - layer->_sort = sort; - _layers.insert(layer); - - win_display_regions_changed(); - return true; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsChannel::get_num_layers -// Access: Published -// Description: Returns the number of layers currently associated -// with the channel. -//////////////////////////////////////////////////////////////////// -int GraphicsChannel:: -get_num_layers() const { - MutexHolder holder(_lock); - return _layers.size(); -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsChannel::get_layer -// Access: Published -// Description: Returns the nth layer associated with the channel. -// Walking through this list from 0 to (get_num_layers() -// - 1) will retrieve all of the layers in the order in -// which they will be rendered. It is therefore invalid -// to call make_layer(), remove_layer(), or move_layer() -// while traversing this list. -//////////////////////////////////////////////////////////////////// -GraphicsLayer *GraphicsChannel:: -get_layer(int index) const { - MutexHolder holder(_lock); - nassertr(index >= 0 && index < (int)_layers.size(), NULL); - return _layers[index]; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsChannel::get_window -// Access: Published -// Description: Returns the GraphicsOutput that this channel is -// associated with. It is possible that the -// GraphicsOutput might have been deleted while an -// outstanding PT(GraphicsChannel) prevented all of its -// children channels from also being deleted; in this -// unlikely case, get_window() may return NULL. -//////////////////////////////////////////////////////////////////// -GraphicsOutput *GraphicsChannel:: -get_window() const { - MutexHolder holder(_lock); - return _window; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsChannel::get_pipe -// Access: Published -// Description: Returns the GraphicsPipe that this channel is -// ultimately associated with, or NULL if no pipe is -// associated. -//////////////////////////////////////////////////////////////////// -GraphicsPipe *GraphicsChannel:: -get_pipe() const { - MutexHolder holder(_lock); - return (_window != (GraphicsOutput *)NULL) ? _window->get_pipe() : NULL; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsChannel::set_active -// Access: Published -// Description: Sets the active flag on the channel. If the channel -// is marked as inactive, nothing will be rendered. -//////////////////////////////////////////////////////////////////// -void GraphicsChannel:: -set_active(bool active) { - MutexHolder holder(_lock); - if (active != _is_active) { - _is_active = active; - win_display_regions_changed(); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsChannel::window_resized -// Access: Public, Virtual -// Description: This is called whenever the parent window has been -// resized; it should do whatever needs to be done to -// adjust the channel to account for it. -//////////////////////////////////////////////////////////////////// -void GraphicsChannel:: -window_resized(int x_size, int y_size) { - // By default, a normal GraphicsChannel fills the whole window, and - // so when the window resizes so does the channel, by the same - // amount. - MutexHolder holder(_lock); - GraphicsLayers::iterator li; - for (li = _layers.begin(); - li != _layers.end(); - ++li) { - (*li)->channel_resized(x_size, y_size); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsChannel::win_display_regions_changed -// Access: Private -// Description: Intended to be called when the active state on a -// nested channel or layer or display region changes, -// forcing the window to recompute its list of active -// display regions. It is assumed the lock is already -// held. -//////////////////////////////////////////////////////////////////// -void GraphicsChannel:: -win_display_regions_changed() { - if (_window != (GraphicsOutput *)NULL) { - _window->win_display_regions_changed(); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsChannel::find_layer -// Access: Private -// Description: Returns the iterator corresponding to the indicated -// layer, or _layers.end() if the layer is not part of -// this channel. -//////////////////////////////////////////////////////////////////// -GraphicsChannel::GraphicsLayers::iterator GraphicsChannel:: -find_layer(GraphicsLayer *layer) { - GraphicsLayers::iterator li = _layers.lower_bound(layer); - while (li != _layers.end() && (*li) != layer) { - if (*layer < *(*li)) { - // The layer was not found. - return _layers.end(); - } - ++li; - } - - return li; -} diff --git a/panda/src/display/graphicsChannel.h b/panda/src/display/graphicsChannel.h deleted file mode 100644 index 9d37a201aa..0000000000 --- a/panda/src/display/graphicsChannel.h +++ /dev/null @@ -1,108 +0,0 @@ -// Filename: graphicsChannel.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// -#ifndef GRAPHICSCHANNEL_H -#define GRAPHICSCHANNEL_H - -#include "pandabase.h" -#include "graphicsLayer.h" -#include "typedReferenceCount.h" -#include "pointerTo.h" -#include "pmutex.h" -#include "ordered_vector.h" -#include "indirectLess.h" - -class GraphicsChannel; -class GraphicsPipe; -class GraphicsOutput; -class CullHandler; - -//////////////////////////////////////////////////////////////////// -// Class : GraphicsChannel -// Description : This represents a single hardware output. Typically -// there is exactly one channel per GraphicsOutput, but -// some implementations (e.g. SGI) support potentially -// several different video channel ports connected to -// different parts within a window. -//////////////////////////////////////////////////////////////////// -class EXPCL_PANDA GraphicsChannel : public TypedReferenceCount { -protected: - GraphicsChannel(); - -public: - GraphicsChannel(GraphicsOutput *window); - -private: - GraphicsChannel(const GraphicsChannel ©); - void operator = (const GraphicsChannel ©); - -PUBLISHED: - virtual ~GraphicsChannel(); - GraphicsLayer *make_layer(int sort = 0); - bool remove_layer(GraphicsLayer *layer); - bool move_layer(GraphicsLayer *layer, int sort); - - int get_num_layers() const; - GraphicsLayer *get_layer(int index) const; - - GraphicsOutput *get_window() const; - GraphicsPipe *get_pipe() const; - - void set_active(bool active); - INLINE bool is_active() const; - -public: - virtual void window_resized(int x_size, int y_size); - -private: - void win_display_regions_changed(); - -protected: - Mutex _lock; - GraphicsOutput *_window; - bool _is_active; - - typedef ov_multiset< PT(GraphicsLayer), IndirectLess > GraphicsLayers; - GraphicsLayers _layers; - -private: - GraphicsLayers::iterator find_layer(GraphicsLayer *layer); - -public: - static TypeHandle get_class_type() { - return _type_handle; - } - static void init_type() { - TypedReferenceCount::init_type(); - register_type(_type_handle, "GraphicsChannel", - TypedReferenceCount::get_class_type()); - } - virtual TypeHandle get_type() const { - return get_class_type(); - } - virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - -private: - static TypeHandle _type_handle; - - friend class GraphicsOutput; - friend class GraphicsLayer; -}; - -#include "graphicsChannel.I" - -#endif /* GRAPHICSCHANNEL_H */ diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index 068957c9b1..e04ded72ee 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -703,10 +703,12 @@ cull_and_draw_together(const GraphicsEngine::Windows &wlist) { if (win->begin_frame()) { win->clear(); - int num_display_regions = win->get_num_display_regions(); + int num_display_regions = win->get_num_active_display_regions(); for (int i = 0; i < num_display_regions; i++) { - DisplayRegion *dr = win->get_display_region(i); - cull_and_draw_together(win->get_gsg(), dr); + DisplayRegion *dr = win->get_active_display_region(i); + if (dr != (DisplayRegion *)NULL) { + cull_and_draw_together(win->get_gsg(), dr); + } } win->end_frame(); @@ -773,10 +775,12 @@ cull_bin_draw(const GraphicsEngine::Windows &wlist) { if (win->begin_frame()) { win->clear(); - int num_display_regions = win->get_num_display_regions(); + int num_display_regions = win->get_num_active_display_regions(); for (int i = 0; i < num_display_regions; i++) { - DisplayRegion *dr = win->get_display_region(i); - cull_bin_draw(win->get_gsg(), dr); + DisplayRegion *dr = win->get_active_display_region(i); + if (dr != (DisplayRegion *)NULL) { + cull_bin_draw(win->get_gsg(), dr); + } } win->end_frame(); diff --git a/panda/src/display/graphicsLayer.I b/panda/src/display/graphicsLayer.I deleted file mode 100644 index 5f56447d9b..0000000000 --- a/panda/src/display/graphicsLayer.I +++ /dev/null @@ -1,50 +0,0 @@ -// Filename: graphicsLayer.I -// Created by: drose (18Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// - - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::Comparison operator -// Access: Published -// Description: Sorts the layers in order by sort parameter only. -//////////////////////////////////////////////////////////////////// -INLINE bool GraphicsLayer:: -operator < (const GraphicsLayer &other) const { - return _sort < other._sort; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::is_active -// Access: Published -// Description: Returns the active flag on the layer. -//////////////////////////////////////////////////////////////////// -INLINE bool GraphicsLayer:: -is_active() const { - return _is_active; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::get_sort -// Access: Published -// Description: Returns the sort parameter associated with the layer. -// This defines the order in which this layer is -// rendered relative to the other layers on the channel. -//////////////////////////////////////////////////////////////////// -INLINE int GraphicsLayer:: -get_sort() const { - return _sort; -} diff --git a/panda/src/display/graphicsLayer.cxx b/panda/src/display/graphicsLayer.cxx deleted file mode 100644 index 9dd527a331..0000000000 --- a/panda/src/display/graphicsLayer.cxx +++ /dev/null @@ -1,315 +0,0 @@ -// Filename: graphicsLayer.cxx -// Created by: drose (18Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// - -#include "graphicsLayer.h" -#include "graphicsChannel.h" -#include "graphicsOutput.h" -#include "config_display.h" -#include "notify.h" -#include "mutexHolder.h" - -#include - - -TypeHandle GraphicsLayer::_type_handle; - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::Constructor -// Access: Private -// Description: Use GraphicsChannel::make_layer() to make a new -// layer. -//////////////////////////////////////////////////////////////////// -GraphicsLayer:: -GraphicsLayer() { - _channel = NULL; - _sort = 0; - _is_active = true; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::Constructor -// Access: Public -// Description: Use GraphicsChannel::make_layer() to make a new -// layer. -//////////////////////////////////////////////////////////////////// -GraphicsLayer:: -GraphicsLayer(GraphicsChannel *channel, int sort) : - _channel(channel), - _sort(sort) -{ - _is_active = true; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::Copy Constructor -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// -GraphicsLayer:: -GraphicsLayer(const GraphicsLayer &) { - nassertv(false); -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::Copy Assignment Operator -// Access: Private -// Description: -//////////////////////////////////////////////////////////////////// -void GraphicsLayer:: -operator = (const GraphicsLayer &) { - nassertv(false); -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::Destructor -// Access: Published -// Description: -//////////////////////////////////////////////////////////////////// -GraphicsLayer:: -~GraphicsLayer() { - // We don't have to destruct our child display regions explicitly, - // since they are all reference-counted and will go away when their - // pointers do. However, we do need to zero out their pointers to - // us. - DisplayRegions::iterator dri; - for (dri = _display_regions.begin(); - dri != _display_regions.end(); - ++dri) { - DisplayRegion *dr = (*dri); - MutexHolder holder(dr->_lock); - dr->_layer = NULL; - } - win_display_regions_changed(); - - // We don't need to remove ourself from the channel's list of - // layers. We must have already been removed, or we wouldn't be - // destructing! -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::make_display_region -// Access: Published -// Description: Creates a new DisplayRegion that covers the entire -// layer. -//////////////////////////////////////////////////////////////////// -DisplayRegion *GraphicsLayer:: -make_display_region() { - PT(DisplayRegion) dr = new DisplayRegion(this); - - MutexHolder holder(_lock); - _display_regions.push_back(dr); - win_display_regions_changed(); - return dr; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::make_display_region -// Access: Published -// Description: Creates a new DisplayRegion that covers the indicated -// sub-rectangle within the layer. -//////////////////////////////////////////////////////////////////// -DisplayRegion *GraphicsLayer:: -make_display_region(float l, float r, float b, float t) { - nassertr(this != (GraphicsLayer *)NULL, NULL); - PT(DisplayRegion) dr = new DisplayRegion(this, l, r, b, t); - - MutexHolder holder(_lock); - _display_regions.push_back(dr); - win_display_regions_changed(); - return dr; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::get_num_drs -// Access: Published -// Description: Returns the number of DisplayRegions associated with -// the layer. -//////////////////////////////////////////////////////////////////// -int GraphicsLayer:: -get_num_drs() const { - MutexHolder holder(_lock); - return _display_regions.size(); -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::get_dr -// Access: Published -// Description: Returns the nth DisplayRegion associated with the -// layer. This might return NULL if another thread has -// recently removed a DisplayRegion. -//////////////////////////////////////////////////////////////////// -DisplayRegion *GraphicsLayer:: -get_dr(int index) const { - MutexHolder holder(_lock); - if (index >= 0 && index < (int)_display_regions.size()) { - return _display_regions[index]; - } else { - return NULL; - } -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::remove_dr -// Access: Published -// Description: Removes (and possibly deletes) the nth DisplayRegion -// associated with the layer. All subsequent index -// numbers will shift down one. -//////////////////////////////////////////////////////////////////// -void GraphicsLayer:: -remove_dr(int index) { - MutexHolder holder(_lock); - nassertv(index >= 0 && index < (int)_display_regions.size()); - _display_regions[index]->_layer = NULL; - _display_regions.erase(_display_regions.begin() + index); - win_display_regions_changed(); -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::remove_dr -// Access: Published -// Description: Removes (and possibly deletes) the indicated -// DisplayRegion associated with the layer. All -// subsequent index numbers will shift down one. -// Returns true if the DisplayRegion was removed, false -// if it was not a member of the layer. -//////////////////////////////////////////////////////////////////// -bool GraphicsLayer:: -remove_dr(DisplayRegion *display_region) { - MutexHolder holder(_lock); - PT(DisplayRegion) ptdr = display_region; - DisplayRegions::iterator dri = - find(_display_regions.begin(), _display_regions.end(), ptdr); - if (dri != _display_regions.end()) { - display_region->_layer = NULL; - _display_regions.erase(dri); - win_display_regions_changed(); - return true; - } - return false; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::get_channel -// Access: Published -// Description: Returns the GraphicsChannel that this layer is -// associated with. It is possible that the -// GraphicsChannel might have been deleted while an -// outstanding PT(GraphicsLayer) prevented all of its -// children layers from also being deleted; in this -// unlikely case, get_channel() may return NULL. -//////////////////////////////////////////////////////////////////// -GraphicsChannel *GraphicsLayer:: -get_channel() const { - MutexHolder holder(_lock); - return _channel; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::get_window -// Access: Published -// Description: Returns the GraphicsOutput that this layer is -// ultimately associated with, or NULL if no window is -// associated. -//////////////////////////////////////////////////////////////////// -GraphicsOutput *GraphicsLayer:: -get_window() const { - MutexHolder holder(_lock); - return (_channel != (GraphicsChannel *)NULL) ? _channel->get_window() : NULL; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::get_pipe -// Access: Published -// Description: Returns the GraphicsPipe that this layer is -// ultimately associated with, or NULL if no pipe is -// associated. -//////////////////////////////////////////////////////////////////// -GraphicsPipe *GraphicsLayer:: -get_pipe() const { - MutexHolder holder(_lock); - return (_channel != (GraphicsChannel *)NULL) ? _channel->get_pipe() : NULL; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::set_active -// Access: Published -// Description: Sets the active flag on the layer. If the layer -// is marked as inactive, nothing will be rendered. -//////////////////////////////////////////////////////////////////// -void GraphicsLayer:: -set_active(bool active) { - MutexHolder holder(_lock); - if (active != _is_active) { - _is_active = active; - win_display_regions_changed(); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::set_sort -// Access: Published -// Description: Changes the sort parameter on the layer. If the sort -// parameter is changed, the layer will be reordered -// among the other layers on the same channel. If the -// sort parameter is not changed, the layer will remain -// in the same sort position. (This is different from -// GraphicsChannel::move_layer(), which will reorder the -// layer even if the sort parameter does not change.) -//////////////////////////////////////////////////////////////////// -void GraphicsLayer:: -set_sort(int sort) { - if (sort != _sort) { - _channel->move_layer(this, sort); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::channel_resized -// Access: Public -// Description: This is called whenever the parent channel has been -// resized; it should do whatever needs to be done to -// adjust the layer to account for it. -//////////////////////////////////////////////////////////////////// -void GraphicsLayer:: -channel_resized(int x, int y) { - MutexHolder holder(_lock); - // Since a layer always fills the whole channel, when the channel - // resizes so does the layer, by the same amount. - DisplayRegions::iterator dri; - for (dri = _display_regions.begin(); - dri != _display_regions.end(); - ++dri) { - (*dri)->compute_pixels(x, y); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsLayer::win_display_regions_changed -// Access: Private -// Description: Intended to be called when the active state on a -// nested channel or layer or display region changes, -// forcing the window to recompute its list of active -// display regions. It is assumed the lock is already -// held. -//////////////////////////////////////////////////////////////////// -void GraphicsLayer:: -win_display_regions_changed() { - if (_channel != (GraphicsChannel *)NULL) { - _channel->win_display_regions_changed(); - } -} diff --git a/panda/src/display/graphicsLayer.h b/panda/src/display/graphicsLayer.h deleted file mode 100644 index cf68777853..0000000000 --- a/panda/src/display/graphicsLayer.h +++ /dev/null @@ -1,118 +0,0 @@ -// Filename: graphicsLayer.h -// Created by: drose (18Apr00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// - -#ifndef GRAPHICSLAYER_H -#define GRAPHICSLAYER_H - -#include "pandabase.h" - -#include "displayRegion.h" -#include "typedReferenceCount.h" -#include "pointerTo.h" -#include "pmutex.h" -#include "pvector.h" - -class GraphicsChannel; -class GraphicsOutput; -class GraphicsPipe; -class CullHandler; - -//////////////////////////////////////////////////////////////////// -// Class : GraphicsLayer -// Description : A layer is a collection of non-overlapping -// DisplayRegions within a Channel that will be rendered -// together. When the channel renders, it will render -// all of its layers in index number order; each layer -// may overlap some or all of its DisplayRegions with -// other layers, and they will be drawn sequentially -// without clearing the framebuffer between layers. -//////////////////////////////////////////////////////////////////// -class EXPCL_PANDA GraphicsLayer : public TypedReferenceCount { -private: - GraphicsLayer(); - GraphicsLayer(GraphicsChannel *channel, int sort); - -private: - GraphicsLayer(const GraphicsLayer ©); - void operator = (const GraphicsLayer ©); - -public: - INLINE bool operator < (const GraphicsLayer &other) const; - -PUBLISHED: - virtual ~GraphicsLayer(); - - DisplayRegion *make_display_region(); - DisplayRegion *make_display_region(float l, float r, - float b, float t); - - int get_num_drs() const; - DisplayRegion *get_dr(int index) const; - void remove_dr(int index); - bool remove_dr(DisplayRegion *display_region); - - GraphicsChannel *get_channel() const; - GraphicsOutput *get_window() const; - GraphicsPipe *get_pipe() const; - - void set_active(bool active); - INLINE bool is_active() const; - - void set_sort(int sort); - INLINE int get_sort() const; - -public: - void channel_resized(int x, int y); - -private: - void win_display_regions_changed(); - - Mutex _lock; - GraphicsChannel *_channel; - bool _is_active; - int _sort; - - typedef pvector< PT(DisplayRegion) > DisplayRegions; - DisplayRegions _display_regions; - - -public: - static TypeHandle get_class_type() { - return _type_handle; - } - static void init_type() { - TypedReferenceCount::init_type(); - register_type(_type_handle, "GraphicsLayer", - TypedReferenceCount::get_class_type()); - } - virtual TypeHandle get_type() const { - return get_class_type(); - } - virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - -private: - static TypeHandle _type_handle; - - friend class GraphicsChannel; - friend class GraphicsOutput; - friend class DisplayRegion; -}; - -#include "graphicsLayer.I" - -#endif /* GRAPHICSLAYER_H */ diff --git a/panda/src/display/graphicsOutput.I b/panda/src/display/graphicsOutput.I index 4397849889..786e518b1f 100644 --- a/panda/src/display/graphicsOutput.I +++ b/panda/src/display/graphicsOutput.I @@ -226,6 +226,29 @@ get_sort() const { return _sort; } +//////////////////////////////////////////////////////////////////// +// Function: GraphicsOutput::make_display_region +// Access: Published +// Description: Creates a new DisplayRegion that covers the entire +// window. +//////////////////////////////////////////////////////////////////// +INLINE DisplayRegion *GraphicsOutput:: +make_display_region() { + return add_display_region(new DisplayRegion(this)); +} + +//////////////////////////////////////////////////////////////////// +// Function: GraphicsOutput::make_display_region +// Access: Published +// Description: Creates a new DisplayRegion that covers the indicated +// sub-rectangle within the window. The range on all +// parameters is 0..1. +//////////////////////////////////////////////////////////////////// +INLINE DisplayRegion *GraphicsOutput:: +make_display_region(float l, float r, float b, float t) { + return add_display_region(new DisplayRegion(this, l, r, b, t)); +} + //////////////////////////////////////////////////////////////////// // Function: GraphicsOutput::save_screenshot_default // Access: Published @@ -233,7 +256,7 @@ get_sort() const { // filename, and returns the filename, or empty string // if the screenshot failed. The default filename is // generated from the supplied prefix and from the -// Configrc variable screenshot-filename, which contains +// Config variable screenshot-filename, which contains // the following strings: // // %~p - the supplied prefix @@ -243,8 +266,7 @@ get_sort() const { //////////////////////////////////////////////////////////////////// INLINE Filename GraphicsOutput:: save_screenshot_default(const string &prefix) { - DisplayRegion dr(this, _x_size, _y_size); - return dr.save_screenshot_default(prefix); + return _default_display_region->save_screenshot_default(prefix); } //////////////////////////////////////////////////////////////////// @@ -255,8 +277,7 @@ save_screenshot_default(const string &prefix) { //////////////////////////////////////////////////////////////////// INLINE bool GraphicsOutput:: save_screenshot(const Filename &filename) { - DisplayRegion dr(this, _x_size, _y_size); - return dr.save_screenshot(filename); + return _default_display_region->save_screenshot(filename); } //////////////////////////////////////////////////////////////////// @@ -268,21 +289,7 @@ save_screenshot(const Filename &filename) { //////////////////////////////////////////////////////////////////// INLINE bool GraphicsOutput:: get_screenshot(PNMImage &image) { - DisplayRegion dr(this, _x_size, _y_size); - return dr.get_screenshot(image); -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::win_display_regions_changed -// Access: Public -// Description: Intended to be called when the active state on a -// nested channel or layer or display region changes, -// forcing the window to recompute its list of active -// display regions. -//////////////////////////////////////////////////////////////////// -INLINE void GraphicsOutput:: -win_display_regions_changed() { - _display_regions_stale = true; + return _default_display_region->get_screenshot(image); } //////////////////////////////////////////////////////////////////// @@ -338,3 +345,15 @@ determine_display_regions() const { ((GraphicsOutput *)this)->do_determine_display_regions(); } } + +//////////////////////////////////////////////////////////////////// +// Function: GraphicsOutput::win_display_regions_changed +// Access: Private +// Description: Intended to be called when the active state on a +// nested display region changes, forcing the window to +// recompute its list of active display regions. +//////////////////////////////////////////////////////////////////// +INLINE void GraphicsOutput:: +win_display_regions_changed() { + _display_regions_stale = true; +} diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index 3d4d9fd52a..3de1b7febf 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -22,8 +22,8 @@ #include "graphicsWindow.h" #include "config_display.h" #include "mutexHolder.h" -#include "hardwareChannel.h" #include "renderBuffer.h" +#include "indirectLess.h" #include "pStatTimer.h" TypeHandle GraphicsOutput::_type_handle; @@ -65,6 +65,11 @@ GraphicsOutput(GraphicsPipe *pipe, GraphicsStateGuardian *gsg, _draw_buffer_type = RenderBuffer::T_front; } + // We start out with one DisplayRegion that covers the whole window, + // which we may use internally for full-window operations like + // clear() and get_screenshot(). + _default_display_region = make_display_region(0.0f, 1.0f, 0.0f, 1.0f); + _display_regions_stale = false; // By default, each new GraphicsOutput is set up to clear color and @@ -106,14 +111,20 @@ GraphicsOutput:: // We shouldn't have a GraphicsPipe pointer anymore. nassertv(_pipe == (GraphicsPipe *)NULL); - // We don't have to destruct our child channels explicitly, since - // they are all reference-counted and will go away when their + // We don't have to destruct our child display regions explicitly, + // since they are all reference-counted and will go away when their // pointers do. However, we do need to zero out their pointers to // us. - Channels::iterator ci; - for (ci = _channels.begin(); ci != _channels.end(); ++ci) { - (*ci)->_window = NULL; + TotalDisplayRegions::iterator dri; + for (dri = _total_display_regions.begin(); + dri != _total_display_regions.end(); + ++dri) { + (*dri)->_window = NULL; } + + _total_display_regions.clear(); + _active_display_regions.clear(); + _default_display_region = NULL; } //////////////////////////////////////////////////////////////////// @@ -191,129 +202,41 @@ set_sort(int sort) { } //////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_channel -// Access: Public -// Description: Returns a GraphicsChannel pointer that can be used to -// access the indicated channel number. All windows -// have at least one channel, channel 0, which -// corresponds to the entire window. If the hardware -// supports it, some kinds of windows may also have a -// number of hardware channels available at indices -// 1..n, which will correspond to a subregion of the -// window. +// Function: GraphicsOutput::remove_display_region +// Access: Published +// Description: Removes the indicated DisplayRegion from the window, +// and destructs it if there are no other references. // -// This function returns a GraphicsChannel pointer if a -// channel is available, or NULL if it is not. If -// called twice with the same index number, it will -// return the same pointer. -//////////////////////////////////////////////////////////////////// -GraphicsChannel *GraphicsOutput:: -get_channel(int index) { - MutexHolder holder(_lock); - nassertr(index >= 0, NULL); - - if (index < (int)_channels.size()) { - if (_channels[index] != (GraphicsChannel *)NULL) { - return _channels[index]; - } - } - - // This channel has never been requested before; define it. - - PT(GraphicsChannel) chan; - if (index == 0) { - // Channel 0 is the default channel: the entire screen. - chan = new GraphicsChannel(this); - } else { - // Any other channel is some hardware-specific channel. - GraphicsPipe *pipe = _pipe; - if (pipe != (GraphicsPipe *)NULL) { - chan = _pipe->get_hw_channel(this, index); - if (chan == (GraphicsChannel *)NULL) { - display_cat.error() - << "GraphicsOutput::get_channel() - got a NULL channel" << endl; - } else { - if (chan->get_window() != this) { - chan = NULL; - } - } - } - } - - if (chan != (GraphicsChannel *)NULL) { - declare_channel(index, chan); - } - - return chan; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::remove_channel -// Access: Public -// Description: Deletes a GraphicsChannel that was previously created -// via a call to get_channel(). Note that the channel -// is not actually deleted until all pointers to it are -// cleared. -//////////////////////////////////////////////////////////////////// -void GraphicsOutput:: -remove_channel(int index) { - MutexHolder holder(_lock); - if (index >= 0 && index < (int)_channels.size()) { - _channels[index].clear(); - } -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::get_max_channel_index -// Access: Public -// Description: Returns the largest channel index number yet created, -// plus 1. All channels associated with this window -// will have an index number in the range [0, -// get_max_channel_index()). This function, in -// conjunction with is_channel_defined(), below, may be -// used to determine the complete set of channels -// associated with the window. -//////////////////////////////////////////////////////////////////// -int GraphicsOutput:: -get_max_channel_index() const { - int result; - { - MutexHolder holder(_lock); - result = _channels.size(); - } - return result; -} - -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::is_channel_defined -// Access: Public -// Description: Returns true if the channel with the given index -// number has already been defined, false if it hasn't. -// If this returns true, calling get_channel() on the -// given index number will return the channel pointer. -// If it returns false, calling get_channel() will -// create and return a new channel pointer. +// Returns true if the DisplayRegion is found and +// removed, false if it was not a part of the window. //////////////////////////////////////////////////////////////////// bool GraphicsOutput:: -is_channel_defined(int index) const { - bool result; - { - MutexHolder holder(_lock); - if (index < 0 || index >= (int)_channels.size()) { - result = false; - } else { - result = (_channels[index] != (GraphicsChannel *)NULL); +remove_display_region(DisplayRegion *display_region) { + MutexHolder holder(_lock); + + nassertr(display_region != _default_display_region, false); + + TotalDisplayRegions::iterator dri = + find(_total_display_regions.begin(), _total_display_regions.end(), + display_region); + if (dri != _total_display_regions.end()) { + display_region->_window = NULL; + _total_display_regions.erase(dri); + if (display_region->is_active()) { + _display_regions_stale = true; } + + return true; } - return result; + + return false; } //////////////////////////////////////////////////////////////////// // Function: GraphicsOutput::get_num_display_regions // Access: Published -// Description: Returns the number of active DisplayRegions that have -// been created within the various layers and channels -// of the window. +// Description: Returns the number of DisplayRegions that have +// been created within the window, active or otherwise. //////////////////////////////////////////////////////////////////// int GraphicsOutput:: get_num_display_regions() const { @@ -321,7 +244,7 @@ get_num_display_regions() const { int result; { MutexHolder holder(_lock); - result = _display_regions.size(); + result = _total_display_regions.size(); } return result; } @@ -329,21 +252,61 @@ get_num_display_regions() const { //////////////////////////////////////////////////////////////////// // Function: GraphicsOutput::get_display_region // Access: Published -// Description: Returns the nth active DisplayRegion of those that -// have been created within the various layers and -// channels of the window. This may return NULL if n is -// out of bounds; particularly likely if the number of -// display regions has changed since the last call to +// Description: Returns the nth DisplayRegion of those that have been +// created within the window. This may return NULL if n +// is out of bounds; particularly likely if the number +// of display regions has changed since the last call to // get_num_display_regions(). //////////////////////////////////////////////////////////////////// -DisplayRegion *GraphicsOutput:: +PT(DisplayRegion) GraphicsOutput:: get_display_region(int n) const { determine_display_regions(); - DisplayRegion *result; + PT(DisplayRegion) result; { MutexHolder holder(_lock); - if (n >= 0 && n < (int)_display_regions.size()) { - result = _display_regions[n]; + if (n >= 0 && n < (int)_total_display_regions.size()) { + result = _total_display_regions[n]; + } else { + result = NULL; + } + } + return result; +} + +//////////////////////////////////////////////////////////////////// +// Function: GraphicsOutput::get_num_active_display_regions +// Access: Published +// Description: Returns the number of active DisplayRegions that have +// been created within the window. +//////////////////////////////////////////////////////////////////// +int GraphicsOutput:: +get_num_active_display_regions() const { + determine_display_regions(); + int result; + { + MutexHolder holder(_lock); + result = _active_display_regions.size(); + } + return result; +} + +//////////////////////////////////////////////////////////////////// +// Function: GraphicsOutput::get_active_display_region +// Access: Published +// Description: Returns the nth active DisplayRegion of those that +// have been created within the window. This may return +// NULL if n is out of bounds; particularly likely if +// the number of display regions has changed since the +// last call to get_num_active_display_regions(). +//////////////////////////////////////////////////////////////////// +PT(DisplayRegion) GraphicsOutput:: +get_active_display_region(int n) const { + determine_display_regions(); + PT(DisplayRegion) result; + { + MutexHolder holder(_lock); + if (n >= 0 && n < (int)_active_display_regions.size()) { + result = _active_display_regions[n]; } else { result = NULL; } @@ -455,34 +418,6 @@ make_texture_buffer(const string &name, int x_size, int y_size) { return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::make_scratch_display_region -// Access: Public -// Description: Allocates and returns a temporary DisplayRegion that -// may be used to render offscreen into. This -// DisplayRegion is not associated with any layer. -// -// To allocate a normal DisplayRegion for rendering, use -// the interface provided in GraphicsLayer. -//////////////////////////////////////////////////////////////////// -PT(DisplayRegion) GraphicsOutput:: -make_scratch_display_region(int x_size, int y_size) { -#ifndef NDEBUG - if (x_size > _x_size || y_size > _y_size) { - display_cat.error() - << "make_scratch_display_region(): requested region of size " - << x_size << ", " << y_size << " is larger than window of size " - << _x_size << ", " << _y_size << ".\n"; - x_size = min(x_size, _x_size); - y_size = min(y_size, _y_size); - } -#endif - - PT(DisplayRegion) region = new DisplayRegion(this, x_size, y_size); - region->copy_clear_settings(*this); - return region; -} - //////////////////////////////////////////////////////////////////// // Function: GraphicsOutput::get_host // Access: Public, Virtual @@ -586,9 +521,7 @@ clear() { if (is_any_clear_active()) { nassertv(_gsg != (GraphicsStateGuardian *)NULL); - PT(DisplayRegion) win_dr = - make_scratch_display_region(_x_size, _y_size); - DisplayRegionStack old_dr = _gsg->push_display_region(win_dr); + DisplayRegionStack old_dr = _gsg->push_display_region(_default_display_region); _gsg->clear(this); _gsg->pop_display_region(old_dr); } @@ -613,9 +546,8 @@ end_frame() { if (_copy_texture) { PStatTimer timer(_copy_texture_pcollector); nassertv(has_texture()); - DisplayRegion dr(this, _x_size, _y_size); RenderBuffer buffer = _gsg->get_render_buffer(get_draw_buffer_type()); - _gsg->copy_texture(get_texture(), &dr, buffer); + _gsg->copy_texture(get_texture(), _default_display_region, buffer); } // If we're not single-buffered, we're now ready to flip. @@ -721,59 +653,43 @@ process_events() { } //////////////////////////////////////////////////////////////////// -// Function: GraphicsOutput::declare_channel -// Access: Protected -// Description: An internal function to add the indicated -// newly-created channel to the list at the indicated -// channel number. -// -// The caller must grab and hold _lock before making -// this call. +// Function: GraphicsOutput::add_display_region +// Access: Private +// Description: Called by one of the make_display_region() methods to +// add the new DisplayRegion to the list. //////////////////////////////////////////////////////////////////// -void GraphicsOutput:: -declare_channel(int index, GraphicsChannel *chan) { - nassertv(index >= 0); - if (index >= (int)_channels.size()) { - _channels.reserve(index); - while (index >= (int)_channels.size()) { - _channels.push_back(NULL); - } - } +DisplayRegion *GraphicsOutput:: +add_display_region(DisplayRegion *display_region) { + MutexHolder holder(_lock); + _total_display_regions.push_back(display_region); + _display_regions_stale = true; - nassertv(index < (int)_channels.size()); - _channels[index] = chan; + return display_region; } //////////////////////////////////////////////////////////////////// // Function: GraphicsOutput::do_determine_display_regions // Access: Private -// Description: Recomputes the list of active DisplayRegions within +// Description: Re-sorts the list of active DisplayRegions within // the window. //////////////////////////////////////////////////////////////////// void GraphicsOutput:: do_determine_display_regions() { MutexHolder holder(_lock); _display_regions_stale = false; - _display_regions.clear(); - Channels::const_iterator ci; - for (ci = _channels.begin(); ci != _channels.end(); ++ci) { - GraphicsChannel *chan = (*ci); - if (chan->is_active()) { - GraphicsChannel::GraphicsLayers::const_iterator li; - for (li = chan->_layers.begin(); li != chan->_layers.end(); ++li) { - GraphicsLayer *layer = (*li); - if (layer->is_active()) { - GraphicsLayer::DisplayRegions::const_iterator dri; - for (dri = layer->_display_regions.begin(); - dri != layer->_display_regions.end(); - ++dri) { - DisplayRegion *dr = (*dri); - if (dr->is_active()) { - _display_regions.push_back(dr); - } - } - } - } + + _active_display_regions.clear(); + _active_display_regions.reserve(_total_display_regions.size()); + + TotalDisplayRegions::const_iterator dri; + for (dri = _total_display_regions.begin(); + dri != _total_display_regions.end(); + ++dri) { + DisplayRegion *display_region = (*dri); + if (display_region->is_active()) { + _active_display_regions.push_back(display_region); } } + + stable_sort(_active_display_regions.begin(), _active_display_regions.end(), IndirectLess()); } diff --git a/panda/src/display/graphicsOutput.h b/panda/src/display/graphicsOutput.h index 68c6f94771..5c13c00a4c 100644 --- a/panda/src/display/graphicsOutput.h +++ b/panda/src/display/graphicsOutput.h @@ -21,7 +21,6 @@ #include "pandabase.h" -#include "graphicsChannel.h" #include "graphicsPipe.h" #include "displayRegion.h" #include "graphicsStateGuardian.h" @@ -95,14 +94,16 @@ PUBLISHED: void set_sort(int sort); INLINE int get_sort() const; - GraphicsChannel *get_channel(int index); - void remove_channel(int index); - - int get_max_channel_index() const; - bool is_channel_defined(int index) const; + INLINE DisplayRegion *make_display_region(); + INLINE DisplayRegion *make_display_region(float l, float r, + float b, float t); + bool remove_display_region(DisplayRegion *display_region); int get_num_display_regions() const; - DisplayRegion *get_display_region(int n) const; + PT(DisplayRegion) get_display_region(int n) const; + + int get_num_active_display_regions() const; + PT(DisplayRegion) get_active_display_region(int n) const; GraphicsOutput *make_texture_buffer(const string &name, int x_size, int y_size); @@ -110,13 +111,8 @@ PUBLISHED: INLINE bool save_screenshot(const Filename &filename); INLINE bool get_screenshot(PNMImage &image); -public: - // No need to publish these. - PT(DisplayRegion) make_scratch_display_region(int x_size, int y_size); - public: // These are not intended to be called directly by the user. - INLINE void win_display_regions_changed(); INLINE bool needs_context() const; INLINE bool flip_ready() const; @@ -151,9 +147,6 @@ public: // thread other than the window thread. These methods are normally // called by the GraphicsEngine. virtual void process_events(); - -protected: - void declare_channel(int index, GraphicsChannel *chan); protected: PT(GraphicsStateGuardian) _gsg; @@ -165,6 +158,10 @@ protected: bool _needs_context; private: + DisplayRegion *add_display_region(DisplayRegion *display_region); + + INLINE void win_display_regions_changed(); + INLINE void determine_display_regions() const; void do_determine_display_regions(); @@ -177,13 +174,12 @@ protected: protected: Mutex _lock; - // protects _channels, _display_regions. - - typedef pvector< PT(GraphicsChannel) > Channels; - Channels _channels; - - typedef pvector DisplayRegions; - DisplayRegions _display_regions; + // protects _display_regions. + PT(DisplayRegion) _default_display_region; + typedef pvector< PT(DisplayRegion) > TotalDisplayRegions; + TotalDisplayRegions _total_display_regions; + typedef pvector ActiveDisplayRegions; + ActiveDisplayRegions _active_display_regions; bool _display_regions_stale; protected: @@ -214,6 +210,7 @@ private: friend class GraphicsPipe; friend class GraphicsEngine; + friend class DisplayRegion; }; #include "graphicsOutput.I" diff --git a/panda/src/display/graphicsWindow.cxx b/panda/src/display/graphicsWindow.cxx index 8e0018102f..4894976cba 100644 --- a/panda/src/display/graphicsWindow.cxx +++ b/panda/src/display/graphicsWindow.cxx @@ -22,7 +22,6 @@ #include "mouseButton.h" #include "keyboardButton.h" #include "mutexHolder.h" -#include "hardwareChannel.h" #include "throw_event.h" TypeHandle GraphicsWindow::_type_handle; @@ -490,10 +489,11 @@ set_properties_now(WindowProperties &properties) { _has_size = true; _is_valid = true; - Channels::iterator ci; - for (ci = _channels.begin(); ci != _channels.end(); ++ci) { - GraphicsChannel *chan = (*ci); - chan->window_resized(_x_size, _y_size); + TotalDisplayRegions::iterator dri; + for (dri = _total_display_regions.begin(); + dri != _total_display_regions.end(); + ++dri) { + (*dri)->compute_pixels(_x_size, _y_size); } } else { @@ -647,9 +647,9 @@ system_changed_properties(const WindowProperties &properties) { //////////////////////////////////////////////////////////////////// // Function: GraphicsWindow::system_changed_size // Access: Protected -// Description: An internal function to update all the channels with -// the new size of the window. This should always be -// called before changing the _size members of the +// Description: An internal function to update all the DisplayRegions +// with the new size of the window. This should always +// be called before changing the _size members of the // _properties structure. //////////////////////////////////////////////////////////////////// void GraphicsWindow:: @@ -664,11 +664,12 @@ system_changed_size(int x_size, int y_size) { _x_size = x_size; _y_size = y_size; _has_size = true; - - Channels::iterator ci; - for (ci = _channels.begin(); ci != _channels.end(); ++ci) { - GraphicsChannel *chan = (*ci); - chan->window_resized(x_size, y_size); + + TotalDisplayRegions::iterator dri; + for (dri = _total_display_regions.begin(); + dri != _total_display_regions.end(); + ++dri) { + (*dri)->compute_pixels(_x_size, _y_size); } } } diff --git a/panda/src/display/hardwareChannel.I b/panda/src/display/hardwareChannel.I deleted file mode 100644 index 10e34c58e1..0000000000 --- a/panda/src/display/hardwareChannel.I +++ /dev/null @@ -1,67 +0,0 @@ -// Filename: hardwareChannel.I -// Created by: mike (04Feb99) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////// -// Function: get_id -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE int HardwareChannel::get_id( void ) const -{ - return _id; -} - -//////////////////////////////////////////////////////////////////// -// Function: get_xorg -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE int HardwareChannel::get_xorg( void ) const -{ - return _xorg; -} - -//////////////////////////////////////////////////////////////////// -// Function: get_yorg -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE int HardwareChannel::get_yorg( void ) const -{ - return _yorg; -} - -//////////////////////////////////////////////////////////////////// -// Function: get_xsize -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE int HardwareChannel::get_xsize( void ) const -{ - return _xsize; -} - -//////////////////////////////////////////////////////////////////// -// Function: get_ysize -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE int HardwareChannel::get_ysize( void ) const -{ - return _ysize; -} diff --git a/panda/src/display/hardwareChannel.cxx b/panda/src/display/hardwareChannel.cxx deleted file mode 100644 index 7bbbbfee9d..0000000000 --- a/panda/src/display/hardwareChannel.cxx +++ /dev/null @@ -1,65 +0,0 @@ -// Filename: hardwareChannel.cxx -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// - -#include "hardwareChannel.h" -#include "config_display.h" - -//////////////////////////////////////////////////////////////////// -// Static variables -//////////////////////////////////////////////////////////////////// -TypeHandle HardwareChannel::_type_handle; - -//////////////////////////////////////////////////////////////////// -// Function: HardwareChannel::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -HardwareChannel:: -HardwareChannel( GraphicsWindow* window ) : - GraphicsChannel( window ) { - _id = 0; - _xorg = 0; - _yorg = 0; - _xsize = 0; - _ysize = 0; - - // Why do we do this? - set_active(false); -} - -//////////////////////////////////////////////////////////////////// -// Function: HardwareChannel::Destructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -HardwareChannel:: -~HardwareChannel(void) { - return; -} - -//////////////////////////////////////////////////////////////////// -// Function: HardwareChannel::window_resized -// Access: Public, Virtual -// Description: This is called whenever the parent window has been -// resized; it should do whatever needs to be done to -// adjust the channel to account for it. -//////////////////////////////////////////////////////////////////// -void HardwareChannel:: -window_resized(int, int) { - // A HardwareChannel ignores window resize messages. -} diff --git a/panda/src/display/hardwareChannel.h b/panda/src/display/hardwareChannel.h deleted file mode 100644 index 3c8ea0d442..0000000000 --- a/panda/src/display/hardwareChannel.h +++ /dev/null @@ -1,84 +0,0 @@ -// Filename: hardwareChannel.h -// Created by: mike (09Jan97) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://etc.cmu.edu/panda3d/docs/license/ . -// -// To contact the maintainers of this program write to -// panda3d-general@lists.sourceforge.net . -// -//////////////////////////////////////////////////////////////////// -#ifndef HARDWARECHANNEL_H -#define HARDWARECHANNEL_H -// -//////////////////////////////////////////////////////////////////// -// Includes -//////////////////////////////////////////////////////////////////// -#include "pandabase.h" - -#include "graphicsChannel.h" - -//////////////////////////////////////////////////////////////////// -// Defines -//////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////// -// Class : HardwareChannel -// Description : Video output channels if available on the current -// platform -// NOTE: hardware channels belong to a pipe rather -// than to a particular window -//////////////////////////////////////////////////////////////////// -class EXPCL_PANDA HardwareChannel : public GraphicsChannel -{ - public: - - HardwareChannel( GraphicsWindow* window ); - ~HardwareChannel( void ); - - virtual void window_resized(int x, int y); - - INLINE int get_id( void ) const; - INLINE int get_xorg( void ) const; - INLINE int get_yorg( void ) const; - INLINE int get_xsize( void ) const; - INLINE int get_ysize( void ) const; - - protected: - - int _id; - int _xorg; - int _yorg; - int _xsize; - int _ysize; - - public: - - static TypeHandle get_class_type() { - return _type_handle; - } - static void init_type() { - GraphicsChannel::init_type(); - register_type(_type_handle, "HardwareChannel", - GraphicsChannel::get_class_type()); - } - virtual TypeHandle get_type() const { - return get_class_type(); - } - virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - - private: - - static TypeHandle _type_handle; -}; - -#include "hardwareChannel.I" - -#endif diff --git a/panda/src/distort/nonlinearImager.cxx b/panda/src/distort/nonlinearImager.cxx index 740774baba..d075f65f28 100644 --- a/panda/src/distort/nonlinearImager.cxx +++ b/panda/src/distort/nonlinearImager.cxx @@ -684,8 +684,7 @@ recompute_screen(NonlinearImager::Screen &screen, size_t vi) { if (buffer != (GraphicsOutput *)NULL) { screen._buffer = buffer; - GraphicsLayer *layer = buffer->get_channel(0)->make_layer(); - DisplayRegion *dr = layer->make_display_region(); + DisplayRegion *dr = buffer->make_display_region(); dr->set_camera(screen._source_camera); } else { diff --git a/panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx b/panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx index a56a582940..54a2ada905 100644 --- a/panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx +++ b/panda/src/dxgsg7/dxGraphicsStateGuardian7.cxx @@ -25,7 +25,6 @@ #include "geomSphere.h" #include "geomIssuer.h" #include "graphicsWindow.h" -#include "graphicsChannel.h" #include "lens.h" #include "ambientLight.h" #include "directionalLight.h" @@ -459,9 +458,6 @@ dx_init( void) { _last_testcooplevel_result = S_OK; - // only 1 channel on dx currently - //_panda_gfx_channel = _win->get_channel(0); - HRESULT hr; #ifdef USE_TEXFMTVEC @@ -3532,27 +3528,8 @@ copy_texture(Texture *tex, const DisplayRegion *dr, const RenderBuffer &rb) { //////////////////////////////////////////////////////////////////// void DXGraphicsStateGuardian7:: texture_to_pixel_buffer(TextureContext *tc, PixelBuffer *pb) { -#if 1 dxgsg7_cat.error() << "texture_to_pixel_buffer unimplemented!\n"; -#else - nassertv(tc != NULL && pb != NULL); - - Texture *tex = tc->_texture; - - int w = tex->_pbuffer->get_xsize(); - int h = tex->_pbuffer->get_ysize(); - - PT(DisplayRegion) dr = _win->make_scratch_display_region(w, h); - - FrameBufferStack old_fb = push_frame_buffer - (get_render_buffer(RenderBuffer::T_back | RenderBuffer::T_depth), - dr); - - texture_to_pixel_buffer(tc, pb, dr); - - pop_frame_buffer(old_fb); -#endif } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx index d1d3f38a8a..12c7c19fbb 100644 --- a/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx +++ b/panda/src/dxgsg8/dxGraphicsStateGuardian8.cxx @@ -26,7 +26,6 @@ #include "geomIssuer.h" #include "graphicsWindow.h" #include "graphicsEngine.h" -#include "graphicsChannel.h" #include "lens.h" #include "ambientLight.h" #include "directionalLight.h" @@ -559,12 +558,6 @@ dx_init(void) { _last_testcooplevel_result = D3D_OK; -#if 0 - // unused now - // only 1 channel on dx currently - _panda_gfx_channel = _win->get_channel(0); -#endif - for(int i=0;i_texture; - - int w = tex->_pbuffer->get_xsize(); - int h = tex->_pbuffer->get_ysize(); - - PT(DisplayRegion) dr = _win->make_scratch_display_region(w, h); - - FrameBufferStack old_fb = push_frame_buffer - (get_render_buffer(RenderBuffer::T_back | RenderBuffer::T_depth), - dr); - - texture_to_pixel_buffer(tc, pb, dr); - - pop_frame_buffer(old_fb); -#else dxgsg8_cat.error() << "texture_to_pixel_buffer unimplemented for DX!\n"; -#endif } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index 8423290d92..5ceede9772 100755 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -26,7 +26,6 @@ #include "geomIssuer.h" #include "graphicsWindow.h" #include "graphicsEngine.h" -#include "graphicsChannel.h" #include "lens.h" #include "ambientLight.h" #include "directionalLight.h" @@ -559,12 +558,6 @@ dx_init(void) { _last_testcooplevel_result = D3D_OK; -#if 0 - // unused now - // only 1 channel on dx currently - _panda_gfx_channel = _win->get_channel(0); -#endif - for(int i=0;i_texture; - - int w = tex->_pbuffer->get_xsize(); - int h = tex->_pbuffer->get_ysize(); - - PT(DisplayRegion) dr = _win->make_scratch_display_region(w, h); - - FrameBufferStack old_fb = push_frame_buffer - (get_render_buffer(RenderBuffer::T_back | RenderBuffer::T_depth), - dr); - - texture_to_pixel_buffer(tc, pb, dr); - - pop_frame_buffer(old_fb); -#else dxgsg9_cat.error() << "texture_to_pixel_buffer unimplemented for DX!\n"; -#endif } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/framework/windowFramework.cxx b/panda/src/framework/windowFramework.cxx index 2c96fa1e0f..127e4c25c0 100644 --- a/panda/src/framework/windowFramework.cxx +++ b/panda/src/framework/windowFramework.cxx @@ -152,16 +152,9 @@ open_window(const WindowProperties &props, GraphicsEngine *engine, _window = engine->make_window(ptgsg, name, 0); if (_window != (GraphicsWindow *)NULL) { _window->request_properties(props); - - // Get the first channel on the window. This will be the only - // channel on non-SGI hardware. - PT(GraphicsChannel) channel = _window->get_channel(0); - // Make a layer on the channel to hold our display region. - PT(GraphicsLayer) layer = channel->make_layer(); - - // And create a display region that covers the entire window. - _display_region_3d = layer->make_display_region(); + // Create a display region that covers the entire window. + _display_region_3d = _window->make_display_region(); // Make sure the DisplayRegion does the clearing, not the window, // so we can have multiple DisplayRegions of different colors. @@ -174,7 +167,7 @@ open_window(const WindowProperties &props, GraphicsEngine *engine, if (show_frame_rate_meter) { _frame_rate_meter = new FrameRateMeter("frame_rate_meter"); - _frame_rate_meter->setup_layer(_window); + _frame_rate_meter->setup_window(_window); } } @@ -267,19 +260,12 @@ get_render_2d() { _render_2d.set_two_sided(1, 1); // Now set up a 2-d camera to view render_2d. - - // Get the first channel on the window. This will be the only - // channel on non-SGI hardware. - PT(GraphicsChannel) channel = _window->get_channel(0); - - // Make a layer on the channel to hold our display region. - PT(GraphicsLayer) layer = channel->make_layer(10); - // And create a display region that matches the size of the 3-d + // Create a display region that matches the size of the 3-d // display region. float l, r, b, t; _display_region_3d->get_dimensions(l, r, b, t); - _display_region_2d = layer->make_display_region(l, r, b, t); + _display_region_2d = _window->make_display_region(l, r, b, t); // Finally, we need a camera to associate with the display region. PT(Camera) camera = new Camera("camera2d"); @@ -704,7 +690,7 @@ split_window(SplitType split_type) { float left, right, bottom, top; _display_region_3d->get_dimensions(left, right, bottom, top); - new_region = _display_region_3d->get_layer()->make_display_region(); + new_region = _display_region_3d->get_window()->make_display_region(); if (split_type == ST_vertical) { _display_region_3d->set_dimensions(left, right, bottom, (top + bottom) / 2.0f); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index fbfc6ecbf7..5c00a803cc 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -22,7 +22,6 @@ #include "geom.h" #include "geomIssuer.h" #include "graphicsWindow.h" -#include "graphicsChannel.h" #include "lens.h" #include "perspectiveLens.h" #include "directionalLight.h" @@ -2068,24 +2067,6 @@ void CLP(GraphicsStateGuardian):: texture_to_pixel_buffer(TextureContext *tc, PixelBuffer *pb) { // This code is now invalidated by the new design; perhaps the // interface is not needed anyway. -#if 0 - nassertv(tc != NULL && pb != NULL); - Texture *tex = tc->_texture; - - int w = tex->_pbuffer->get_xsize(); - int h = tex->_pbuffer->get_ysize(); - - PT(DisplayRegion) dr = _win->make_scratch_display_region(w, h); - - FrameBufferStack old_fb = push_frame_buffer - (get_render_buffer(RenderBuffer::T_back | RenderBuffer::T_depth), - dr); - - texture_to_pixel_buffer(tc, pb, dr); - - pop_frame_buffer(old_fb); - report_my_gl_errors(); -#endif } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/grutil/frameRateMeter.I b/panda/src/grutil/frameRateMeter.I index 3dca8f360d..65984fd568 100644 --- a/panda/src/grutil/frameRateMeter.I +++ b/panda/src/grutil/frameRateMeter.I @@ -18,27 +18,16 @@ //////////////////////////////////////////////////////////////////// -// Function: FrameRateMeter::setup_layer +// Function: FrameRateMeter::get_window // Access: Published -// Description: Sets up the frame rate meter to create a layer to -// render itself into the indicated window. -//////////////////////////////////////////////////////////////////// -INLINE void FrameRateMeter:: -setup_layer(GraphicsOutput *window) { - setup_layer(window->get_channel(0)); -} - -//////////////////////////////////////////////////////////////////// -// Function: FrameRateMeter::get_layer -// Access: Published -// Description: Returns the GraphicsLayer that the meter has created +// Description: Returns the GraphicsOutput that the meter has created // to render itself into the window or channel supplied -// to setup_layer(), or NULL if setup_layer() has not +// to setup_window(), or NULL if setup_window() has not // been called. //////////////////////////////////////////////////////////////////// -INLINE GraphicsLayer *FrameRateMeter:: -get_layer() const { - return _layer; +INLINE GraphicsOutput *FrameRateMeter:: +get_window() const { + return _window; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/grutil/frameRateMeter.cxx b/panda/src/grutil/frameRateMeter.cxx index 6e2f190f46..c7452ca625 100644 --- a/panda/src/grutil/frameRateMeter.cxx +++ b/panda/src/grutil/frameRateMeter.cxx @@ -20,7 +20,6 @@ #include "camera.h" #include "displayRegion.h" #include "orthographicLens.h" -#include "graphicsChannel.h" #include "clockObject.h" #include "config_grutil.h" #include "depthTestAttrib.h" @@ -59,18 +58,21 @@ FrameRateMeter(const string &name) : TextNode(name) { //////////////////////////////////////////////////////////////////// FrameRateMeter:: ~FrameRateMeter() { - clear_layer(); + clear_window(); } //////////////////////////////////////////////////////////////////// -// Function: FrameRateMeter::setup_layer +// Function: FrameRateMeter::setup_window // Access: Published -// Description: Sets up the frame rate meter to create a layer to -// render itself into the indicated channel. +// Description: Sets up the frame rate meter to create a +// DisplayRegion to render itself into the indicated +// window. //////////////////////////////////////////////////////////////////// void FrameRateMeter:: -setup_layer(GraphicsChannel *channel) { - clear_layer(); +setup_window(GraphicsOutput *window) { + clear_window(); + + _window = window; _root = NodePath("frame_rate_root"); _root.attach_new_node(this); @@ -81,12 +83,9 @@ setup_layer(GraphicsChannel *channel) { _root.node()->set_attrib(dw, 1); _root.set_material_off(1); _root.set_two_sided(1, 1); - - // Make a layer on the channel to hold our display region. - _layer = channel->make_layer(frame_rate_meter_layer_sort); - // And create a display region that covers the entire window. - PT(DisplayRegion) dr = _layer->make_display_region(); + // Create a display region that covers the entire window. + _display_region = _window->make_display_region(); // Finally, we need a camera to associate with the display region. PT(Camera) camera = new Camera("frame_rate_camera"); @@ -104,25 +103,19 @@ setup_layer(GraphicsChannel *channel) { camera->set_lens(lens); camera->set_scene(_root); - dr->set_camera(camera_np); + _display_region->set_camera(camera_np); } //////////////////////////////////////////////////////////////////// -// Function: FrameRateMeter::clear_layer +// Function: FrameRateMeter::clear_window // Access: Published // Description: Undoes the effect of a previous call to -// setup_layer(). +// setup_window(). //////////////////////////////////////////////////////////////////// void FrameRateMeter:: -clear_layer() { - if (_layer != (GraphicsLayer *)NULL) { - GraphicsChannel *channel = _layer->get_channel(); - if (channel != (GraphicsChannel *)NULL) { - channel->remove_layer(_layer); - } - _layer = (GraphicsLayer *)NULL; - } - +clear_window() { + _window = (GraphicsOutput *)NULL; + _display_region = (DisplayRegion *)NULL; _root = NodePath(); } diff --git a/panda/src/grutil/frameRateMeter.h b/panda/src/grutil/frameRateMeter.h index 86ce7329eb..bb976f487a 100644 --- a/panda/src/grutil/frameRateMeter.h +++ b/panda/src/grutil/frameRateMeter.h @@ -23,7 +23,7 @@ #include "textNode.h" #include "nodePath.h" #include "graphicsOutput.h" -#include "graphicsLayer.h" +#include "displayRegion.h" #include "pointerTo.h" #include "pStatCollector.h" @@ -39,7 +39,7 @@ class ClockObject; // // It also has a special mode in which it may be // attached directly to a channel or window. If this is -// done, it creates a layer for itself and renders +// done, it creates a DisplayRegion for itself and renders // itself in the upper-right-hand corner. //////////////////////////////////////////////////////////////////// class EXPCL_PANDA FrameRateMeter : public TextNode { @@ -47,11 +47,10 @@ PUBLISHED: FrameRateMeter(const string &name); virtual ~FrameRateMeter(); - INLINE void setup_layer(GraphicsOutput *window); - void setup_layer(GraphicsChannel *channel); - void clear_layer(); + void setup_window(GraphicsOutput *window); + void clear_window(); - INLINE GraphicsLayer *get_layer() const; + INLINE GraphicsOutput *get_window() const; INLINE void set_update_interval(double update_interval); INLINE double get_update_interval() const; @@ -69,7 +68,8 @@ private: void do_update(); private: - PT(GraphicsLayer) _layer; + PT(GraphicsOutput) _window; + PT(DisplayRegion) _display_region; NodePath _root; double _update_interval; diff --git a/panda/src/grutil/multitexReducer.cxx b/panda/src/grutil/multitexReducer.cxx index bf3f7af7b6..0af07fb1f6 100644 --- a/panda/src/grutil/multitexReducer.cxx +++ b/panda/src/grutil/multitexReducer.cxx @@ -23,8 +23,6 @@ #include "renderState.h" #include "transformState.h" #include "graphicsOutput.h" -#include "graphicsChannel.h" -#include "graphicsLayer.h" #include "displayRegion.h" #include "camera.h" #include "orthographicLens.h" @@ -254,9 +252,7 @@ flatten(GraphicsOutput *window) { // Set up the offscreen buffer to render 0,0 to 1,1. This will be // the whole texture, but nothing outside the texture. - GraphicsChannel *chan = buffer->get_channel(0); - GraphicsLayer *layer = chan->make_layer(0); - DisplayRegion *dr = layer->make_display_region(); + DisplayRegion *dr = buffer->make_display_region(); PT(Camera) cam_node = new Camera("multitexCam"); PT(Lens) lens = new OrthographicLens(); lens->set_film_size(1.0f, 1.0f);