OSDN Git Service

drm_hwcomposer: Move SeparateLayers into a member function
[android-x86/external-drm_hwcomposer.git] / drmdisplaycomposition.cpp
1 /*
2  * Copyright (C) 2015 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 #define LOG_TAG "hwc-drm-display-composition"
18
19 #include "drmdisplaycomposition.h"
20 #include "drmcrtc.h"
21 #include "drmplane.h"
22 #include "drmresources.h"
23
24 #include <stdlib.h>
25
26 #include <algorithm>
27 #include <unordered_set>
28
29 #include <cutils/log.h>
30 #include <sw_sync.h>
31 #include <sync/sync.h>
32 #include <xf86drmMode.h>
33
34 namespace android {
35
36 DrmDisplayComposition::~DrmDisplayComposition() {
37   if (timeline_fd_ >= 0) {
38     SignalCompositionDone();
39     close(timeline_fd_);
40   }
41 }
42
43 int DrmDisplayComposition::Init(DrmResources *drm, DrmCrtc *crtc,
44                                 Importer *importer, uint64_t frame_no) {
45   drm_ = drm;
46   crtc_ = crtc;  // Can be NULL if we haven't modeset yet
47   importer_ = importer;
48   frame_no_ = frame_no;
49
50   int ret = sw_sync_timeline_create();
51   if (ret < 0) {
52     ALOGE("Failed to create sw sync timeline %d", ret);
53     return ret;
54   }
55   timeline_fd_ = ret;
56   return 0;
57 }
58
59 bool DrmDisplayComposition::validate_composition_type(DrmCompositionType des) {
60   return type_ == DRM_COMPOSITION_TYPE_EMPTY || type_ == des;
61 }
62
63 int DrmDisplayComposition::CreateNextTimelineFence() {
64   ++timeline_;
65   return sw_sync_fence_create(timeline_fd_, "hwc drm display composition fence",
66                               timeline_);
67 }
68
69 int DrmDisplayComposition::IncreaseTimelineToPoint(int point) {
70   int timeline_increase = point - timeline_current_;
71   if (timeline_increase <= 0)
72     return 0;
73
74   int ret = sw_sync_timeline_inc(timeline_fd_, timeline_increase);
75   if (ret)
76     ALOGE("Failed to increment sync timeline %d", ret);
77   else
78     timeline_current_ = point;
79
80   return ret;
81 }
82
83 int DrmDisplayComposition::SetLayers(DrmHwcLayer *layers, size_t num_layers,
84                                      bool geometry_changed) {
85   if (!validate_composition_type(DRM_COMPOSITION_TYPE_FRAME))
86     return -EINVAL;
87
88   geometry_changed_ = geometry_changed;
89
90   for (size_t layer_index = 0; layer_index < num_layers; layer_index++) {
91     layers_.emplace_back(std::move(layers[layer_index]));
92   }
93
94   type_ = DRM_COMPOSITION_TYPE_FRAME;
95   return 0;
96 }
97
98 int DrmDisplayComposition::SetDpmsMode(uint32_t dpms_mode) {
99   if (!validate_composition_type(DRM_COMPOSITION_TYPE_DPMS))
100     return -EINVAL;
101   dpms_mode_ = dpms_mode;
102   type_ = DRM_COMPOSITION_TYPE_DPMS;
103   return 0;
104 }
105
106 int DrmDisplayComposition::SetDisplayMode(const DrmMode &display_mode) {
107   if (!validate_composition_type(DRM_COMPOSITION_TYPE_MODESET))
108     return -EINVAL;
109   display_mode_ = display_mode;
110   dpms_mode_ = DRM_MODE_DPMS_ON;
111   type_ = DRM_COMPOSITION_TYPE_MODESET;
112   return 0;
113 }
114
115 int DrmDisplayComposition::AddPlaneDisable(DrmPlane *plane) {
116   composition_planes_.emplace_back(DrmCompositionPlane::Type::kDisable, plane,
117                                    crtc_);
118   return 0;
119 }
120
121 static size_t CountUsablePlanes(DrmCrtc *crtc,
122                                 std::vector<DrmPlane *> *primary_planes,
123                                 std::vector<DrmPlane *> *overlay_planes) {
124   return std::count_if(
125              primary_planes->begin(), primary_planes->end(),
126              [=](DrmPlane *plane) { return plane->GetCrtcSupported(*crtc); }) +
127          std::count_if(
128              overlay_planes->begin(), overlay_planes->end(),
129              [=](DrmPlane *plane) { return plane->GetCrtcSupported(*crtc); });
130 }
131
132 static DrmPlane *TakePlane(DrmCrtc *crtc, std::vector<DrmPlane *> *planes) {
133   for (auto iter = planes->begin(); iter != planes->end(); ++iter) {
134     if ((*iter)->GetCrtcSupported(*crtc)) {
135       DrmPlane *plane = *iter;
136       planes->erase(iter);
137       return plane;
138     }
139   }
140   return NULL;
141 }
142
143 static DrmPlane *TakePlane(DrmCrtc *crtc,
144                            std::vector<DrmPlane *> *primary_planes,
145                            std::vector<DrmPlane *> *overlay_planes) {
146   DrmPlane *plane = TakePlane(crtc, primary_planes);
147   if (plane)
148     return plane;
149   return TakePlane(crtc, overlay_planes);
150 }
151
152 void DrmDisplayComposition::EmplaceCompositionPlane(
153     DrmCompositionPlane::Type type, std::vector<DrmPlane *> *primary_planes,
154     std::vector<DrmPlane *> *overlay_planes) {
155   DrmPlane *plane = TakePlane(crtc_, primary_planes, overlay_planes);
156   if (plane == NULL) {
157     ALOGE(
158         "Failed to add composition plane because there are no planes "
159         "remaining");
160     return;
161   }
162   composition_planes_.emplace_back(type, plane, crtc_);
163 }
164
165 void DrmDisplayComposition::EmplaceCompositionPlane(
166     size_t source_layer, std::vector<DrmPlane *> *primary_planes,
167     std::vector<DrmPlane *> *overlay_planes) {
168   DrmPlane *plane = TakePlane(crtc_, primary_planes, overlay_planes);
169   if (plane == NULL) {
170     ALOGE(
171         "Failed to add composition plane because there are no planes "
172         "remaining");
173     return;
174   }
175   composition_planes_.emplace_back(DrmCompositionPlane::Type::kLayer, plane,
176                                    crtc_, source_layer);
177 }
178
179 static std::vector<size_t> SetBitsToVector(uint64_t in, size_t *index_map) {
180   std::vector<size_t> out;
181   size_t msb = sizeof(in) * 8 - 1;
182   uint64_t mask = (uint64_t)1 << msb;
183   for (size_t i = msb; mask != (uint64_t)0; i--, mask >>= 1)
184     if (in & mask)
185       out.push_back(index_map[i]);
186   return out;
187 }
188
189 void DrmDisplayComposition::SeparateLayers(size_t *used_layers,
190                                            size_t num_used_layers,
191                                            DrmHwcRect<int> *exclude_rects,
192                                            size_t num_exclude_rects) {
193   DrmCompositionPlane *comp = NULL;
194   std::vector<size_t> dedicated_layers;
195
196   // Go through the composition and find the precomp layer as well as any
197   // layers that have a dedicated plane located below the precomp layer.
198   for (auto &i : composition_planes_) {
199     if (i.type() == DrmCompositionPlane::Type::kLayer) {
200       dedicated_layers.insert(dedicated_layers.end(), i.source_layers().begin(),
201                               i.source_layers().end());
202     } else if (i.type() == DrmCompositionPlane::Type::kPrecomp) {
203       comp = &i;
204       break;
205     }
206   }
207   if (!comp)
208     return;
209
210   if (num_used_layers > 64) {
211     ALOGE("Failed to separate layers because there are more than 64");
212     return;
213   }
214
215   // Index at which the actual layers begin
216   size_t layer_offset = num_exclude_rects + dedicated_layers.size();
217   if (num_used_layers + layer_offset > 64) {
218     ALOGW(
219         "Exclusion rectangles are being truncated to make the rectangle count "
220         "fit into 64");
221     num_exclude_rects = 64 - num_used_layers - dedicated_layers.size();
222   }
223
224   // We inject all the exclude rects into the rects list. Any resulting rect
225   // that includes ANY of the first num_exclude_rects is rejected. After the
226   // exclude rects, we add the lower layers. The rects that intersect with
227   // these layers will be inspected and only those which are to be composited
228   // above the layer will be included in the composition regions.
229   std::vector<DrmHwcRect<int>> layer_rects(num_used_layers + layer_offset);
230   std::copy(exclude_rects, exclude_rects + num_exclude_rects,
231             layer_rects.begin());
232   std::transform(
233       dedicated_layers.begin(), dedicated_layers.end(),
234       layer_rects.begin() + num_exclude_rects,
235       [=](size_t layer_index) { return layers_[layer_index].display_frame; });
236   std::transform(used_layers, used_layers + num_used_layers,
237                  layer_rects.begin() + layer_offset, [=](size_t layer_index) {
238     return layers_[layer_index].display_frame;
239   });
240
241   std::vector<separate_rects::RectSet<uint64_t, int>> separate_regions;
242   separate_rects::separate_rects_64(layer_rects, &separate_regions);
243   uint64_t exclude_mask = ((uint64_t)1 << num_exclude_rects) - 1;
244   uint64_t dedicated_mask = (((uint64_t)1 << dedicated_layers.size()) - 1)
245                             << num_exclude_rects;
246
247   for (separate_rects::RectSet<uint64_t, int> &region : separate_regions) {
248     if (region.id_set.getBits() & exclude_mask)
249       continue;
250
251     // If a rect intersects one of the dedicated layers, we need to remove the
252     // layers from the composition region which appear *below* the dedicated
253     // layer. This effectively punches a hole through the composition layer such
254     // that the dedicated layer can be placed below the composition and not
255     // be occluded.
256     uint64_t dedicated_intersect = region.id_set.getBits() & dedicated_mask;
257     for (size_t i = 0; dedicated_intersect && i < dedicated_layers.size();
258          ++i) {
259       // Only exclude layers if they intersect this particular dedicated layer
260       if (!(dedicated_intersect & (1 << (i + num_exclude_rects))))
261         continue;
262
263       for (size_t j = 0; j < num_used_layers; ++j) {
264         if (used_layers[j] < dedicated_layers[i])
265           region.id_set.subtract(j + layer_offset);
266       }
267     }
268     if (!(region.id_set.getBits() >> layer_offset))
269       continue;
270
271     pre_comp_regions_.emplace_back(DrmCompositionRegion{
272         region.rect,
273         SetBitsToVector(region.id_set.getBits() >> layer_offset, used_layers)});
274   }
275 }
276
277 int DrmDisplayComposition::CreateAndAssignReleaseFences() {
278   std::unordered_set<DrmHwcLayer *> squash_layers;
279   std::unordered_set<DrmHwcLayer *> pre_comp_layers;
280   std::unordered_set<DrmHwcLayer *> comp_layers;
281
282   for (const DrmCompositionRegion &region : squash_regions_) {
283     for (size_t source_layer_index : region.source_layers) {
284       DrmHwcLayer *source_layer = &layers_[source_layer_index];
285       squash_layers.emplace(source_layer);
286     }
287   }
288
289   for (const DrmCompositionRegion &region : pre_comp_regions_) {
290     for (size_t source_layer_index : region.source_layers) {
291       DrmHwcLayer *source_layer = &layers_[source_layer_index];
292       pre_comp_layers.emplace(source_layer);
293       squash_layers.erase(source_layer);
294     }
295   }
296
297   for (const DrmCompositionPlane &plane : composition_planes_) {
298     if (plane.type() == DrmCompositionPlane::Type::kLayer) {
299       for (auto i : plane.source_layers()) {
300         DrmHwcLayer *source_layer = &layers_[i];
301         comp_layers.emplace(source_layer);
302         pre_comp_layers.erase(source_layer);
303       }
304     }
305   }
306
307   for (DrmHwcLayer *layer : squash_layers) {
308     if (!layer->release_fence)
309       continue;
310     int ret = layer->release_fence.Set(CreateNextTimelineFence());
311     if (ret < 0)
312       return ret;
313   }
314   timeline_squash_done_ = timeline_;
315
316   for (DrmHwcLayer *layer : pre_comp_layers) {
317     if (!layer->release_fence)
318       continue;
319     int ret = layer->release_fence.Set(CreateNextTimelineFence());
320     if (ret < 0)
321       return ret;
322   }
323   timeline_pre_comp_done_ = timeline_;
324
325   for (DrmHwcLayer *layer : comp_layers) {
326     if (!layer->release_fence)
327       continue;
328     int ret = layer->release_fence.Set(CreateNextTimelineFence());
329     if (ret < 0)
330       return ret;
331   }
332
333   return 0;
334 }
335
336 int DrmDisplayComposition::Plan(SquashState *squash,
337                                 std::vector<DrmPlane *> *primary_planes,
338                                 std::vector<DrmPlane *> *overlay_planes) {
339   if (type_ != DRM_COMPOSITION_TYPE_FRAME)
340     return 0;
341
342   size_t planes_can_use =
343       CountUsablePlanes(crtc_, primary_planes, overlay_planes);
344   if (planes_can_use == 0) {
345     ALOGE("Display %d has no usable planes", crtc_->display());
346     return -ENODEV;
347   }
348
349   bool use_squash_framebuffer = false;
350   // Used to determine which layers were entirely squashed
351   std::vector<int> layer_squash_area(layers_.size(), 0);
352   // Used to avoid rerendering regions that were squashed
353   std::vector<DrmHwcRect<int>> exclude_rects;
354   if (squash != NULL && planes_can_use >= 3) {
355     if (geometry_changed_) {
356       squash->Init(layers_.data(), layers_.size());
357     } else {
358       std::vector<bool> changed_regions;
359       squash->GenerateHistory(layers_.data(), layers_.size(), changed_regions);
360
361       std::vector<bool> stable_regions;
362       squash->StableRegionsWithMarginalHistory(changed_regions, stable_regions);
363
364       // Only if SOME region is stable
365       use_squash_framebuffer =
366           std::find(stable_regions.begin(), stable_regions.end(), true) !=
367           stable_regions.end();
368
369       squash->RecordHistory(layers_.data(), layers_.size(), changed_regions);
370
371       // Changes in which regions are squashed triggers a rerender via
372       // squash_regions.
373       bool render_squash = squash->RecordAndCompareSquashed(stable_regions);
374
375       for (size_t region_index = 0; region_index < stable_regions.size();
376            region_index++) {
377         const SquashState::Region &region = squash->regions()[region_index];
378         if (!stable_regions[region_index])
379           continue;
380
381         exclude_rects.emplace_back(region.rect);
382
383         if (render_squash) {
384           squash_regions_.emplace_back();
385           squash_regions_.back().frame = region.rect;
386         }
387
388         int frame_area = region.rect.area();
389         // Source layers are sorted front to back i.e. top layer has lowest
390         // index.
391         for (size_t layer_index = layers_.size();
392              layer_index-- > 0;  // Yes, I double checked this
393              /* See condition */) {
394           if (!region.layer_refs[layer_index])
395             continue;
396           layer_squash_area[layer_index] += frame_area;
397           if (render_squash)
398             squash_regions_.back().source_layers.push_back(layer_index);
399         }
400       }
401     }
402   }
403
404   // All protected layers get first usage of planes
405   std::vector<size_t> layers_remaining;
406   std::vector<size_t> protected_layers;
407   for (size_t layer_index = 0; layer_index < layers_.size(); layer_index++) {
408     if (!layers_[layer_index].protected_usage() || planes_can_use == 0) {
409       layers_remaining.push_back(layer_index);
410       continue;
411     }
412     protected_layers.push_back(layer_index);
413     planes_can_use--;
414   }
415
416   if (planes_can_use == 0 && layers_remaining.size() > 0) {
417     for (auto i : protected_layers)
418       EmplaceCompositionPlane(i, primary_planes, overlay_planes);
419
420     ALOGE("Protected layers consumed all hardware planes");
421     return CreateAndAssignReleaseFences();
422   }
423
424   std::vector<size_t> layers_remaining_if_squash;
425   for (size_t layer_index : layers_remaining) {
426     if (layer_squash_area[layer_index] <
427         layers_[layer_index].display_frame.area())
428       layers_remaining_if_squash.push_back(layer_index);
429   }
430
431   if (use_squash_framebuffer) {
432     if (planes_can_use > 1 || layers_remaining_if_squash.size() == 0) {
433       layers_remaining = std::move(layers_remaining_if_squash);
434       planes_can_use--;  // Reserve plane for squashing
435     } else {
436       use_squash_framebuffer = false;  // The squash buffer is still rendered
437     }
438   }
439
440   if (layers_remaining.size() > planes_can_use)
441     planes_can_use--;  // Reserve one for pre-compositing
442
443   // Whatever planes that are not reserved get assigned a layer
444   size_t last_hw_comp_layer = 0;
445   size_t protected_idx = 0;
446   while(last_hw_comp_layer < layers_remaining.size() && planes_can_use > 0) {
447     size_t idx = layers_remaining[last_hw_comp_layer];
448
449     // Put the protected layers into the composition at the right place. We've
450     // already reserved them by decrementing planes_can_use, so no need to do
451     // that again.
452     if (protected_idx < protected_layers.size() &&
453         idx > protected_layers[protected_idx]) {
454       EmplaceCompositionPlane(protected_layers[protected_idx], primary_planes,
455                               overlay_planes);
456       protected_idx++;
457       continue;
458     }
459
460     EmplaceCompositionPlane(layers_remaining[last_hw_comp_layer],
461                             primary_planes, overlay_planes);
462     last_hw_comp_layer++;
463     planes_can_use--;
464   }
465
466   layers_remaining.erase(layers_remaining.begin(),
467                          layers_remaining.begin() + last_hw_comp_layer);
468
469   // Enqueue the rest of the protected layers (if any) between the hw composited
470   // overlay layers and the squash/precomp layers.
471   for (size_t i = protected_idx; i < protected_layers.size(); ++i)
472     EmplaceCompositionPlane(protected_layers[i], primary_planes,
473                             overlay_planes);
474
475   if (layers_remaining.size() > 0) {
476     EmplaceCompositionPlane(DrmCompositionPlane::Type::kPrecomp, primary_planes,
477                             overlay_planes);
478     SeparateLayers(layers_remaining.data(), layers_remaining.size(),
479                    exclude_rects.data(), exclude_rects.size());
480   }
481
482   if (use_squash_framebuffer) {
483     EmplaceCompositionPlane(DrmCompositionPlane::Type::kSquash, primary_planes,
484                             overlay_planes);
485   }
486
487   return CreateAndAssignReleaseFences();
488 }
489
490 static const char *DrmCompositionTypeToString(DrmCompositionType type) {
491   switch (type) {
492     case DRM_COMPOSITION_TYPE_EMPTY:
493       return "EMPTY";
494     case DRM_COMPOSITION_TYPE_FRAME:
495       return "FRAME";
496     case DRM_COMPOSITION_TYPE_DPMS:
497       return "DPMS";
498     case DRM_COMPOSITION_TYPE_MODESET:
499       return "MODESET";
500     default:
501       return "<invalid>";
502   }
503 }
504
505 static const char *DPMSModeToString(int dpms_mode) {
506   switch (dpms_mode) {
507     case DRM_MODE_DPMS_ON:
508       return "ON";
509     case DRM_MODE_DPMS_OFF:
510       return "OFF";
511     default:
512       return "<invalid>";
513   }
514 }
515
516 static void DumpBuffer(const DrmHwcBuffer &buffer, std::ostringstream *out) {
517   if (!buffer) {
518     *out << "buffer=<invalid>";
519     return;
520   }
521
522   *out << "buffer[w/h/format]=";
523   *out << buffer->width << "/" << buffer->height << "/" << buffer->format;
524 }
525
526 static void DumpTransform(uint32_t transform, std::ostringstream *out) {
527   *out << "[";
528
529   if (transform == 0)
530     *out << "IDENTITY";
531
532   bool separator = false;
533   if (transform & DrmHwcTransform::kFlipH) {
534     *out << "FLIPH";
535     separator = true;
536   }
537   if (transform & DrmHwcTransform::kFlipV) {
538     if (separator)
539       *out << "|";
540     *out << "FLIPV";
541     separator = true;
542   }
543   if (transform & DrmHwcTransform::kRotate90) {
544     if (separator)
545       *out << "|";
546     *out << "ROTATE90";
547     separator = true;
548   }
549   if (transform & DrmHwcTransform::kRotate180) {
550     if (separator)
551       *out << "|";
552     *out << "ROTATE180";
553     separator = true;
554   }
555   if (transform & DrmHwcTransform::kRotate270) {
556     if (separator)
557       *out << "|";
558     *out << "ROTATE270";
559     separator = true;
560   }
561
562   uint32_t valid_bits = DrmHwcTransform::kFlipH | DrmHwcTransform::kFlipH |
563                         DrmHwcTransform::kRotate90 |
564                         DrmHwcTransform::kRotate180 |
565                         DrmHwcTransform::kRotate270;
566   if (transform & ~valid_bits) {
567     if (separator)
568       *out << "|";
569     *out << "INVALID";
570   }
571   *out << "]";
572 }
573
574 static const char *BlendingToString(DrmHwcBlending blending) {
575   switch (blending) {
576     case DrmHwcBlending::kNone:
577       return "NONE";
578     case DrmHwcBlending::kPreMult:
579       return "PREMULT";
580     case DrmHwcBlending::kCoverage:
581       return "COVERAGE";
582     default:
583       return "<invalid>";
584   }
585 }
586
587 static void DumpRegion(const DrmCompositionRegion &region,
588                        std::ostringstream *out) {
589   *out << "frame";
590   region.frame.Dump(out);
591   *out << " source_layers=(";
592
593   const std::vector<size_t> &source_layers = region.source_layers;
594   for (size_t i = 0; i < source_layers.size(); i++) {
595     *out << source_layers[i];
596     if (i < source_layers.size() - 1) {
597       *out << " ";
598     }
599   }
600
601   *out << ")";
602 }
603
604 void DrmDisplayComposition::Dump(std::ostringstream *out) const {
605   *out << "----DrmDisplayComposition"
606        << " crtc=" << (crtc_ ? crtc_->id() : -1)
607        << " type=" << DrmCompositionTypeToString(type_);
608
609   switch (type_) {
610     case DRM_COMPOSITION_TYPE_DPMS:
611       *out << " dpms_mode=" << DPMSModeToString(dpms_mode_);
612       break;
613     case DRM_COMPOSITION_TYPE_MODESET:
614       *out << " display_mode=" << display_mode_.h_display() << "x"
615            << display_mode_.v_display();
616       break;
617     default:
618       break;
619   }
620
621   *out << " timeline[current/squash/pre-comp/done]=" << timeline_current_ << "/"
622        << timeline_squash_done_ << "/" << timeline_pre_comp_done_ << "/"
623        << timeline_ << "\n";
624
625   *out << "    Layers: count=" << layers_.size() << "\n";
626   for (size_t i = 0; i < layers_.size(); i++) {
627     const DrmHwcLayer &layer = layers_[i];
628     *out << "      [" << i << "] ";
629
630     DumpBuffer(layer.buffer, out);
631
632     if (layer.protected_usage())
633       *out << " protected";
634
635     *out << " transform=";
636     DumpTransform(layer.transform, out);
637     *out << " blending[a=" << (int)layer.alpha
638          << "]=" << BlendingToString(layer.blending) << " source_crop";
639     layer.source_crop.Dump(out);
640     *out << " display_frame";
641     layer.display_frame.Dump(out);
642
643     *out << "\n";
644   }
645
646   *out << "    Planes: count=" << composition_planes_.size() << "\n";
647   for (size_t i = 0; i < composition_planes_.size(); i++) {
648     const DrmCompositionPlane &comp_plane = composition_planes_[i];
649     *out << "      [" << i << "]"
650          << " plane=" << (comp_plane.plane() ? comp_plane.plane()->id() : -1)
651          << " type=";
652     switch (comp_plane.type()) {
653       case DrmCompositionPlane::Type::kDisable:
654         *out << "DISABLE";
655         break;
656       case DrmCompositionPlane::Type::kLayer:
657         *out << "LAYER";
658         break;
659       case DrmCompositionPlane::Type::kPrecomp:
660         *out << "PRECOMP";
661         break;
662       case DrmCompositionPlane::Type::kSquash:
663         *out << "SQUASH";
664         break;
665       default:
666         *out << "<invalid>";
667         break;
668     }
669
670     *out << " source_layer=";
671     for (auto i : comp_plane.source_layers()) {
672       *out << i << " ";
673     }
674     *out << "\n";
675   }
676
677   *out << "    Squash Regions: count=" << squash_regions_.size() << "\n";
678   for (size_t i = 0; i < squash_regions_.size(); i++) {
679     *out << "      [" << i << "] ";
680     DumpRegion(squash_regions_[i], out);
681     *out << "\n";
682   }
683
684   *out << "    Pre-Comp Regions: count=" << pre_comp_regions_.size() << "\n";
685   for (size_t i = 0; i < pre_comp_regions_.size(); i++) {
686     *out << "      [" << i << "] ";
687     DumpRegion(pre_comp_regions_[i], out);
688     *out << "\n";
689   }
690 }
691 }