Files
odfstudio/vcl/inc/windowdev.hxx
T
Noel Grandin 088a7c7c45 remove alpha device from OutputDevice
and render to a combined color+alpha bitmap

The strategy is to remove the mpAlphaVDev from OutputDevice,
and have the OutputDevice create 32-bit SalBitmap's
and then have the various backends correctly render to
those 32-bit bitmaps.

However, whenever we extract a BitmapEx from OutputDevice
(e.g. via VirtualDevice) and hand it to the rest of the
system, we split the color and alpha information.
So the rest of the codebase doesn't have to deal with
this yet.

We have some major problems to overcome here:
(*) Cairo uses 32-bit data, even if we ask for 24-bit color with no alpha.
    This is because the current version of cairo does not support RGB 24-bit data.
(*) Sometimes we want the bitmap to be initialised with an opaque white background,
    sometimes we want it to be transparent.
(*) Sometimes when we extract a bitmap from a device, we want the alpha channel,
    sometimes not.
(*) There are lots of left-over bits of previous attempts of this change lying around,
    e.g. in skia.

Notes
(*) we allow Bitmap (ie. SalBitmap) to hold color+alpha
(*) The BitmapEx(Bitmap) constructor checks if the incoming
Bitmap is color+alpha, and if so, splits into a color bitmap and an alpha bitmap
(*) Because the underlying image data is stored pre-multipled, if
we write a transparent pixel with color, and then read the pixel value back,
we might lose the color information.

Change-Id: I0fc0042d6e5be5edd99b320892fb00a8eb2842fe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173937
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2025-07-21 10:49:25 +02:00

87 lines
3.2 KiB
C++

/* -*- 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/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
#include <vcl/outdev.hxx>
namespace vcl
{
class WindowOutputDevice final : public ::OutputDevice
{
public:
WindowOutputDevice(vcl::Window& rOwnerWindow);
virtual ~WindowOutputDevice() override;
virtual void dispose() override;
size_t GetSyncCount() const override { return 0x000000ff; }
virtual void EnableRTL(bool bEnable = true) override;
void Flush() override;
void SaveBackground(VirtualDevice& rSaveDevice, const Point& rPos, const Size& rSize,
const Size&) const override;
css::awt::DeviceInfo GetDeviceInfo() const override;
virtual vcl::Region GetActiveClipRegion() const override;
virtual vcl::Region GetOutputBoundsClipRegion() const override;
virtual bool AcquireGraphics() const override;
virtual void ReleaseGraphics(bool bRelease = true) override;
Color GetBackgroundColor() const override;
bool CanAnimate() const override { return true; }
using ::OutputDevice::SetSettings;
virtual void SetSettings(const AllSettings& rSettings) override;
void SetSettings(const AllSettings& rSettings, bool bChild);
bool CanEnableNativeWidget() const override;
/** Get the vcl::Window that this OutputDevice belongs to, if any */
virtual vcl::Window* GetOwnerWindow() const override { return mxOwnerWindow.get(); }
virtual css::uno::Reference<css::rendering::XCanvas>
ImplGetCanvas(bool bSpriteCanvas) const override;
virtual bool HasAlpha() const override { return true; }
private:
virtual void InitClipRegion() override;
void ImplClearFontData(bool bNewFontLists) override;
void ImplRefreshFontData(bool bNewFontLists) override;
void ImplInitMapModeObjects() override;
virtual void CopyDeviceArea(SalTwoRect& aPosAry, bool bWindowInvalidate) override;
virtual const OutputDevice* DrawOutDevDirectCheck(const OutputDevice& rSrcDev) const override;
virtual void DrawOutDevDirectProcess(const OutputDevice& rSrcDev, SalTwoRect& rPosAry,
SalGraphics* pSrcGraphics) override;
virtual void ClipToPaintRegion(tools::Rectangle& rDstRect) override;
virtual bool UsePolyPolygonForComplexGradient() override;
VclPtr<vcl::Window> mxOwnerWindow;
};
}; // namespace vcl
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */