diff options
author | Marius Renn <renn@google.com> | 2012-03-27 10:44:45 -0700 |
---|---|---|
committer | Marius Renn <renn@google.com> | 2012-03-27 10:44:45 -0700 |
commit | 65953da4636fbf5f0a24b8f5f2b5fa7d76ff13d9 (patch) | |
tree | bfb7ea73b90f23cd135b68b090a72ef8b947ee90 /media/mca/filterpacks/native/base/geometry.h | |
parent | 80e4ee46008d2817dc0496e0cf8c9470c6851755 (diff) | |
download | frameworks_base-65953da4636fbf5f0a24b8f5f2b5fa7d76ff13d9.zip frameworks_base-65953da4636fbf5f0a24b8f5f2b5fa7d76ff13d9.tar.gz frameworks_base-65953da4636fbf5f0a24b8f5f2b5fa7d76ff13d9.tar.bz2 |
Multi-Project Commit: Move of filterfw out of system/media (2 of 7)
This is part of the multi-project commit to move the filter-framework
from system/media/mca to frameworks/base/media/mca.
Note that the filter-framework will soon be replaced with a refactored
version currently under API review (also to go under frameworks/base).
This move is done now to unblock the PDK efforts.
Change-Id: I9f42be5a12a9e8157512be11f04e38e4548970be
Diffstat (limited to 'media/mca/filterpacks/native/base/geometry.h')
-rw-r--r-- | media/mca/filterpacks/native/base/geometry.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/media/mca/filterpacks/native/base/geometry.h b/media/mca/filterpacks/native/base/geometry.h new file mode 100644 index 0000000..40a9343 --- /dev/null +++ b/media/mca/filterpacks/native/base/geometry.h @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_FILTERFW_FILTERPACKS_BASE_GEOMETRY_H +#define ANDROID_FILTERFW_FILTERPACKS_BASE_GEOMETRY_H + +#include <vector> + +namespace android { +namespace filterfw { + +// This is an initial implementation of some geometrical structures. This is +// likely to grow and become more sophisticated in the future. + +class Point { + public: + Point() : x_(0.0f), y_(0.0f) {} + Point(float x, float y) : x_(x), y_(y) {} + + float x() const { return x_; } + float y() const { return y_; } + + float Length() const; + bool ScaleTo(float new_length); + static float Distance(const Point& p0, const Point& p1); + + // Add more of these as needed: + Point operator+(const Point& other) const; + Point operator-(const Point& other) const; + Point operator*(float factor) const; + + void Rotate90Clockwise(); + + private: + float x_, y_; +}; + +class Quad { + public: + Quad() : points_(4) {} + virtual ~Quad() {} + + Quad(const Point& p0, const Point& p1, const Point& p2, const Point& p3) + : points_(4) { + points_[0] = p0; + points_[1] = p1; + points_[2] = p2; + points_[3] = p3; + } + + const std::vector<Point>& points() const { return points_; } + const Point& point(int ix) const; + + protected: + std::vector<Point> points_; +}; + +class SlantedRect : public Quad { + public: + SlantedRect() : width_(0.0f), height_(0.0f) {} + virtual ~SlantedRect() {} + + bool FromCenterAxisAndLengths(const Point& center, + const Point& vert_axis, + const Point& lenghts); + + float width() const { return width_; } + float height() const { return height_; } + + private: + float width_; + float height_; +}; + +struct Rect { + float x, y, width, height; + + Rect() { + x = y = 0.0f; + width = height = 1.0f; + } + + Rect(float x, float y, float width, float height) { + this->x = x; + this->y = y; + this->width = width; + this->height = height; + } + + bool ExpandToAspectRatio(float ratio); + bool ExpandToMinLength(float length); + bool ScaleWithLengthLimit(float factor, float max_length); +}; + +} // namespace filterfw +} // namespace android + +#endif // ANDROID_FILTERFW_FILTERPACKS_BASE_GEOMETRY_H |