OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/shared_impl/ppb_image_data_shared.h" | 5 #include "ppapi/shared_impl/ppb_image_data_shared.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #if !defined(OS_NACL) && !defined(NACL_WIN64) | 10 #if !defined(OS_NACL) && !defined(NACL_WIN64) |
11 #include "third_party/skia/include/core/SkTypes.h" | 11 #include "third_party/skia/include/core/SkTypes.h" |
12 #endif | 12 #endif |
13 | 13 |
14 namespace ppapi { | 14 namespace ppapi { |
15 | 15 |
16 // static | 16 // static |
17 PP_ImageDataFormat PPB_ImageData_Shared::GetNativeImageDataFormat() { | 17 PP_ImageDataFormat PPB_ImageData_Shared::GetNativeImageDataFormat() { |
18 #if defined(OS_NACL) | 18 #if defined(OS_NACL) |
19 // In NaCl, just default to something. If we're wrong, it will be converted | 19 // In NaCl, just default to something. If we're wrong, it will be converted |
20 // later. | 20 // later. |
21 // TODO(dmichael): Really proxy this. | 21 // TODO(dmichael): Really proxy this. |
22 return PP_IMAGEDATAFORMAT_BGRA_PREMUL; | 22 return PP_IMAGEDATAFORMAT_BGRA_PREMUL; |
23 #elif defined(NACL_WIN64) | 23 #elif defined(NACL_WIN64) |
24 // In the NaCl Win64 helper, this shouldn't be called. If we start building | 24 // In the NaCl Win64 helper, this shouldn't be called. If we start building |
25 // Chrome on Windows 64 for realz, we should really implement this. | 25 // Chrome on Windows 64 for realz, we should really implement this. |
26 NOTIMPLEMENTED(); | 26 NOTIMPLEMENTED(); |
27 return PP_IMAGEDATAFORMAT_BGRA_PREMUL; | 27 return PP_IMAGEDATAFORMAT_BGRA_PREMUL; |
28 #else | 28 #else |
29 return PP_IMAGEDATAFORMAT_BGRA_PREMUL; | 29 if (SK_B32_SHIFT == 0) |
| 30 return PP_IMAGEDATAFORMAT_BGRA_PREMUL; |
| 31 else if (SK_R32_SHIFT == 0) |
| 32 return PP_IMAGEDATAFORMAT_RGBA_PREMUL; |
| 33 else |
| 34 return PP_IMAGEDATAFORMAT_BGRA_PREMUL; // Default to something on failure |
30 #endif | 35 #endif |
31 } | 36 } |
32 | 37 |
33 // static | 38 // static |
34 PP_Bool PPB_ImageData_Shared::IsImageDataFormatSupported( | 39 PP_Bool PPB_ImageData_Shared::IsImageDataFormatSupported( |
35 PP_ImageDataFormat format) { | 40 PP_ImageDataFormat format) { |
36 return PP_FromBool(format == PP_IMAGEDATAFORMAT_BGRA_PREMUL || | 41 return PP_FromBool(format == PP_IMAGEDATAFORMAT_BGRA_PREMUL || |
37 format == PP_IMAGEDATAFORMAT_RGBA_PREMUL); | 42 format == PP_IMAGEDATAFORMAT_RGBA_PREMUL); |
38 } | 43 } |
39 | 44 |
40 // static | 45 // static |
41 PP_Bool PPB_ImageData_Shared::IsImageDataDescValid( | 46 PP_Bool PPB_ImageData_Shared::IsImageDataDescValid( |
42 const PP_ImageDataDesc& desc) { | 47 const PP_ImageDataDesc& desc) { |
43 return PP_FromBool(IsImageDataFormatSupported(desc.format) && | 48 return PP_FromBool(IsImageDataFormatSupported(desc.format) && |
44 desc.size.width > 0 && | 49 desc.size.width > 0 && |
45 desc.size.height > 0 && | 50 desc.size.height > 0 && |
46 desc.stride > 0); | 51 desc.stride > 0); |
47 } | 52 } |
48 | 53 |
49 } // namespace ppapi | 54 } // namespace ppapi |
OLD | NEW |