From a36e193ca3f20e854c80ced80d676234f7d50133 Mon Sep 17 00:00:00 2001 From: "tapted@chromium.org" Date: Mon, 17 Feb 2014 03:26:48 +0000 Subject: [PATCH] Revert of Fix CreateHRGNFromSkPath to support arbitrary SkPaths. (https://codereview.chromium.org/83293008/) Reason for revert: As per http://crbug.com/344243 - this CL makes the App Launcher window invisible under Aero, and packaged app windows invisible under non-Aero (RDP/Classic theme/etc.). BUG=344243 Original issue's description: > Fix CreateHRGNFromSkPath to support arbitrary SkPaths. > > Also adds tests for CreateHRGNFromSkPath and CreateHRGNFromSkRegion. > > BUG=322360 > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=251555 TBR=ben@chromium.org,wez@chromium.org NOTREECHECKS=true NOTRY=true BUG=322360 Review URL: https://codereview.chromium.org/169223002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251636 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/gfx/path_win.cc | 14 +++++--- ui/gfx/path_win_unittest.cc | 82 --------------------------------------------- ui/ui_unittests.gyp | 1 - 3 files changed, 10 insertions(+), 87 deletions(-) delete mode 100644 ui/gfx/path_win_unittest.cc diff --git a/ui/gfx/path_win.cc b/ui/gfx/path_win.cc index 2588e811c12d..b28ea7a2c7bf 100644 --- a/ui/gfx/path_win.cc +++ b/ui/gfx/path_win.cc @@ -25,10 +25,16 @@ HRGN CreateHRGNFromSkRegion(const SkRegion& region) { } HRGN CreateHRGNFromSkPath(const SkPath& path) { - SkRegion clip(SkIRect::MakeLTRB(INT_MIN, INT_MIN, INT_MAX, INT_MAX)); - SkRegion region; - region.setPath(path, clip); - return CreateHRGNFromSkRegion(region); + int point_count = path.getPoints(NULL, 0); + scoped_ptr points(new SkPoint[point_count]); + path.getPoints(points.get(), point_count); + scoped_ptr windows_points(new POINT[point_count]); + for (int i = 0; i < point_count; ++i) { + windows_points[i].x = SkScalarRoundToInt(points[i].fX); + windows_points[i].y = SkScalarRoundToInt(points[i].fY); + } + + return ::CreatePolygonRgn(windows_points.get(), point_count, ALTERNATE); } // See path_aura.cc for Aura definition of these methods: diff --git a/ui/gfx/path_win_unittest.cc b/ui/gfx/path_win_unittest.cc deleted file mode 100644 index a307b630e92b..000000000000 --- a/ui/gfx/path_win_unittest.cc +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2014 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 "ui/gfx/path_win.h" - -#include -#include - -#include "base/logging.h" -#include "base/win/scoped_gdi_object.h" -#include "skia/ext/skia_utils_win.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/skia/include/core/SkPath.h" -#include "third_party/skia/include/core/SkRegion.h" - -namespace gfx { -namespace { - -std::vector GetRectsFromHRGN(HRGN region) { - // Determine the size of output buffer required to receive the region. - DWORD bytes_size = GetRegionData(region, 0, NULL); - CHECK(bytes_size != 0); - - // Fetch the Windows RECTs that comprise the region. - std::vector buffer(bytes_size);; - LPRGNDATA region_data = reinterpret_cast(buffer.data()); - DWORD result = GetRegionData(region, bytes_size, region_data); - CHECK(result == bytes_size); - - // Pull out the rectangles into a SkIRect vector to pass to setRects(). - const LPRECT rects = reinterpret_cast(®ion_data->Buffer[0]); - std::vector sk_rects(region_data->rdh.nCount); - std::transform(rects, rects + region_data->rdh.nCount, - sk_rects.begin(), skia::RECTToSkIRect); - - return sk_rects; -} - -TEST(PathWinTest, BasicSkPathToHRGN) { - SkPath path; - path.moveTo(0.0f, 0.0f); - path.rLineTo(100.0f, 0.0f); - path.rLineTo(0.0f, 100.0f); - path.rLineTo(-100.0f, 0.0f); - path.rLineTo(0.0f, -100.0f); - base::win::ScopedRegion region(CreateHRGNFromSkPath(path)); - std::vector result = GetRectsFromHRGN(region); - EXPECT_EQ(1U, result.size()); - EXPECT_EQ(0, result[0].left()); - EXPECT_EQ(0, result[0].top()); - EXPECT_EQ(100, result[0].right()); - EXPECT_EQ(100, result[0].bottom()); -} - -TEST(PathWinTest, NonContiguousSkPathToHRGN) { - SkPath path; - path.moveTo(0.0f, 0.0f); - path.rLineTo(100.0f, 0.0f); - path.rLineTo(0.0f, 100.0f); - path.rLineTo(-100.0f, 0.0f); - path.rLineTo(0.0f, -100.0f); - path.moveTo(150.0f, 0.0f); - path.rLineTo(100.0f, 0.0f); - path.rLineTo(0.0f, 100.0f); - path.rLineTo(-100.0f, 0.0f); - path.rLineTo(0.0f, -100.0f); - base::win::ScopedRegion region(CreateHRGNFromSkPath(path)); - std::vector result = GetRectsFromHRGN(region); - EXPECT_EQ(2U, result.size()); - EXPECT_EQ(0, result[0].left()); - EXPECT_EQ(0, result[0].top()); - EXPECT_EQ(100, result[0].right()); - EXPECT_EQ(100, result[0].bottom()); - EXPECT_EQ(150, result[1].left()); - EXPECT_EQ(0, result[1].top()); - EXPECT_EQ(250, result[1].right()); - EXPECT_EQ(100, result[1].bottom()); -} - -} // namespace -} // namespace gfx diff --git a/ui/ui_unittests.gyp b/ui/ui_unittests.gyp index 3e2f43a79fb8..9577c42fc388 100644 --- a/ui/ui_unittests.gyp +++ b/ui/ui_unittests.gyp @@ -156,7 +156,6 @@ 'gfx/ozone/dri/hardware_display_controller_unittest.cc', 'gfx/ozone/dri/dri_surface_factory_unittest.cc', 'gfx/ozone/dri/dri_surface_unittest.cc', - 'gfx/path_win_unittest.cc', 'gfx/platform_font_mac_unittest.mm', 'gfx/render_text_unittest.cc', 'gfx/sequential_id_generator_unittest.cc', -- 2.11.4.GIT