This source file includes following definitions.
- GetNativeImageDataFormat
- IsImageDataFormatSupported
- IsImageDataDescValid
#include "ppapi/shared_impl/ppb_image_data_shared.h"
#include "base/logging.h"
#include "build/build_config.h"
#if !defined(OS_NACL) && !defined(NACL_WIN64)
#include "third_party/skia/include/core/SkTypes.h"
#endif
namespace ppapi {
PP_ImageDataFormat PPB_ImageData_Shared::GetNativeImageDataFormat() {
#if defined(OS_NACL)
return PP_IMAGEDATAFORMAT_BGRA_PREMUL;
#elif defined(NACL_WIN64)
NOTIMPLEMENTED();
return PP_IMAGEDATAFORMAT_BGRA_PREMUL;
#else
if (SK_B32_SHIFT == 0)
return PP_IMAGEDATAFORMAT_BGRA_PREMUL;
else if (SK_R32_SHIFT == 0)
return PP_IMAGEDATAFORMAT_RGBA_PREMUL;
else
return PP_IMAGEDATAFORMAT_BGRA_PREMUL;
#endif
}
PP_Bool PPB_ImageData_Shared::IsImageDataFormatSupported(
PP_ImageDataFormat format) {
return PP_FromBool(format == PP_IMAGEDATAFORMAT_BGRA_PREMUL ||
format == PP_IMAGEDATAFORMAT_RGBA_PREMUL);
}
PP_Bool PPB_ImageData_Shared::IsImageDataDescValid(
const PP_ImageDataDesc& desc) {
return PP_FromBool(IsImageDataFormatSupported(desc.format) &&
desc.size.width > 0 && desc.size.height > 0 &&
desc.stride > 0);
}
}