-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: GPU shared texture offscreen rendering
- Loading branch information
Showing
24 changed files
with
341 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# OffscreenSharedTexture Object | ||
|
||
* `widgetType` string - The widget type of the texture, could be `popup` or `frame`. | ||
* `pixelFormat` string - The pixel format of the texture, could be `rgba` or `bgra`. | ||
* `sharedTextureHandle` string - _Windows_ _macOS_ The handle to the shared texture. | ||
* `planes` Object[] - _Linux_ Each plane's info of the shared texture. | ||
* `stride` number - The strides and offsets in bytes to be used when accessing the buffers via a memory mapping. One per plane per entry. | ||
* `offset` number - The strides and offsets in bytes to be used when accessing the buffers via a memory mapping. One per plane per entry. | ||
* `size` number - Size in bytes of the plane. This is necessary to map the buffers. | ||
* `fd` number - File descriptor for the underlying memory object (usually dmabuf). | ||
* `modifier` string - _Linux_ The modifier is retrieved from GBM library and passed to EGL driver. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
// Copyright (c) 2024 GitHub, Inc. | ||
// Use of this source code is governed by the MIT license that can be found in | ||
// the LICENSE file. | ||
|
||
#include "shell/browser/osr/osr_paint_event.h" | ||
|
||
namespace electron { | ||
|
||
NativePixmapPlaneInfo::NativePixmapPlaneInfo() = default; | ||
NativePixmapPlaneInfo::~NativePixmapPlaneInfo() = default; | ||
NativePixmapPlaneInfo::NativePixmapPlaneInfo( | ||
const NativePixmapPlaneInfo& other) = default; | ||
NativePixmapPlaneInfo::NativePixmapPlaneInfo(uint32_t stride, | ||
uint64_t offset, | ||
uint64_t size, | ||
int fd) | ||
: stride(stride), offset(offset), size(size), fd(fd) {} | ||
|
||
OffscreenSharedTextureValue::OffscreenSharedTextureValue() = default; | ||
OffscreenSharedTextureValue::~OffscreenSharedTextureValue() = default; | ||
OffscreenSharedTextureValue::OffscreenSharedTextureValue( | ||
const OffscreenSharedTextureValue& other) = default; | ||
|
||
} // namespace electron |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
|
||
// Copyright (c) 2024 GitHub, Inc. | ||
// Use of this source code is governed by the MIT license that can be found in | ||
// the LICENSE file. | ||
|
||
#ifndef ELECTRON_SHELL_BROWSER_OSR_GPU_SHARED_TEXTURE_H | ||
#define ELECTRON_SHELL_BROWSER_OSR_GPU_SHARED_TEXTURE_H | ||
|
||
#include "base/functional/callback_helpers.h" | ||
#include "media/base/video_types.h" | ||
#include "third_party/skia/include/core/SkCanvas.h" | ||
#include "ui/gfx/canvas.h" | ||
#include "ui/gfx/native_widget_types.h" | ||
|
||
#include <cstdint> | ||
|
||
#include "content/public/common/widget_type.h" | ||
|
||
namespace electron { | ||
|
||
struct NativePixmapPlaneInfo { | ||
// The strides and offsets in bytes to be used when accessing the buffers | ||
// via a memory mapping. One per plane per entry. Size in bytes of the | ||
// plane is necessary to map the buffers. | ||
uint32_t stride; | ||
uint64_t offset; | ||
uint64_t size; | ||
|
||
// File descriptor for the underlying memory object (usually dmabuf). | ||
int fd; | ||
|
||
NativePixmapPlaneInfo(); | ||
~NativePixmapPlaneInfo(); | ||
NativePixmapPlaneInfo(const NativePixmapPlaneInfo& other); | ||
NativePixmapPlaneInfo(uint32_t stride, | ||
uint64_t offset, | ||
uint64_t size, | ||
int fd); | ||
}; | ||
|
||
struct OffscreenSharedTextureValue { | ||
OffscreenSharedTextureValue(); | ||
~OffscreenSharedTextureValue(); | ||
OffscreenSharedTextureValue(const OffscreenSharedTextureValue& other); | ||
|
||
// It is user's responsibility to compose popup widget textures. | ||
content::WidgetType widget_type; | ||
|
||
// The pixel format of the shared texture, RGBA or BGRA depends on platform. | ||
media::VideoPixelFormat pixel_format; | ||
|
||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) | ||
// On Windows it is a HANDLE to the shared D3D11 texture. | ||
// On macOS it is a IOSurface* to the shared IOSurface. | ||
uintptr_t shared_texture_handle; | ||
#elif BUILDFLAG(IS_LINUX) | ||
std::vector<NativePixmapPlaneInfo> planes; | ||
uint64_t modifier; | ||
#endif | ||
}; | ||
|
||
typedef std::optional<OffscreenSharedTextureValue> OffscreenSharedTexture; | ||
|
||
typedef base::RepeatingCallback< | ||
void(const gfx::Rect&, const SkBitmap&, const OffscreenSharedTexture&)> | ||
OnPaintCallback; | ||
|
||
} // namespace electron | ||
|
||
#endif // ELECTRON_SHELL_BROWSER_OSR_GPU_SHARED_TEXTURE_H |
Oops, something went wrong.