2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
4 * This file is part of CasparCG (www.casparcg.com).
6 * CasparCG is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * CasparCG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
19 * Author: Niklas P Andersson, niklas.p.andersson@svt.se
23 #include "../StdAfx.h"
27 namespace caspar { namespace core {
29 frame_geometry::coord::coord(double vertex_x, double vertex_y, double texture_x, double texture_y)
32 , texture_x(texture_x)
33 , texture_y(texture_y)
37 bool frame_geometry::coord::operator==(const frame_geometry::coord& other) const
39 return vertex_x == other.vertex_x
40 && vertex_y == other.vertex_y
41 && texture_x == other.texture_x
42 && texture_y == other.texture_y
43 && texture_r == other.texture_r
44 && texture_q == other.texture_q;
47 struct frame_geometry::impl
49 impl(frame_geometry::geometry_type type, std::vector<coord> data)
52 if (type == geometry_type::quad && data.size() != 4)
53 CASPAR_THROW_EXCEPTION(invalid_argument() << msg_info("The number of coordinates needs to be 4"));
55 if (type == geometry_type::quad_list)
57 if (data.size() % 4 != 0)
58 CASPAR_THROW_EXCEPTION(invalid_argument() << msg_info("The number of coordinates needs to be a multiple of 4"));
61 data_ = std::move(data);
64 frame_geometry::geometry_type type_;
65 std::vector<coord> data_;
68 frame_geometry::frame_geometry(geometry_type type, std::vector<coord> data) : impl_(new impl(type, std::move(data))) {}
70 frame_geometry::geometry_type frame_geometry::type() const { return impl_->type_; }
71 const std::vector<frame_geometry::coord>& frame_geometry::data() const
76 const frame_geometry& frame_geometry::get_default()
78 static std::vector<frame_geometry::coord> data = {
80 { 0.0, 0.0, 0.0, 0.0 }, // upper left
81 { 1.0, 0.0, 1.0, 0.0 }, // upper right
82 { 1.0, 1.0, 1.0, 1.0 }, // lower right
83 { 0.0, 1.0, 0.0, 1.0 } // lower left
85 static const frame_geometry g(frame_geometry::geometry_type::quad, data);