#include "third_party/blink/renderer/platform/graphics/gpu/shared_gpu_context.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "gpu/command_buffer/client/raster_interface.h"
#include "gpu/config/gpu_driver_bug_workaround_type.h"
#include "gpu/config/gpu_feature_info.h"
#include "gpu/ipc/client/client_shared_image_interface.h"
#include "gpu/ipc/client/gpu_channel_host.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_graphics_context_3d_provider.h"
#include "third_party/blink/public/platform/web_url.h"
#include "third_party/blink/renderer/platform/graphics/gpu/webgraphics_shared_image_interface_provider_impl.h"
#include "third_party/blink/renderer/platform/scheduler/public/main_thread.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
namespace blink {
SharedGpuContext* SharedGpuContext::GetInstanceForCurrentThread() { … }
SharedGpuContext::SharedGpuContext() = default;
bool SharedGpuContext::IsGpuCompositingEnabled() { … }
base::WeakPtr<WebGraphicsContext3DProviderWrapper>
SharedGpuContext::ContextProviderWrapper() { … }
WebGraphicsSharedImageInterfaceProvider*
SharedGpuContext::SharedImageInterfaceProvider() { … }
gpu::GpuMemoryBufferManager* SharedGpuContext::GetGpuMemoryBufferManager() { … }
void SharedGpuContext::SetGpuMemoryBufferManagerForTesting(
gpu::GpuMemoryBufferManager* mgr) { … }
static void CreateContextProviderOnMainThread(
bool only_if_gpu_compositing,
bool* gpu_compositing_disabled,
std::unique_ptr<WebGraphicsContext3DProviderWrapper>* wrapper,
gpu::GpuMemoryBufferManager** gpu_memory_buffer_manager,
base::WaitableEvent* waitable_event) { … }
void SharedGpuContext::CreateContextProviderIfNeeded(
bool only_if_gpu_compositing) { … }
static void CreateGpuChannelOnMainThread(
scoped_refptr<gpu::GpuChannelHost>* gpu_channel,
base::WaitableEvent* waitable_event) { … }
void SharedGpuContext::CreateSharedImageInterfaceProviderIfNeeded() { … }
void SharedGpuContext::SetContextProviderFactoryForTesting(
ContextProviderFactory factory) { … }
void SharedGpuContext::Reset() { … }
bool SharedGpuContext::IsValidWithoutRestoring() { … }
bool SharedGpuContext::AllowSoftwareToAcceleratedCanvasUpgrade() { … }
#if BUILDFLAG(IS_ANDROID)
bool SharedGpuContext::MaySupportImageChromium() {
SharedGpuContext* this_ptr = GetInstanceForCurrentThread();
this_ptr->CreateContextProviderIfNeeded(true);
if (!this_ptr->context_provider_wrapper_) {
return false;
}
const gpu::GpuFeatureInfo& gpu_feature_info =
this_ptr->context_provider_wrapper_->ContextProvider()
->GetGpuFeatureInfo();
return gpu_feature_info
.status_values[gpu::GPU_FEATURE_TYPE_ANDROID_SURFACE_CONTROL] ==
gpu::kGpuFeatureStatusEnabled;
}
#endif
}