forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gpu: Create a backing factory for Ozone SharedImages
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
Showing
3 changed files
with
136 additions
and
0 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
69 changes: 69 additions & 0 deletions
69
gpu/command_buffer/service/shared_image_backing_factory_ozone.cc
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,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
65
gpu/command_buffer/service/shared_image_backing_factory_ozone.h
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,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_ |