Render SkiaWindow with scale factor

This commit is contained in:
David Capello 2015-03-25 17:27:43 -03:00
parent 7129873cd1
commit 6e76d50864
3 changed files with 14 additions and 12 deletions

View File

@ -9,9 +9,9 @@ namespace she {
class SkiaDisplay : public Display {
public:
SkiaDisplay(int width, int height, int scale)
: m_window(&m_queue, this)
, m_scale(scale) {
: m_window(&m_queue, this) {
m_surface.create(width, height);
m_window.setScale(scale);
m_window.setVisible(true);
}
@ -38,11 +38,11 @@ public:
}
void setScale(int scale) override {
m_scale = scale;
m_window.setScale(scale);
}
int scale() const override {
return m_scale;
return m_window.scale();
}
// Returns the main surface to draw into this display.
@ -98,7 +98,6 @@ private:
SkiaEventQueue m_queue;
SkiaWindow m_window;
SkiaSurface m_surface;
int m_scale;
};
} // namespace she

View File

@ -34,15 +34,14 @@ public:
ASSERT(bitmap.width() * bitmap.bytesPerPixel() == bitmap.rowBytes());
bitmap.lockPixels();
int ret = SetDIBitsToDevice(hdc,
0, 0,
bitmap.width(), bitmap.height(),
0, 0,
0, bitmap.height(),
int ret = StretchDIBits(hdc,
0, 0, bitmap.width()*scale(), bitmap.height()*scale(),
0, 0, bitmap.width(), bitmap.height(),
bitmap.getPixels(),
&bmi,
DIB_RGB_COLORS);
&bmi, DIB_RGB_COLORS, SRCCOPY);
(void)ret;
bitmap.unlockPixels();
}

View File

@ -310,6 +310,10 @@ static KeyScancode vkToScancode(int vk) {
static_cast<T*>(this)->queueEventImpl(ev);
}
int scale() const {
return m_scale;
}
void setScale(int scale) {
m_scale = scale;
}