2020-10-27 21:28:43 +00:00
|
|
|
// Copyright (c) 2020 Microsoft, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "shell/browser/ui/drag_util.h"
|
|
|
|
|
2021-10-21 18:51:36 +00:00
|
|
|
#include "ui/gfx/geometry/skia_conversions.h"
|
2020-10-27 21:28:43 +00:00
|
|
|
|
|
|
|
namespace electron {
|
|
|
|
|
|
|
|
// Convert draggable regions in raw format to SkRegion format.
|
|
|
|
std::unique_ptr<SkRegion> DraggableRegionsToSkRegion(
|
|
|
|
const std::vector<mojom::DraggableRegionPtr>& regions) {
|
|
|
|
auto sk_region = std::make_unique<SkRegion>();
|
|
|
|
for (const auto& region : regions) {
|
|
|
|
sk_region->op(
|
2021-01-04 22:01:32 +00:00
|
|
|
SkIRect::MakeLTRB(region->bounds.x(), region->bounds.y(),
|
|
|
|
region->bounds.right(), region->bounds.bottom()),
|
2020-10-27 21:28:43 +00:00
|
|
|
region->draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
|
|
|
|
}
|
|
|
|
return sk_region;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace electron
|