1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/viz/common/quads/quad_list.h"
#include "components/viz/common/quads/compositor_render_pass_draw_quad.h"
#include "components/viz/common/quads/debug_border_draw_quad.h"
#include "components/viz/common/quads/draw_quad.h"
#include "components/viz/common/quads/largest_draw_quad.h"
#include "components/viz/common/quads/picture_draw_quad.h"
#include "components/viz/common/quads/shared_element_draw_quad.h"
#include "components/viz/common/quads/shared_quad_state.h"
#include "components/viz/common/quads/solid_color_draw_quad.h"
#include "components/viz/common/quads/surface_draw_quad.h"
#include "components/viz/common/quads/texture_draw_quad.h"
#include "components/viz/common/quads/tile_draw_quad.h"
#include "components/viz/common/quads/video_hole_draw_quad.h"
namespace {
// This rounding is required because 'LargestDrawQuadSize' and
// 'LargestDrawQuadAlignment' might not be the largest for the same quad type.
// For example |TextureDrawQuad| might be the largest quad but only have an
// alignment requirement of 8 bytes whereas |TileDrawQuad| might not be the
// largest quad but could have an alignment requirement of 16 bytes.
constexpr size_t RoundUp(size_t size, size_t align) {
return (size + align - 1u) & ~(align - 1u);
}
const size_t kDefaultNumQuadsToReserve = 128;
} // namespace
namespace viz {
QuadList::QuadList()
: ListContainer<DrawQuad>(
LargestDrawQuadAlignment(),
RoundUp(LargestDrawQuadSize(), LargestDrawQuadAlignment()),
kDefaultNumQuadsToReserve) {}
QuadList::QuadList(size_t default_size_to_reserve)
: ListContainer<DrawQuad>(
LargestDrawQuadAlignment(),
RoundUp(LargestDrawQuadSize(), LargestDrawQuadAlignment()),
default_size_to_reserve) {}
QuadList::Iterator QuadList::InsertCopyBeforeDrawQuad(Iterator at,
size_t count) {
DCHECK(at->shared_quad_state);
switch (at->material) {
case DrawQuad::Material::kDebugBorder: {
const auto copy = *DebugBorderDrawQuad::MaterialCast(*at);
return InsertBeforeAndInvalidateAllPointers<DebugBorderDrawQuad>(
at, count, copy);
}
case DrawQuad::Material::kPictureContent: {
const auto copy = *PictureDrawQuad::MaterialCast(*at);
return InsertBeforeAndInvalidateAllPointers<PictureDrawQuad>(at, count,
copy);
}
case DrawQuad::Material::kTextureContent: {
const auto copy = *TextureDrawQuad::MaterialCast(*at);
return InsertBeforeAndInvalidateAllPointers<TextureDrawQuad>(at, count,
copy);
}
case DrawQuad::Material::kSolidColor: {
const auto copy = *SolidColorDrawQuad::MaterialCast(*at);
return InsertBeforeAndInvalidateAllPointers<SolidColorDrawQuad>(at, count,
copy);
}
case DrawQuad::Material::kTiledContent: {
const auto copy = *TileDrawQuad::MaterialCast(*at);
return InsertBeforeAndInvalidateAllPointers<TileDrawQuad>(at, count,
copy);
}
case DrawQuad::Material::kSurfaceContent: {
const auto copy = *SurfaceDrawQuad::MaterialCast(*at);
return InsertBeforeAndInvalidateAllPointers<SurfaceDrawQuad>(at, count,
copy);
}
case DrawQuad::Material::kVideoHole: {
const auto copy = *VideoHoleDrawQuad::MaterialCast(*at);
return InsertBeforeAndInvalidateAllPointers<VideoHoleDrawQuad>(at, count,
copy);
}
case DrawQuad::Material::kSharedElement: {
const auto copy = *SharedElementDrawQuad::MaterialCast(*at);
return InsertBeforeAndInvalidateAllPointers<SharedElementDrawQuad>(
at, count, copy);
}
// RenderPass quads should not be copied.
case DrawQuad::Material::kAggregatedRenderPass:
case DrawQuad::Material::kCompositorRenderPass:
case DrawQuad::Material::kInvalid:
NOTREACHED(); // Invalid DrawQuad material.
}
}
} // namespace viz
|