diff options
Diffstat (limited to 'src/core/compositor/display_skia_output_device.cpp')
-rw-r--r-- | src/core/compositor/display_skia_output_device.cpp | 76 |
1 files changed, 20 insertions, 56 deletions
diff --git a/src/core/compositor/display_skia_output_device.cpp b/src/core/compositor/display_skia_output_device.cpp index c33a31b87..ee693ed81 100644 --- a/src/core/compositor/display_skia_output_device.cpp +++ b/src/core/compositor/display_skia_output_device.cpp @@ -1,48 +1,12 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "display_skia_output_device.h" #include "type_conversion.h" #include "gpu/command_buffer/service/skia_utils.h" -#include "skia/ext/legacy_display_globals.h" +#include "third_party/skia/include/core/SkSurfaceProps.h" namespace QtWebEngineCore { @@ -53,29 +17,31 @@ public: : m_parent(parent) , m_shape(m_parent->m_shape) { - auto formatIndex = static_cast<int>(m_shape.format); - const auto &colorType = m_parent->capabilities_.sk_color_types[formatIndex]; - DCHECK(colorType != kUnknown_SkColorType) - << "SkColorType is invalid for format: " << formatIndex; + const auto &colorType = m_shape.characterization.colorType(); + DCHECK(colorType != kUnknown_SkColorType); m_texture = m_parent->m_contextState->gr_context()->createBackendTexture( - m_shape.sizeInPixels.width(), m_shape.sizeInPixels.height(), colorType, + m_shape.characterization.width(), m_shape.characterization.height(), colorType, GrMipMapped::kNo, GrRenderable::kYes); DCHECK(m_texture.isValid()); if (m_texture.backend() == GrBackendApi::kVulkan) { +#if BUILDFLAG(ENABLE_VULKAN) GrVkImageInfo info; bool result = m_texture.getVkImageInfo(&info); DCHECK(result); m_estimatedSize = info.fAlloc.fSize; +#else + NOTREACHED(); +#endif } else { - auto info = SkImageInfo::Make(m_shape.sizeInPixels.width(), m_shape.sizeInPixels.height(), + auto info = SkImageInfo::Make(m_shape.characterization.width(), m_shape.characterization.height(), colorType, kUnpremul_SkAlphaType); m_estimatedSize = info.computeMinByteSize(); } m_parent->memory_type_tracker_->TrackMemAlloc(m_estimatedSize); - SkSurfaceProps surfaceProps = skia::LegacyDisplayGlobals::GetSkSurfaceProps(); + SkSurfaceProps surfaceProps = SkSurfaceProps{0, kUnknown_SkPixelGeometry}; m_surface = SkSurface::MakeFromBackendTexture( m_parent->m_contextState->gr_context(), m_texture, m_parent->capabilities_.output_surface_origin == gfx::SurfaceOrigin::kTopLeft @@ -129,6 +95,7 @@ DisplaySkiaOutputDevice::DisplaySkiaOutputDevice( , m_contextState(contextState) { capabilities_.uses_default_gl_framebuffer = false; + capabilities_.supports_surfaceless = true; capabilities_.sk_color_types[static_cast<int>(gfx::BufferFormat::RGBA_8888)] = kRGBA_8888_SkColorType; @@ -149,13 +116,12 @@ void DisplaySkiaOutputDevice::SetFrameSinkId(const viz::FrameSinkId &id) bind(id); } -bool DisplaySkiaOutputDevice::Reshape(const gfx::Size& sizeInPixels, - float devicePixelRatio, - const gfx::ColorSpace& colorSpace, - gfx::BufferFormat format, +bool DisplaySkiaOutputDevice::Reshape(const SkSurfaceCharacterization &characterization, + const gfx::ColorSpace &colorSpace, + float device_scale_factor, gfx::OverlayTransform transform) { - m_shape = Shape{sizeInPixels, devicePixelRatio, colorSpace, format}; + m_shape = Shape{characterization, device_scale_factor, colorSpace}; DCHECK_EQ(transform, gfx::OVERLAY_TRANSFORM_NONE); return true; } @@ -188,10 +154,8 @@ void DisplaySkiaOutputDevice::DiscardBackbuffer() { } -SkSurface *DisplaySkiaOutputDevice::BeginPaint(bool allocate_frame_buffer, - std::vector<GrBackendSemaphore> *) +SkSurface *DisplaySkiaOutputDevice::BeginPaint(std::vector<GrBackendSemaphore> *) { - Q_UNUSED(allocate_frame_buffer); // FIXME? if (!m_backBuffer || m_backBuffer->shape() != m_shape) m_backBuffer = std::make_unique<Buffer>(this); return m_backBuffer->surface(); @@ -234,7 +198,7 @@ int DisplaySkiaOutputDevice::textureId() QSize DisplaySkiaOutputDevice::size() { - return m_frontBuffer ? toQt(m_frontBuffer->shape().sizeInPixels) : QSize(); + return m_frontBuffer ? toQt(m_frontBuffer->shape().characterization.dimensions()) : QSize(); } bool DisplaySkiaOutputDevice::hasAlphaChannel() @@ -255,7 +219,7 @@ void DisplaySkiaOutputDevice::SwapBuffersFinished() } FinishSwapBuffers(gfx::SwapCompletionResult(gfx::SwapResult::SWAP_ACK), - gfx::Size(m_shape.sizeInPixels.width(), m_shape.sizeInPixels.height()), + gfx::Size(m_shape.characterization.width(), m_shape.characterization.height()), std::move(m_frame)); } |