1aeca6fd0e
* feat: GPU shared texture offscreen rendering * docs: clarify texture infos that passed by the paint event. * feat: make gpu osr spec test optional * fix: osr image compare * fix: remove duplicate test * fix: update patch file * fix: code review * feat: expose more metadata * feat: use better switch design * feat: add warning when user forget to release the texture. * fix: typo * chore: update patch * fix: update patch * fix: update patch description * fix: update docs * fix: apply suggestions from code review Co-authored-by: Charles Kerr <charles@charleskerr.com> * fix: apply suggested fixes --------- Co-authored-by: Charles Kerr <charles@charleskerr.com>
39 lines
1.2 KiB
Text
39 lines
1.2 KiB
Text
// Copyright (c) 2019 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_host_display_client.h"
|
|
#include "third_party/skia/include/core/SkBitmap.h"
|
|
#include "third_party/skia/include/core/SkImageInfo.h"
|
|
|
|
#include <IOSurface/IOSurface.h>
|
|
|
|
namespace electron {
|
|
|
|
void OffScreenHostDisplayClient::OnDisplayReceivedCALayerParams(
|
|
const gfx::CALayerParams& ca_layer_params) {
|
|
if (!ca_layer_params.is_empty) {
|
|
base::apple::ScopedCFTypeRef<IOSurfaceRef> io_surface(
|
|
IOSurfaceLookupFromMachPort(
|
|
ca_layer_params.io_surface_mach_port.get()));
|
|
|
|
gfx::Size pixel_size_ = ca_layer_params.pixel_size;
|
|
void* pixels =
|
|
static_cast<void*>(IOSurfaceGetBaseAddress(io_surface.get()));
|
|
size_t stride = IOSurfaceGetBytesPerRow(io_surface.get());
|
|
|
|
struct IOSurfacePinner {
|
|
base::apple::ScopedCFTypeRef<IOSurfaceRef> io_surface;
|
|
};
|
|
|
|
SkBitmap bitmap;
|
|
bitmap.installPixels(
|
|
SkImageInfo::MakeN32(pixel_size_.width(), pixel_size_.height(),
|
|
kPremul_SkAlphaType),
|
|
pixels, stride);
|
|
bitmap.setImmutable();
|
|
callback_.Run(ca_layer_params.damage, bitmap, {});
|
|
}
|
|
}
|
|
|
|
} // namespace electron
|