Home | History | Annotate | Download | only in legacy
      1 /*
      2  * Copyright (C) 2016 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #include "geometry_utils.h"
     18 #include <algorithm>
     19 #include <utility>
     20 
     21 namespace cvd {
     22 
     23 bool LayersOverlap(const vsoc_hwc_layer& layer1, const vsoc_hwc_layer& layer2) {
     24   int left1 = layer1.displayFrame.left;
     25   int right1 = layer1.displayFrame.right;
     26   int top1 = layer1.displayFrame.top;
     27   int bottom1 = layer1.displayFrame.bottom;
     28 
     29   int left2 = layer2.displayFrame.left;
     30   int right2 = layer2.displayFrame.right;
     31   int top2 = layer2.displayFrame.top;
     32   int bottom2 = layer2.displayFrame.bottom;
     33 
     34   bool overlap_x = left1 < right2 && left2 < right1;
     35   bool overlap_y = top1 < bottom2 && top2 < bottom1;
     36 
     37   return overlap_x && overlap_y;
     38 }
     39 
     40 }  // namespace cvd
     41