drag_util.cc 890 B

12345678910111213141516171819202122232425
  1. // Copyright (c) 2020 Microsoft, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #include "shell/browser/ui/drag_util.h"
  5. #include "third_party/blink/public/mojom/page/draggable_region.mojom.h"
  6. #include "third_party/skia/include/core/SkRegion.h"
  7. namespace electron {
  8. // Convert draggable regions in raw format to SkRegion format.
  9. std::unique_ptr<SkRegion> DraggableRegionsToSkRegion(
  10. const std::vector<blink::mojom::DraggableRegionPtr>& regions) {
  11. auto sk_region = std::make_unique<SkRegion>();
  12. for (const auto& region : regions) {
  13. sk_region->op(
  14. SkIRect::MakeLTRB(region->bounds.x(), region->bounds.y(),
  15. region->bounds.right(), region->bounds.bottom()),
  16. region->draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
  17. }
  18. return sk_region;
  19. }
  20. } // namespace electron