Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
MipMapDescription.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 //
4 // Copyright (c) 2010-2012 SharpDX - Alexandre Mutel
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 // THE SOFTWARE.
23 
24 using System;
25 
26 namespace SiliconStudio.Paradox.Graphics
27 {
28  /// <summary>
29  /// Describes a mipmap.
30  /// </summary>
31  public class MipMapDescription : IEquatable<MipMapDescription>
32  {
33  /// <summary>
34  /// Initializes a new instance of the <see cref="MipMapDescription" /> class.
35  /// </summary>
36  /// <param name="width">The width.</param>
37  /// <param name="height">The height.</param>
38  /// <param name="depth">The depth.</param>
39  /// <param name="rowStride">The row stride.</param>
40  /// <param name="depthStride">The depth stride.</param>
41  public MipMapDescription(int width, int height, int depth, int rowStride, int depthStride, int widthPacked, int heightPacked)
42  {
43  Width = width;
44  Height = height;
45  Depth = depth;
46  RowStride = rowStride;
47  DepthStride = depthStride;
48  MipmapSize = depthStride * depth;
49  WidthPacked = widthPacked;
50  HeightPacked = heightPacked;
51  }
52 
53  /// <summary>
54  /// Width of this mipmap.
55  /// </summary>
56  public readonly int Width;
57 
58  /// <summary>
59  /// Height of this mipmap.
60  /// </summary>
61  public readonly int Height;
62 
63  /// <summary>
64  /// Width of this mipmap.
65  /// </summary>
66  public readonly int WidthPacked;
67 
68  /// <summary>
69  /// Height of this mipmap.
70  /// </summary>
71  public readonly int HeightPacked;
72 
73  /// <summary>
74  /// Depth of this mipmap.
75  /// </summary>
76  public readonly int Depth;
77 
78  /// <summary>
79  /// RowStride of this mipmap (number of bytes per row).
80  /// </summary>
81  public readonly int RowStride;
82 
83  /// <summary>
84  /// DepthStride of this mipmap (number of bytes per depth slice).
85  /// </summary>
86  public readonly int DepthStride;
87 
88  /// <summary>
89  /// Size in bytes of this whole mipmap.
90  /// </summary>
91  public readonly int MipmapSize;
92 
93  public bool Equals(MipMapDescription other)
94  {
95  if (ReferenceEquals(null, other))
96  return false;
97  if (ReferenceEquals(this, other))
98  return true;
99  return this.Width == other.Width && this.Height == other.Height && this.WidthPacked == other.WidthPacked && this.HeightPacked == other.HeightPacked && this.Depth == other.Depth && this.RowStride == other.RowStride && this.MipmapSize == other.MipmapSize && this.DepthStride == other.DepthStride;
100  }
101 
102  public override bool Equals(object obj)
103  {
104  if (ReferenceEquals(null, obj))
105  return false;
106  if (ReferenceEquals(this, obj))
107  return true;
108  if (obj.GetType() != this.GetType())
109  return false;
110  return Equals((MipMapDescription)obj);
111  }
112 
113  public override int GetHashCode()
114  {
115  unchecked
116  {
117  int hashCode = this.Width;
118  hashCode = (hashCode * 397) ^ this.Height;
119  hashCode = (hashCode * 397) ^ this.WidthPacked;
120  hashCode = (hashCode * 397) ^ this.HeightPacked;
121  hashCode = (hashCode * 397) ^ this.Depth;
122  hashCode = (hashCode * 397) ^ this.RowStride;
123  hashCode = (hashCode * 397) ^ this.MipmapSize;
124  hashCode = (hashCode * 397) ^ this.DepthStride;
125  return hashCode;
126  }
127  }
128 
129  /// <summary>
130  /// Implements the ==.
131  /// </summary>
132  /// <param name="left">The left.</param>
133  /// <param name="right">The right.</param>
134  /// <returns>The result of the operator.</returns>
135  public static bool operator ==(MipMapDescription left, MipMapDescription right)
136  {
137  return Equals(left, right);
138  }
139 
140  /// <summary>
141  /// Implements the !=.
142  /// </summary>
143  /// <param name="left">The left.</param>
144  /// <param name="right">The right.</param>
145  /// <returns>The result of the operator.</returns>
146  public static bool operator !=(MipMapDescription left, MipMapDescription right)
147  {
148  return !Equals(left, right);
149  }
150  }
151 }
readonly int Height
Height of this mipmap.
readonly int Depth
Depth of this mipmap.
readonly int WidthPacked
Width of this mipmap.
readonly int MipmapSize
Size in bytes of this whole mipmap.
readonly int DepthStride
DepthStride of this mipmap (number of bytes per depth slice).
MipMapDescription(int width, int height, int depth, int rowStride, int depthStride, int widthPacked, int heightPacked)
Initializes a new instance of the MipMapDescription class.
readonly int RowStride
RowStride of this mipmap (number of bytes per row).
readonly int Width
Width of this mipmap.
readonly int HeightPacked
Height of this mipmap.