OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Pattern Class Reference

#include <C4Draw.h>

Public Member Functions

C4Patternoperator= (const C4Pattern &)
 
const C4SurfacegetSurface () const
 
DWORD PatternClr (unsigned int iX, unsigned int iY) const
 
bool Set (class C4Surface *sfcSource, int iZoom=0)
 
void SetZoom (int iZoom)
 
void Clear ()
 
 C4Pattern ()
 
 ~C4Pattern ()
 

Detailed Description

Definition at line 38 of file C4Draw.h.

Constructor & Destructor Documentation

C4Pattern::C4Pattern ( )

Definition at line 141 of file C4Draw.cpp.

142 {
143  // disable
144  sfcPattern32=nullptr;
145  CachedPattern = 0;
146  Zoom=0;
147 }
C4Pattern::~C4Pattern ( )
inline

Definition at line 55 of file C4Draw.h.

References Clear().

55 { Clear(); } // dtor
void Clear()
Definition: C4Draw.cpp:149

Here is the call graph for this function:

Member Function Documentation

void C4Pattern::Clear ( )

Definition at line 149 of file C4Draw.cpp.

References C4Surface::Unlock().

Referenced by C4TexMapEntry::Clear(), Set(), and ~C4Pattern().

150 {
151  // pattern assigned
152  if (sfcPattern32)
153  {
154  // unlock it
155  sfcPattern32->Unlock();
156  // clear field
157  sfcPattern32=nullptr;
158  }
159  delete[] CachedPattern; CachedPattern = 0;
160 }
bool Unlock()
Definition: C4Surface.cpp:474

Here is the call graph for this function:

Here is the caller graph for this function:

const C4Surface* C4Pattern::getSurface ( ) const
inline

Definition at line 49 of file C4Draw.h.

49 { return sfcPattern32; }
C4Pattern & C4Pattern::operator= ( const C4Pattern nPattern)

Definition at line 97 of file C4Draw.cpp.

References C4Surface::Hgt, C4Surface::Lock(), and C4Surface::Wdt.

98 {
99  sfcPattern32 = nPattern.sfcPattern32;
100  if (sfcPattern32) sfcPattern32->Lock();
101  delete [] CachedPattern;
102  if (nPattern.CachedPattern)
103  {
104  CachedPattern = new uint32_t[sfcPattern32->Wdt * sfcPattern32->Hgt];
105  memcpy(CachedPattern, nPattern.CachedPattern, sfcPattern32->Wdt * sfcPattern32->Hgt * 4);
106  }
107  else
108  {
109  CachedPattern = 0;
110  }
111  Wdt = nPattern.Wdt;
112  Hgt = nPattern.Hgt;
113  Zoom = nPattern.Zoom;
114  return *this;
115 }
int Wdt
Definition: C4Surface.h:67
bool Lock()
Definition: C4Surface.cpp:463
int Hgt
Definition: C4Surface.h:67

Here is the call graph for this function:

DWORD C4Pattern::PatternClr ( unsigned int  iX,
unsigned int  iY 
) const

Definition at line 162 of file C4Draw.cpp.

Referenced by C4Draw::DrawPatternedCircle(), C4Landscape::P::Mat2Pal(), and C4TextureMap::StoreMapPalette().

163 {
164  if (!CachedPattern) return 0;
165  // wrap position
166  iX %= Wdt; iY %= Hgt;
167  return CachedPattern[iY * Wdt + iX];
168 }

Here is the caller graph for this function:

bool C4Pattern::Set ( class C4Surface sfcSource,
int  iZoom = 0 
)

Definition at line 117 of file C4Draw.cpp.

References Clear(), C4Surface::GetPixDw(), C4Surface::Hgt, C4Surface::Lock(), and C4Surface::Wdt.

Referenced by C4TexMapEntry::Init().

118 {
119  // Safety
120  if (!sfcSource) return false;
121  // Clear existing pattern
122  Clear();
123  // new style: simply store pattern for modulation or shifting, which will be decided upon use
124  sfcPattern32=sfcSource;
125  sfcPattern32->Lock();
126  Wdt = sfcPattern32->Wdt;
127  Hgt = sfcPattern32->Hgt;
128  // set zoom
129  Zoom=iZoom;
130  // set flags
131  CachedPattern = new uint32_t[Wdt * Hgt];
132  if (!CachedPattern) return false;
133  for (int y = 0; y < Hgt; ++y)
134  for (int x = 0; x < Wdt; ++x)
135  {
136  CachedPattern[y * Wdt + x] = sfcPattern32->GetPixDw(x, y, false);
137  }
138  return true;
139 }
int Wdt
Definition: C4Surface.h:67
bool Lock()
Definition: C4Surface.cpp:463
int Hgt
Definition: C4Surface.h:67
void Clear()
Definition: C4Draw.cpp:149
DWORD GetPixDw(int iX, int iY, bool fApplyModulation)
Definition: C4Surface.cpp:501

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Pattern::SetZoom ( int  iZoom)
inline

Definition at line 52 of file C4Draw.h.

52 { Zoom = iZoom; }

The documentation for this class was generated from the following files: