Move scale factor-related wxBitmap functions out of line
This will make it possible to change them later without breaking ABI, which is probably worth paying the price of a function call (assuming the compiler could de-virtualize this call and inline it before). No real changes.
This commit is contained in:
@@ -177,8 +177,7 @@ public:
|
||||
|
||||
virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH) = 0;
|
||||
virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) = 0;
|
||||
virtual bool CreateScaled(int w, int h, int d, double logicalScale)
|
||||
{ return Create(wxRound(w*logicalScale), wxRound(h*logicalScale), d); }
|
||||
virtual bool CreateScaled(int w, int h, int d, double logicalScale);
|
||||
|
||||
virtual int GetHeight() const = 0;
|
||||
virtual int GetWidth() const = 0;
|
||||
@@ -188,12 +187,11 @@ public:
|
||||
{ return wxSize(GetWidth(), GetHeight()); }
|
||||
|
||||
// support for scaled bitmaps
|
||||
virtual void SetScaleFactor(double WXUNUSED(scale)) { }
|
||||
virtual double GetScaleFactor() const { return 1.0; }
|
||||
virtual double GetScaledWidth() const { return GetWidth() / GetScaleFactor(); }
|
||||
virtual double GetScaledHeight() const { return GetHeight() / GetScaleFactor(); }
|
||||
virtual wxSize GetScaledSize() const
|
||||
{ return wxSize(wxRound(GetScaledWidth()), wxRound(GetScaledHeight())); }
|
||||
virtual void SetScaleFactor(double scale);
|
||||
virtual double GetScaleFactor() const;
|
||||
virtual double GetScaledWidth() const;
|
||||
virtual double GetScaledHeight() const;
|
||||
virtual wxSize GetScaledSize() const;
|
||||
|
||||
#if wxUSE_IMAGE
|
||||
virtual wxImage ConvertToImage() const = 0;
|
||||
|
@@ -158,8 +158,7 @@ public:
|
||||
|
||||
virtual bool Create(int width, int height, const wxDC& dc);
|
||||
virtual bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1);
|
||||
virtual bool CreateScaled(int w, int h, int d, double logicalScale)
|
||||
{ return Create(wxRound(w*logicalScale), wxRound(h*logicalScale), d); }
|
||||
virtual bool CreateScaled(int w, int h, int d, double logicalScale);
|
||||
|
||||
virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
|
||||
virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const;
|
||||
@@ -185,12 +184,12 @@ public:
|
||||
void UseAlpha(bool use = true);
|
||||
void ResetAlpha() { UseAlpha(false); }
|
||||
|
||||
// support for scaled bitmaps
|
||||
virtual void SetScaleFactor(double WXUNUSED(scale)) { }
|
||||
virtual double GetScaleFactor() const { return 1.0; }
|
||||
virtual double GetScaledWidth() const { return GetWidth(); }
|
||||
virtual double GetScaledHeight() const { return GetHeight(); }
|
||||
virtual wxSize GetScaledSize() const { return GetSize(); }
|
||||
// provide stabs of scaled bitmaps functions, they are trivial here
|
||||
virtual void SetScaleFactor(double scale);
|
||||
virtual double GetScaleFactor() const;
|
||||
virtual double GetScaledWidth() const;
|
||||
virtual double GetScaledHeight() const;
|
||||
virtual wxSize GetScaledSize() const;
|
||||
|
||||
// implementation only from now on
|
||||
// -------------------------------
|
||||
|
@@ -196,6 +196,39 @@ public:
|
||||
|
||||
wxIMPLEMENT_DYNAMIC_CLASS(wxBitmapBaseModule, wxModule);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Trivial implementations of scale-factor related functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxBitmapBase::CreateScaled(int w, int h, int d, double logicalScale)
|
||||
{
|
||||
return Create(wxRound(w*logicalScale), wxRound(h*logicalScale), d);
|
||||
}
|
||||
|
||||
void wxBitmapBase::SetScaleFactor(double WXUNUSED(scale))
|
||||
{
|
||||
}
|
||||
|
||||
double wxBitmapBase::GetScaleFactor() const
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
double wxBitmapBase::GetScaledWidth() const
|
||||
{
|
||||
return GetWidth() / GetScaleFactor();
|
||||
}
|
||||
|
||||
double wxBitmapBase::GetScaledHeight() const
|
||||
{
|
||||
return GetHeight() / GetScaleFactor();
|
||||
}
|
||||
|
||||
wxSize wxBitmapBase::GetScaledSize() const
|
||||
{
|
||||
return wxSize(wxRound(GetScaledWidth()), wxRound(GetScaledHeight()));
|
||||
}
|
||||
|
||||
#endif // wxUSE_BITMAP_BASE
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -745,6 +745,11 @@ bool wxBitmap::Create(int width, int height, const wxDC& dc)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxBitmap::CreateScaled(int w, int h, int d, double logicalScale)
|
||||
{
|
||||
return Create(wxRound(w*logicalScale), wxRound(h*logicalScale), d);
|
||||
}
|
||||
|
||||
bool wxBitmap::DoCreate(int w, int h, int d, WXHDC hdc)
|
||||
{
|
||||
UnRef();
|
||||
@@ -1357,6 +1362,39 @@ bool wxBitmap::InitFromHBITMAP(WXHBITMAP bmp, int width, int height, int depth)
|
||||
return IsOk();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// scale factor-related functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Note: currently we don't use scale factor at all and don't even store it
|
||||
// because this seems useless, but we define these functions out of line here
|
||||
// and not inline in the header to make it possible to change this later
|
||||
// without breaking ABI if necessary.
|
||||
|
||||
void wxBitmap::SetScaleFactor(double WXUNUSED(scale))
|
||||
{
|
||||
}
|
||||
|
||||
double wxBitmap::GetScaleFactor() const
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
double wxBitmap::GetScaledWidth() const
|
||||
{
|
||||
return GetWidth();
|
||||
}
|
||||
|
||||
double wxBitmap::GetScaledHeight() const
|
||||
{
|
||||
return GetHeight();
|
||||
}
|
||||
|
||||
wxSize wxBitmap::GetScaledSize() const
|
||||
{
|
||||
return GetSize();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// raw bitmap access support
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user