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

View File

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

View File

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