#ifndef CONTENT_COMMON_GPU_GPU_MEMORY_ALLOCATION_H_
#define CONTENT_COMMON_GPU_GPU_MEMORY_ALLOCATION_H_
#include "base/basictypes.h"
struct GpuMemoryAllocationForRenderer {
enum {
INVALID_RESOURCE_SIZE = -1
};
size_t gpu_resource_size_in_bytes;
bool suggest_have_backbuffer;
GpuMemoryAllocationForRenderer()
: gpu_resource_size_in_bytes(0),
suggest_have_backbuffer(false) {
}
GpuMemoryAllocationForRenderer(size_t gpu_resource_size_in_bytes,
bool suggest_have_backbuffer)
: gpu_resource_size_in_bytes(gpu_resource_size_in_bytes),
suggest_have_backbuffer(suggest_have_backbuffer) {
}
bool operator==(const GpuMemoryAllocationForRenderer& other) const {
return gpu_resource_size_in_bytes == other.gpu_resource_size_in_bytes &&
suggest_have_backbuffer == other.suggest_have_backbuffer;
}
bool operator!=(const GpuMemoryAllocationForRenderer& other) const {
return !(*this == other);
}
};
struct GpuMemoryAllocationForBrowser {
bool suggest_have_frontbuffer;
GpuMemoryAllocationForBrowser()
: suggest_have_frontbuffer(false) {
}
GpuMemoryAllocationForBrowser(bool suggest_have_frontbuffer)
: suggest_have_frontbuffer(suggest_have_frontbuffer) {
}
bool operator==(const GpuMemoryAllocationForBrowser& other) const {
return suggest_have_frontbuffer == other.suggest_have_frontbuffer;
}
bool operator!=(const GpuMemoryAllocationForBrowser& other) const {
return !(*this == other);
}
};
struct GpuMemoryAllocation : public GpuMemoryAllocationForRenderer,
public GpuMemoryAllocationForBrowser {
enum BufferAllocation {
kHasNoBuffers = 0,
kHasFrontbuffer = 1,
kHasBackbuffer = 2
};
GpuMemoryAllocation()
: GpuMemoryAllocationForRenderer(),
GpuMemoryAllocationForBrowser() {
}
GpuMemoryAllocation(size_t gpu_resource_size_in_bytes,
int allocationBitmap)
: GpuMemoryAllocationForRenderer(gpu_resource_size_in_bytes,
(allocationBitmap & kHasBackbuffer) == kHasBackbuffer),
GpuMemoryAllocationForBrowser(
(allocationBitmap & kHasFrontbuffer) == kHasFrontbuffer) {
}
bool operator==(const GpuMemoryAllocation& other) const {
return static_cast<const GpuMemoryAllocationForRenderer&>(*this) ==
static_cast<const GpuMemoryAllocationForRenderer&>(other) &&
static_cast<const GpuMemoryAllocationForBrowser&>(*this) ==
static_cast<const GpuMemoryAllocationForBrowser&>(other);
}
bool operator!=(const GpuMemoryAllocation& other) const {
return !(*this == other);
}
};
struct GpuMemoryAllocationRequest {
size_t min_allocation_bytes;
size_t ideal_allocation_bytes;
GpuMemoryAllocationRequest()
: min_allocation_bytes(0),
ideal_allocation_bytes(0) {
}
GpuMemoryAllocationRequest(size_t min_bytes, size_t ideal_bytes)
: min_allocation_bytes(min_bytes),
ideal_allocation_bytes(ideal_bytes) {
}
bool operator==(const GpuMemoryAllocationRequest& other) const {
return min_allocation_bytes == other.min_allocation_bytes &&
ideal_allocation_bytes == other.ideal_allocation_bytes;
}
bool operator!=(const GpuMemoryAllocationRequest& other) const {
return !(*this == other);
}
};
#endif