Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 1 | /* |
Stephen Hines | 411f599 | 2012-07-10 15:38:09 -0700 | [diff] [blame] | 2 | * Copyright (C) 2011-2012 The Android Open Source Project |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ANDROID_RS_MATRIX_2x2_H |
| 18 | #define ANDROID_RS_MATRIX_2x2_H |
| 19 | |
| 20 | #include "rsType.h" |
| 21 | |
| 22 | |
| 23 | // --------------------------------------------------------------------------- |
| 24 | namespace android { |
| 25 | namespace renderscript { |
| 26 | |
| 27 | struct Matrix2x2 : public rs_matrix2x2 { |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 28 | inline float get(uint32_t col, uint32_t row) const { |
| 29 | return m[col*2 + row]; |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 30 | } |
| 31 | |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 32 | inline void set(uint32_t col, uint32_t row, float v) { |
| 33 | m[col*2 + row] = v; |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | void loadIdentity(); |
| 37 | void load(const float *); |
| 38 | void load(const rs_matrix2x2 *); |
| 39 | |
| 40 | void loadMultiply(const rs_matrix2x2 *lhs, const rs_matrix2x2 *rhs); |
| 41 | |
| 42 | void transpose(); |
| 43 | |
| 44 | void multiply(const rs_matrix2x2 *rhs) { |
Jean-Luc Brouillet | 1bb2eed | 2014-09-05 17:44:48 -0700 | [diff] [blame] | 45 | loadMultiply(this, rhs); |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 46 | } |
| 47 | }; |
| 48 | |
Rahul Chaudhry | 7974fc0 | 2017-02-09 12:33:28 -0800 | [diff] [blame] | 49 | } // namespace renderscript |
| 50 | } // namespace android |
Jason Sams | 87fe59a | 2011-04-20 15:09:01 -0700 | [diff] [blame] | 51 | |
Stephen Hines | 411f599 | 2012-07-10 15:38:09 -0700 | [diff] [blame] | 52 | #endif // ANDROID_RS_MATRIX_2x2_H |