rounded_corner_utils.cc 855 B

123456789101112131415161718192021222324252627
  1. // Copyright (c) 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ash/public/cpp/rounded_corner_utils.h"
  5. #include "ui/aura/window.h"
  6. #include "ui/compositor/layer.h"
  7. #include "ui/compositor_extra/shadow.h"
  8. #include "ui/gfx/geometry/rounded_corners_f.h"
  9. #include "ui/wm/core/shadow_controller.h"
  10. namespace ash {
  11. void SetCornerRadius(aura::Window* shadow_window,
  12. ui::Layer* layer,
  13. int radius) {
  14. float radius_f = radius;
  15. layer->SetRoundedCornerRadius({radius_f, radius_f, radius_f, radius_f});
  16. layer->SetIsFastRoundedCorner(true);
  17. ui::Shadow* shadow = wm::ShadowController::GetShadowForWindow(shadow_window);
  18. if (shadow)
  19. shadow->SetRoundedCornerRadius(radius);
  20. }
  21. } // namespace ash