#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "gpu/command_buffer/service/common_decoder.h"
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <algorithm>
#include "base/numerics/safe_math.h"
#include "base/pickle.h"
#include "gpu/command_buffer/service/command_buffer_service.h"
#include "gpu/command_buffer/service/decoder_client.h"
#include "ui/gfx/ipc/color/gfx_param_traits.h"
namespace gpu {
namespace {
static const size_t kDefaultMaxBucketSize = …;
uint32_t LoadU32Unaligned(const void* ptr) { … }
void StoreU32Unaligned(uint32_t v, void* ptr) { … }
}
const CommonDecoder::CommandInfo CommonDecoder::command_info[] = …;
CommonDecoder::Bucket::Bucket() : … { … }
CommonDecoder::Bucket::~Bucket() = default;
void* CommonDecoder::Bucket::GetData(size_t offset, size_t size) const { … }
void CommonDecoder::Bucket::SetSize(size_t size) { … }
bool CommonDecoder::Bucket::SetData(
const volatile void* src, size_t offset, size_t size) { … }
void CommonDecoder::Bucket::SetFromString(const char* str) { … }
bool CommonDecoder::Bucket::GetAsString(std::string* str) { … }
bool CommonDecoder::Bucket::GetAsStrings(
GLsizei* _count, std::vector<char*>* _string, std::vector<GLint>* _length) { … }
bool CommonDecoder::Bucket::OffsetSizeValid(size_t offset, size_t size) const { … }
CommonDecoder::CommonDecoder(DecoderClient* client,
CommandBufferServiceBase* command_buffer_service)
: … { … }
CommonDecoder::~CommonDecoder() = default;
void* CommonDecoder::GetAddressAndCheckSize(unsigned int shm_id,
unsigned int data_offset,
unsigned int data_size) { … }
void* CommonDecoder::GetAddressAndSize(unsigned int shm_id,
unsigned int data_offset,
unsigned int minimum_size,
unsigned int* data_size) { … }
unsigned int CommonDecoder::GetSharedMemorySize(unsigned int shm_id,
unsigned int offset) { … }
scoped_refptr<gpu::Buffer> CommonDecoder::GetSharedMemoryBuffer(
unsigned int shm_id) { … }
const char* CommonDecoder::GetCommonCommandName(
cmd::CommandId command_id) const { … }
CommonDecoder::Bucket* CommonDecoder::GetBucket(uint32_t bucket_id) const { … }
CommonDecoder::Bucket* CommonDecoder::CreateBucket(uint32_t bucket_id) { … }
namespace {
template <typename T>
const volatile void* AddressAfterStruct(const volatile T& pod) { … }
template <typename RETURN_TYPE, typename COMMAND_TYPE>
RETURN_TYPE GetImmediateDataAs(const volatile COMMAND_TYPE& pod) { … }
}
error::Error CommonDecoder::DoCommonCommand(unsigned int command,
unsigned int arg_count,
const volatile void* cmd_data) { … }
error::Error CommonDecoder::HandleNoop(uint32_t immediate_data_size,
const volatile void* cmd_data) { … }
error::Error CommonDecoder::HandleSetToken(uint32_t immediate_data_size,
const volatile void* cmd_data) { … }
error::Error CommonDecoder::HandleSetBucketSize(uint32_t immediate_data_size,
const volatile void* cmd_data) { … }
error::Error CommonDecoder::HandleSetBucketData(uint32_t immediate_data_size,
const volatile void* cmd_data) { … }
error::Error CommonDecoder::HandleSetBucketDataImmediate(
uint32_t immediate_data_size,
const volatile void* cmd_data) { … }
error::Error CommonDecoder::HandleGetBucketStart(
uint32_t immediate_data_size,
const volatile void* cmd_data) { … }
error::Error CommonDecoder::HandleGetBucketData(uint32_t immediate_data_size,
const volatile void* cmd_data) { … }
error::Error CommonDecoder::HandleInsertFenceSync(
uint32_t immediate_data_size,
const volatile void* cmd_data) { … }
bool CommonDecoder::ReadColorSpace(uint32_t shm_id,
uint32_t shm_offset,
uint32_t color_space_size,
gfx::ColorSpace* color_space) { … }
}