summaryrefslogtreecommitdiffstats
path: root/ppapi/shared_impl/ppb_image_data_shared.cc
blob: abdea60e270f633b89afdc3c3ffe0147c97f3dd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 {

// static
PP_ImageDataFormat PPB_ImageData_Shared::GetNativeImageDataFormat() {
#if defined(OS_NACL)
  // In NaCl, just default to something. If we're wrong, it will be converted
  // later.
  // TODO(dmichael): Really proxy this.
  return PP_IMAGEDATAFORMAT_BGRA_PREMUL;
#elif defined(NACL_WIN64)
  // In the NaCl Win64 helper, this shouldn't be called. If we start building
  // Chrome on Windows 64 for realz, we should really implement this.
  NOTIMPLEMENTED();
  return PP_IMAGEDATAFORMAT_BGRA_PREMUL;
#else
  return PP_IMAGEDATAFORMAT_BGRA_PREMUL;  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;  // Default to something on failure.
#endif
}

// static
bool PPB_ImageData_Shared::IsImageDataFormatSupported(
    PP_ImageDataFormat format) {
  return format == PP_IMAGEDATAFORMAT_BGRA_PREMUL ||
         format == PP_IMAGEDATAFORMAT_RGBA_PREMUL;
}

}  // namespace ppapi