Fixed subsample size adjustment in AVC AnnexB conversion
[chromium-blink-merge.git] / skia / ext / skia_utils_win.cc
blobe065b1e403cf30521d37bd0942890d28d9f8f050
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "skia/ext/skia_utils_win.h"
7 #include <stddef.h>
8 #include <windows.h>
10 #include "third_party/skia/include/core/SkRect.h"
11 #include "third_party/skia/include/core/SkTypes.h"
12 #include "third_party/skia/include/effects/SkGradientShader.h"
14 namespace {
16 SK_COMPILE_ASSERT(offsetof(RECT, left) == offsetof(SkIRect, fLeft), o1);
17 SK_COMPILE_ASSERT(offsetof(RECT, top) == offsetof(SkIRect, fTop), o2);
18 SK_COMPILE_ASSERT(offsetof(RECT, right) == offsetof(SkIRect, fRight), o3);
19 SK_COMPILE_ASSERT(offsetof(RECT, bottom) == offsetof(SkIRect, fBottom), o4);
20 SK_COMPILE_ASSERT(sizeof(RECT().left) == sizeof(SkIRect().fLeft), o5);
21 SK_COMPILE_ASSERT(sizeof(RECT().top) == sizeof(SkIRect().fTop), o6);
22 SK_COMPILE_ASSERT(sizeof(RECT().right) == sizeof(SkIRect().fRight), o7);
23 SK_COMPILE_ASSERT(sizeof(RECT().bottom) == sizeof(SkIRect().fBottom), o8);
24 SK_COMPILE_ASSERT(sizeof(RECT) == sizeof(SkIRect), o9);
26 } // namespace
28 namespace skia {
30 POINT SkPointToPOINT(const SkPoint& point) {
31 POINT win_point = {
32 SkScalarRoundToInt(point.fX), SkScalarRoundToInt(point.fY)
34 return win_point;
37 SkRect RECTToSkRect(const RECT& rect) {
38 SkRect sk_rect = { SkIntToScalar(rect.left), SkIntToScalar(rect.top),
39 SkIntToScalar(rect.right), SkIntToScalar(rect.bottom) };
40 return sk_rect;
43 SkColor COLORREFToSkColor(COLORREF color) {
44 #ifndef _MSC_VER
45 return SkColorSetRGB(GetRValue(color), GetGValue(color), GetBValue(color));
46 #else
47 // ARGB = 0xFF000000 | ((0BGR -> RGB0) >> 8)
48 return 0xFF000000u | (_byteswap_ulong(color) >> 8);
49 #endif
52 COLORREF SkColorToCOLORREF(SkColor color) {
53 #ifndef _MSC_VER
54 return RGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color));
55 #else
56 // 0BGR = ((ARGB -> BGRA) >> 8)
57 return (_byteswap_ulong(color) >> 8);
58 #endif
61 } // namespace skia