From e732297cfb164d6e54175c51e9a60f438eceb01c Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 2 Oct 2015 12:12:37 -0300 Subject: [PATCH] Update Skia port to latest Skia version --- src/she/skia/gl_context_wgl.h | 17 +++++++++++------ src/she/skia/skia_surface.h | 22 ++++++++++++++-------- src/she/skia/skia_system.h | 2 +- src/she/skia/skia_window_win.cpp | 2 +- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/she/skia/gl_context_wgl.h b/src/she/skia/gl_context_wgl.h index dd5f8bd2a..7c36bb24d 100644 --- a/src/she/skia/gl_context_wgl.h +++ b/src/she/skia/gl_context_wgl.h @@ -48,14 +48,15 @@ public: wglMakeCurrent(hdc, m_glrc); - fGL.reset(GrGLCreateNativeInterface()); - if (!fGL) { + const GrGLInterface* gl = GrGLCreateNativeInterface(); + init(gl); + if (!gl) { ReleaseDC(m_hwnd, hdc); destroy(); return; } - if (!fGL->validate()) { + if (!gl->validate()) { ReleaseDC(m_hwnd, hdc); destroy(); return; @@ -68,18 +69,22 @@ public: destroy(); } - void makeCurrent() const override { + void onPlatformMakeCurrent() const override { HDC hdc = GetDC(m_hwnd); wglMakeCurrent(hdc, m_glrc); ReleaseDC(m_hwnd, hdc); } - void swapBuffers() const override { + void onPlatformSwapBuffers() const override { HDC hdc = GetDC(m_hwnd); SwapBuffers(hdc); ReleaseDC(m_hwnd, hdc); } + GrGLFuncPtr onPlatformGetProcAddress(const char* name) const override { + return reinterpret_cast(wglGetProcAddress(name)); + } + int getStencilBits() { HDC hdc = GetDC(m_hwnd); int pixelFormat = GetPixelFormat(hdc); @@ -95,7 +100,7 @@ public: private: void destroy() { - fGL.reset(nullptr); + teardown(); if (m_glrc) { wglMakeCurrent(nullptr, nullptr); diff --git a/src/she/skia/skia_surface.h b/src/she/skia/skia_surface.h index 062464384..a09ee9995 100644 --- a/src/she/skia/skia_surface.h +++ b/src/she/skia/skia_surface.h @@ -136,7 +136,8 @@ public: SkCanvas canvas(result); SkRect srcRect = SkRect::Make(SkIRect::MakeXYWH(0, 0, width(), height())); SkRect dstRect = SkRect::Make(SkIRect::MakeXYWH(0, 0, result.width(), result.height())); - canvas.drawBitmapRectToRect(m_bitmap, &srcRect, dstRect, &paint); + canvas.drawBitmapRect(m_bitmap, srcRect, dstRect, &paint, + SkCanvas::kStrict_SrcRectConstraint); swapBitmap(result); } @@ -307,7 +308,9 @@ public: SkRect srcRect = SkRect::Make(SkIRect::MakeXYWH(srcx, srcy, width, height)); SkRect dstRect = SkRect::Make(SkIRect::MakeXYWH(dstx, dsty, width, height)); - ((SkiaSurface*)dest)->m_canvas->drawBitmapRectToRect(m_bitmap, &srcRect, dstRect, &paint); + ((SkiaSurface*)dest)->m_canvas->drawBitmapRect( + m_bitmap, srcRect, dstRect, &paint, + SkCanvas::kStrict_SrcRectConstraint); } } @@ -363,8 +366,9 @@ public: SkPaint paint; paint.setXfermodeMode(SkXfermode::kSrc_Mode); - m_canvas->drawBitmapRectToRect( - ((SkiaSurface*)src)->m_bitmap, &srcRect, dstRect, &paint); + m_canvas->drawBitmapRect( + ((SkiaSurface*)src)->m_bitmap, srcRect, dstRect, &paint, + SkCanvas::kStrict_SrcRectConstraint); } void drawRgbaSurface(const LockedSurface* src, int dstx, int dsty) override { @@ -381,8 +385,9 @@ public: SkPaint paint; paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); - m_canvas->drawBitmapRectToRect( - ((SkiaSurface*)src)->m_bitmap, &srcRect, dstRect, &paint); + m_canvas->drawBitmapRect( + ((SkiaSurface*)src)->m_bitmap, srcRect, dstRect, &paint, + SkCanvas::kStrict_SrcRectConstraint); } void drawColoredRgbaSurface(const LockedSurface* src, gfx::Color fg, gfx::Color bg, const gfx::Clip& clipbase) override { @@ -407,9 +412,10 @@ public: SkColorFilter::CreateModeFilter(to_skia(fg), SkXfermode::kSrcIn_Mode)); paint.setColorFilter(colorFilter); - m_canvas->drawBitmapRectToRect( + m_canvas->drawBitmapRect( ((SkiaSurface*)src)->m_bitmap, - &srcRect, dstRect, &paint); + srcRect, dstRect, &paint, + SkCanvas::kStrict_SrcRectConstraint); } void drawChar(Font* font, gfx::Color fg, gfx::Color bg, int x, int y, int chr) override { diff --git a/src/she/skia/skia_system.h b/src/she/skia/skia_system.h index dbe45b9fb..71b9e9ed7 100644 --- a/src/she/skia/skia_system.h +++ b/src/she/skia/skia_system.h @@ -82,7 +82,7 @@ public: Surface* loadSurface(const char* filename) override { base::FileHandle fp(base::open_file_with_exception(filename, "rb")); - SkAutoTDelete stream(SkNEW_ARGS(SkFILEStream, (fp.get(), SkFILEStream::kCallerRetains_Ownership))); + SkAutoTDelete stream(new SkFILEStream(fp.get(), SkFILEStream::kCallerRetains_Ownership)); SkAutoTDelete decoder(SkImageDecoder::Factory(stream)); if (decoder) { diff --git a/src/she/skia/skia_window_win.cpp b/src/she/skia/skia_window_win.cpp index 260d1845c..41f17972e 100644 --- a/src/she/skia/skia_window_win.cpp +++ b/src/she/skia/skia_window_win.cpp @@ -122,7 +122,7 @@ void SkiaWindow::paintHDC(HDC hdc) bool SkiaWindow::attachGL() { if (!m_glCtx) { - GLContextWGL* wglCtx = SkNEW_ARGS(GLContextWGL, (handle(), kGLES_GrGLStandard)); + GLContextWGL* wglCtx = new GLContextWGL(handle(), kGLES_GrGLStandard); m_stencilBits = wglCtx->getStencilBits(); m_sampleCount = wglCtx->getSampleCount();