chromium/gpu/command_buffer/common/shared_image_usage.h

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef GPU_COMMAND_BUFFER_COMMON_SHARED_IMAGE_USAGE_H_
#define GPU_COMMAND_BUFFER_COMMON_SHARED_IMAGE_USAGE_H_

#include <stdint.h>

#include <initializer_list>
#include <string>

#include "gpu/gpu_export.h"

namespace gpu {

// Please update the function, CreateLabelForSharedImageUsage, when adding a new
// enum value.
enum SharedImageUsage : uint32_t {};

class GPU_EXPORT SharedImageUsageSet {};

inline constexpr const SharedImageUsageSet Intersection(
    gpu::SharedImageUsageSet set_a,
    gpu::SharedImageUsageSet set_b) {}
// The global operators below cause 'SharedImageUsage' operations to result in
// 'SharedImageUsageSet' and avoid the ambiguity with uint32_t.
inline constexpr gpu::SharedImageUsageSet operator|(
    gpu::SharedImageUsageSet set_a,
    gpu::SharedImageUsageSet set_b) {}

inline constexpr gpu::SharedImageUsageSet operator|(
    gpu::SharedImageUsageSet set_a,
    gpu::SharedImageUsage mask_b) {}

inline constexpr gpu::SharedImageUsageSet operator|(
    gpu::SharedImageUsage mask_a,
    gpu::SharedImageUsageSet set_b) {}

inline constexpr gpu::SharedImageUsageSet operator|(
    gpu::SharedImageUsage mask_a,
    gpu::SharedImageUsage mask_b) {}

inline constexpr bool operator==(gpu::SharedImageUsageSet set_a,
                                 gpu::SharedImageUsageSet set_b) {}

// This is used as the debug_label prefix for all shared images created by
// importing buffers in Exo. This prefix is checked in the GPU process when
// reporting if memory for shared images is attributed to exo imports or not.
GPU_EXPORT extern const char kExoTextureLabelPrefix[];

// Returns true if usage is a valid client usage.
GPU_EXPORT bool IsValidClientUsage(SharedImageUsageSet usage);

// Returns true iff usage includes SHARED_IMAGE_USAGE_GLES2_READ or
// SHARED_IMAGE_USAGE_GLES2_WRITE.
GPU_EXPORT bool HasGLES2ReadOrWriteUsage(SharedImageUsageSet usage);

// Create a string to label SharedImageUsage.
GPU_EXPORT std::string CreateLabelForSharedImageUsage(
    SharedImageUsageSet usage);

}  // namespace gpu

#endif  // GPU_COMMAND_BUFFER_COMMON_SHARED_IMAGE_USAGE_H_