18 #ifndef EQFABRIC_PIXELVIEWPORT_H 19 #define EQFABRIC_PIXELVIEWPORT_H 21 #include <eq/fabric/pixel.h> 22 #include <eq/fabric/viewport.h> 23 #include <eq/fabric/zoom.h> 25 #include <lunchbox/debug.h> 84 bool isValid()
const {
return (w >= 0 && h >= 0); }
90 bool hasArea()
const {
return (w > 0 && h > 0); }
92 uint32_t
getArea()
const {
return w * h; }
97 bool isInside(
const int32_t pX,
const int32_t pY)
const 99 if (pX < x || pY < y || pX > (x + w) || pY > (y + h))
111 const int32_t xEnd = x + int32_t((vp.
x + vp.
w) * w);
112 const int32_t yEnd = y + int32_t((vp.
y + vp.
h) * h);
114 x += int32_t(w * vp.
x);
115 y += int32_t(h * vp.
y);
126 int32_t newWidth = w / pixel.w;
130 if (w - (newWidth * pixel.w) != 0)
137 int32_t newHeight = h / pixel.h;
141 if (h - (newHeight * pixel.h) != 0)
154 x =
static_cast<int32_t
>(x * zoom.x() + .5f);
155 y =
static_cast<int32_t
>(y * zoom.y() + .5f);
156 w =
static_cast<int32_t
>(w * zoom.x() + .5f);
157 h =
static_cast<int32_t
>(h * zoom.y() + .5f);
171 return Zoom(std::numeric_limits<float>::max(),
172 std::numeric_limits<float>::max());
174 return Zoom(w / static_cast<float>(rhs.w),
175 h / static_cast<float>(rhs.h));
194 x = int32_t(dims[0]);
195 w = int32_t(dims[1]);
196 y = int32_t(dims[2]);
197 h = int32_t(dims[3]);
216 return Viewport(static_cast<float>(x),
static_cast<float>(y), 0.f,
219 return Viewport((x - rhs.x) / static_cast<float>(rhs.w),
220 (y - rhs.y) / static_cast<float>(rhs.h),
221 (w) / static_cast<float>(rhs.w),
222 (h) / static_cast<float>(rhs.h));
252 return (x == rhs.x && y == rhs.y && w == rhs.w && h == rhs.h);
261 return (x != rhs.x || y != rhs.y || w != rhs.w || h != rhs.h);
270 if (*
this == rhs || !rhs.
isValid())
281 const int32_t sEx = x + w;
282 const int32_t sEy = y + h;
283 const int32_t dEx = rhs.x + rhs.w;
284 const int32_t dEy = rhs.y + rhs.h;
286 x = LB_MIN(x, rhs.x);
287 y = LB_MIN(y, rhs.y);
288 w = LB_MAX(sEx, dEx) - x;
289 h = LB_MAX(sEy, dEy) - y;
314 const int32_t sEx = x + w;
315 const int32_t sEy = y + h;
316 const int32_t dEx = rhs.x + rhs.w;
317 const int32_t dEy = rhs.y + rhs.h;
319 x = LB_MAX(x, rhs.x);
320 y = LB_MAX(y, rhs.y);
321 w = LB_MIN(sEx, dEx) - x;
322 h = LB_MIN(sEy, dEy) - y;
335 os <<
"[ " << pvp.x <<
" " << pvp.y <<
" " << pvp.w <<
" " << pvp.h <<
" ]";
341 #endif // EQFABRIC_PIXELVIEWPORT_H A zoom specification with methods for manipulation.
bool operator!=(const PixelViewport &rhs) const
void invalidate()
Invalidate the pixel viewport.
const Zoom getZoom(const PixelViewport &rhs) const
PixelViewport(const int32_t pvp[4])
Construct a new pixel viewport with default values.
A fractional viewport with methods for manipulation.
const PixelViewport & operator-=(const Vector2i &offset)
void convertToPlugin(uint64_t dims[4]) const
Convert into a lunchbox::Plugin usable format.
PixelViewport(const int32_t x_, const int32_t y_, const int32_t w_, const int32_t h_)
Construct a new pixel viewport with default values.
void convertFromPlugin(const uint64_t dims[4])
Convert from a lunchbox::Plugin format.
void apply(const Zoom &zoom)
Apply a zoom to this pixel viewport.
const PixelViewport operator+(const Vector2i &offset) const
PixelViewport & apply(const Viewport &vp)
Apply a fractional viewport to this pixel viewport.
void intersect(const PixelViewport &rhs)
Create the intersection of the two pixel viewports.
PixelViewport()
Construct a new, invalid pixel viewport.
Holds a pixel decomposition specification with methods for manipulation.
The Equalizer client library.
static EQFABRIC_API const Viewport FULL
A full viewport.
std::ostream & operator<<(std::ostream &os, const AxisEvent &event)
Print the axis event to the given output stream.
bool operator==(const PixelViewport &rhs) const
void unapply(const Pixel &pixel)
Perform the inverse operation of applying a pixel decomposition to this pixel viewport.
void apply(const Pixel &pixel)
Apply a pixel decomposition to this pixel viewport.
bool isInside(const int32_t pX, const int32_t pY) const
Holds a 2D pixel viewport with methods for manipulation.
PixelViewport & merge(const PixelViewport &rhs)
Create a pixel viewport that includes both viewports (union).
static EQFABRIC_API const Zoom NONE
The zoom NONE (1,1) value.