summaryrefslogtreecommitdiff
path: root/vcl/skia/win/gdiimpl.cxx
blob: fa173226b871ea6de00d084f222e29a97e7ee244 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <skia/win/gdiimpl.hxx>

#include <tools/sk_app/win/WindowContextFactory_win.h>
#include <tools/sk_app/WindowContext.h>

WinSkiaSalGraphicsImpl::WinSkiaSalGraphicsImpl(WinSalGraphics& rGraphics,
                                               SalGeometryProvider* mpProvider)
    : SkiaSalGraphicsImpl(rGraphics, mpProvider)
    , mWinParent(rGraphics)
{
}

void WinSkiaSalGraphicsImpl::Init()
{
#if 0 // TODO
    if (!IsOffscreen() && mpContext.is() && mpContext->isInitialized())
    {
        const GLWinWindow& rGLWindow = static_cast<const GLWinWindow&>(mpContext->getOpenGLWindow());
        if (rGLWindow.hWnd != mrWinParent.mhWnd || rGLWindow.hDC == mrWinParent.mhLocalDC)
        {
            // This can legitimately happen, SalFrame keeps 2x
            // SalGraphics which share the same hWnd and hDC.
            // The shape 'Area' dialog does reparenting to trigger this.
            SAL_WARN("vcl.opengl", "Unusual: Windows handle / DC changed without DeInit");
            DeInit();
        }
    }
#endif
    SkiaSalGraphicsImpl::Init();
}

void WinSkiaSalGraphicsImpl::createSurface()
{
    if (isOffscreen())
        return SkiaSalGraphicsImpl::createSurface();
    if (GetWidth() == 0 || GetHeight() == 0)
    {
        // When created, Init() gets called with size (0,0), which is invalid size
        // for Skia. So fake a surface, Init() will get called later again with the correct size.
        mSurface = SkSurface::MakeRasterN32Premul(1, 1);
        return;
    }
    sk_app::DisplayParams displayParams;
    mWindowContext.reset(
        sk_app::window_context_factory::NewRasterForWin(mWinParent.gethWnd(), displayParams));
    assert(SkToBool(mWindowContext)); // TODO
    mSurface = mWindowContext->getBackbufferSurface();
    assert(mSurface.get());
}

void WinSkiaSalGraphicsImpl::DeInit()
{
    mWindowContext.reset();
    SkiaSalGraphicsImpl::DeInit();
}

void WinSkiaSalGraphicsImpl::freeResources() {}

void WinSkiaSalGraphicsImpl::performFlush()
{
    if (mWindowContext)
        mWindowContext->swapBuffers();
}

bool WinSkiaSalGraphicsImpl::TryRenderCachedNativeControl(ControlCacheKey const& rControlCacheKey,
                                                          int nX, int nY)
{
    (void)rControlCacheKey;
    (void)nX;
    (void)nY;
    return false; // TODO
}

// TODO OpenGLCompatibleDC?
bool WinSkiaSalGraphicsImpl::RenderAndCacheNativeControl(OpenGLCompatibleDC& rWhite,
                                                         OpenGLCompatibleDC& rBlack, int nX, int nY,
                                                         ControlCacheKey& aControlCacheKey)
{
    (void)rWhite;
    (void)rBlack;
    (void)nX;
    (void)nY;
    (void)aControlCacheKey;
    return false; // TODO
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */