drag_util.cc 805 B

123456789101112131415161718192021222324
  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 "ui/gfx/geometry/skia_conversions.h"
  6. namespace electron {
  7. // Convert draggable regions in raw format to SkRegion format.
  8. std::unique_ptr<SkRegion> DraggableRegionsToSkRegion(
  9. const std::vector<mojom::DraggableRegionPtr>& regions) {
  10. auto sk_region = std::make_unique<SkRegion>();
  11. for (const auto& region : regions) {
  12. sk_region->op(
  13. SkIRect::MakeLTRB(region->bounds.x(), region->bounds.y(),
  14. region->bounds.right(), region->bounds.bottom()),
  15. region->draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
  16. }
  17. return sk_region;
  18. }
  19. } // namespace electron