Skip to content

Commit

Permalink
gpu: Create a backing factory for Ozone SharedImages
Browse files Browse the repository at this point in the history
This CL creates a SharedImageBackingFactory for Ozone-based
SharedImages. Currently, SharedImageBackingFactoryOzone does not
support creating shared images from pixel data or GpuMemoryBuffers.

Bug: 1023997,996470
Change-Id: If62251b9a55f5cdbe975c648da2349029bae732f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1913086
Reviewed-by: Khushal <khushalsagar@chromium.org>
Reviewed-by: Daniele Castagna <dcastagna@chromium.org>
Reviewed-by: Andres Calderon Jaramillo <andrescj@chromium.org>
Commit-Queue: Brian Ho <hob@chromium.org>
Cr-Commit-Position: refs/heads/master@{#740043}
  • Loading branch information
Brian Ho authored and Commit Bot committed Feb 10, 2020
1 parent e59c9ae commit ff1d044
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gpu/command_buffer/service/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ target(link_target_type, "gles2_sources") {

if (use_ozone) {
sources += [
"shared_image_backing_factory_ozone.cc",
"shared_image_backing_factory_ozone.h",
"shared_image_backing_ozone.cc",
"shared_image_backing_ozone.h",
"shared_image_representation_gl_ozone.cc",
Expand Down
69 changes: 69 additions & 0 deletions gpu/command_buffer/service/shared_image_backing_factory_ozone.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "gpu/command_buffer/service/shared_image_backing_factory_ozone.h"

#include <dawn/dawn_proc_table.h>
#include <dawn_native/DawnNative.h>

#include "base/logging.h"
#include "gpu/command_buffer/service/shared_image_backing_ozone.h"

namespace gpu {

SharedImageBackingFactoryOzone::SharedImageBackingFactoryOzone(
SharedContextState* shared_context_state)
: shared_context_state_(shared_context_state),
dawn_procs_(base::MakeRefCounted<base::RefCountedData<DawnProcTable>>(
dawn_native::GetProcs())) {}

SharedImageBackingFactoryOzone::~SharedImageBackingFactoryOzone() = default;

std::unique_ptr<SharedImageBacking>
SharedImageBackingFactoryOzone::CreateSharedImage(
const Mailbox& mailbox,
viz::ResourceFormat format,
const gfx::Size& size,
const gfx::ColorSpace& color_space,
uint32_t usage,
bool is_thread_safe) {
DCHECK(!is_thread_safe);
return SharedImageBackingOzone::Create(dawn_procs_, shared_context_state_,
mailbox, format, size, color_space,
usage);
}

std::unique_ptr<SharedImageBacking>
SharedImageBackingFactoryOzone::CreateSharedImage(
const Mailbox& mailbox,
viz::ResourceFormat format,
const gfx::Size& size,
const gfx::ColorSpace& color_space,
uint32_t usage,
base::span<const uint8_t> pixel_data) {
NOTIMPLEMENTED_LOG_ONCE();
return nullptr;
}

std::unique_ptr<SharedImageBacking>
SharedImageBackingFactoryOzone::CreateSharedImage(
const Mailbox& mailbox,
int client_id,
gfx::GpuMemoryBufferHandle handle,
gfx::BufferFormat buffer_format,
SurfaceHandle surface_handle,
const gfx::Size& size,
const gfx::ColorSpace& color_space,
uint32_t usage) {
NOTIMPLEMENTED_LOG_ONCE();
return nullptr;
}

bool SharedImageBackingFactoryOzone::CanImportGpuMemoryBuffer(
gfx::GpuMemoryBufferType memory_buffer_type) {
NOTIMPLEMENTED_LOG_ONCE();
return false;
}

} // namespace gpu
65 changes: 65 additions & 0 deletions gpu/command_buffer/service/shared_image_backing_factory_ozone.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef GPU_COMMAND_BUFFER_SERVICE_SHARED_IMAGE_BACKING_FACTORY_OZONE_H_
#define GPU_COMMAND_BUFFER_SERVICE_SHARED_IMAGE_BACKING_FACTORY_OZONE_H_

#include "base/memory/ref_counted.h"
#include "base/memory/scoped_refptr.h"
#include "gpu/command_buffer/service/shared_image_backing_factory.h"
#include "gpu/gpu_gles2_export.h"

struct DawnProcTable;

namespace gpu {

class SharedContextState;

// Implementation of SharedImageBackingFactory that produces NativePixmap
// backed SharedImages.
class GPU_GLES2_EXPORT SharedImageBackingFactoryOzone
: public SharedImageBackingFactory {
public:
SharedImageBackingFactoryOzone(SharedContextState* shared_context_state);

~SharedImageBackingFactoryOzone() override;

// SharedImageBackingFactory implementation
std::unique_ptr<SharedImageBacking> CreateSharedImage(
const Mailbox& mailbox,
viz::ResourceFormat format,
const gfx::Size& size,
const gfx::ColorSpace& color_space,
uint32_t usage,
bool is_thread_safe) override;

std::unique_ptr<SharedImageBacking> CreateSharedImage(
const Mailbox& mailbox,
viz::ResourceFormat format,
const gfx::Size& size,
const gfx::ColorSpace& color_space,
uint32_t usage,
base::span<const uint8_t> pixel_data) override;

std::unique_ptr<SharedImageBacking> CreateSharedImage(
const Mailbox& mailbox,
int client_id,
gfx::GpuMemoryBufferHandle handle,
gfx::BufferFormat format,
SurfaceHandle surface_handle,
const gfx::Size& size,
const gfx::ColorSpace& color_space,
uint32_t usage) override;

bool CanImportGpuMemoryBuffer(
gfx::GpuMemoryBufferType memory_buffer_type) override;

private:
SharedContextState* const shared_context_state_;
scoped_refptr<base::RefCountedData<DawnProcTable>> dawn_procs_;
};

} // namespace gpu

#endif // GPU_COMMAND_BUFFER_SERVICE_SHARED_IMAGE_BACKING_FACTORY_OZONE_H_

0 comments on commit ff1d044

Please sign in to comment.