diff options
author | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-02 22:35:42 +0000 |
---|---|---|
committer | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-02 22:35:42 +0000 |
commit | 004a96a015b5dfcadaad4ea1b192c97c415b75de (patch) | |
tree | cb32d3809e4366c07e837416a106a3083d2690a5 /skia/ext/skia_utils_win.cc | |
parent | f8ed412acb7bcab9855d0ebd9d29f7e38a3a8f92 (diff) | |
download | chromium_src-004a96a015b5dfcadaad4ea1b192c97c415b75de.zip chromium_src-004a96a015b5dfcadaad4ea1b192c97c415b75de.tar.gz chromium_src-004a96a015b5dfcadaad4ea1b192c97c415b75de.tar.bz2 |
Move convolver, image_operations, and skia_utils from base/gfx to skia/ext.
This changes the namespace in those files from "gfx" to "skia".
I split skia_utils into two parts, the Windows specific part is now in a separate file called skia_utils_win.
There were several obsolete includes of these headers which I removed. I also removed img_resize_perftest which isn't used and has bitrotted.
Review URL: http://codereview.chromium.org/12842
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6248 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext/skia_utils_win.cc')
-rw-r--r-- | skia/ext/skia_utils_win.cc | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/skia/ext/skia_utils_win.cc b/skia/ext/skia_utils_win.cc new file mode 100644 index 0000000..f695a63 --- /dev/null +++ b/skia/ext/skia_utils_win.cc @@ -0,0 +1,59 @@ +// Copyright (c) 2006-2008 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 <windows.h> + +#include "skia/ext/skia_utils_win.h" + +#include "SkRect.h" +#include "SkGradientShader.h" + +namespace { + +// Compiler assert from base/logging.h +template <bool> +struct CompileAssert { +}; +#undef COMPILE_ASSERT +#define COMPILE_ASSERT(expr, msg) \ + typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] + +COMPILE_ASSERT(SK_OFFSETOF(RECT, left) == SK_OFFSETOF(SkIRect, fLeft), o1); +COMPILE_ASSERT(SK_OFFSETOF(RECT, top) == SK_OFFSETOF(SkIRect, fTop), o2); +COMPILE_ASSERT(SK_OFFSETOF(RECT, right) == SK_OFFSETOF(SkIRect, fRight), o3); +COMPILE_ASSERT(SK_OFFSETOF(RECT, bottom) == SK_OFFSETOF(SkIRect, fBottom), o4); +COMPILE_ASSERT(sizeof(RECT().left) == sizeof(SkIRect().fLeft), o5); +COMPILE_ASSERT(sizeof(RECT().top) == sizeof(SkIRect().fTop), o6); +COMPILE_ASSERT(sizeof(RECT().right) == sizeof(SkIRect().fRight), o7); +COMPILE_ASSERT(sizeof(RECT().bottom) == sizeof(SkIRect().fBottom), o8); +COMPILE_ASSERT(sizeof(RECT) == sizeof(SkIRect), o9); + +} // namespace + +namespace skia { + +POINT SkPointToPOINT(const SkPoint& point) { + POINT win_point = { SkScalarRound(point.fX), SkScalarRound(point.fY) }; + return win_point; +} + +SkRect RECTToSkRect(const RECT& rect) { + SkRect sk_rect = { SkIntToScalar(rect.left), SkIntToScalar(rect.top), + SkIntToScalar(rect.right), SkIntToScalar(rect.bottom) }; + return sk_rect; +} + +SkColor COLORREFToSkColor(COLORREF color) { + return SkColorSetRGB(GetRValue(color), GetGValue(color), GetBValue(color)); +} + +COLORREF SkColorToCOLORREF(SkColor color) { + // Currently, Alpha is always 255 or the color is 0 so there is no need to + // demultiply the channels. If this is needed, (SkColorGetX(color) * 255 / a) + // will have to be added in the conversion. + return RGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color)); +} + +} // namespace skia + |