Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
src
gpu
RectanizerSkyline.h
Go to the documentation of this file.
1
/*
2
* Copyright 2014 Google Inc.
3
*
4
* Use of this source code is governed by a BSD-style license that can be
5
* found in the LICENSE file.
6
*/
7
8
#ifndef skgpu_RectanizerSkyline_DEFINED
9
#define skgpu_RectanizerSkyline_DEFINED
10
11
#include "
include/private/base/SkTDArray.h
"
12
#include "
src/gpu/Rectanizer.h
"
13
14
#include <cstdint>
15
16
struct
SkIPoint16
;
17
18
namespace
skgpu
{
19
20
// Pack rectangles and track the current silhouette
21
// Based, in part, on Jukka Jylanki's work at http://clb.demon.fi
22
//
23
// Mark this class final in an effort to avoid the vtable when this subclass is used explicitly.
24
class
RectanizerSkyline
final :
public
Rectanizer
{
25
public
:
26
RectanizerSkyline
(
int
w
,
int
h
) :
Rectanizer
(
w
,
h
) {
27
this->
reset
();
28
}
29
30
~RectanizerSkyline
() final { }
31
32
void
reset
() final {
33
fAreaSoFar = 0;
34
fSkyline.
clear
();
35
fSkyline.
push_back
(SkylineSegment{0, 0, this->
width
()});
36
}
37
38
bool
addRect
(
int
w
,
int
h
,
SkIPoint16
* loc)
final
;
39
40
float
percentFull
() const final {
41
return
fAreaSoFar / ((float)this->
width
() * this->
height
());
42
}
43
44
private
:
45
struct
SkylineSegment {
46
int
fX;
47
int
fY;
48
int
fWidth;
49
};
50
51
SkTDArray<SkylineSegment>
fSkyline;
52
53
int32_t fAreaSoFar;
54
55
// Can a width x height rectangle fit in the free space represented by
56
// the skyline segments >= 'skylineIndex'? If so, return true and fill in
57
// 'y' with the y-location at which it fits (the x location is pulled from
58
// 'skylineIndex's segment.
59
bool
rectangleFits(
int
skylineIndex,
int
width
,
int
height
,
int
*
y
)
const
;
60
// Update the skyline structure to include a width x height rect located
61
// at x,y.
62
void
addSkylineLevel(
int
skylineIndex,
int
x
,
int
y
,
int
width
,
int
height
);
63
};
64
65
}
// End of namespace skgpu
66
67
#endif
Rectanizer.h
SkTDArray.h
SkTDArray
Definition
SkTDArray.h:105
SkTDArray::push_back
void push_back(const T &v)
Definition
SkTDArray.h:219
SkTDArray::clear
void clear()
Definition
SkTDArray.h:175
skgpu::RectanizerSkyline
Definition
RectanizerSkyline.h:24
skgpu::RectanizerSkyline::addRect
bool addRect(int w, int h, SkIPoint16 *loc) final
Definition
RectanizerSkyline.cpp:17
skgpu::RectanizerSkyline::reset
void reset() final
Definition
RectanizerSkyline.h:32
skgpu::RectanizerSkyline::~RectanizerSkyline
~RectanizerSkyline() final
Definition
RectanizerSkyline.h:30
skgpu::RectanizerSkyline::RectanizerSkyline
RectanizerSkyline(int w, int h)
Definition
RectanizerSkyline.h:26
skgpu::RectanizerSkyline::percentFull
float percentFull() const final
Definition
RectanizerSkyline.h:40
skgpu::Rectanizer
Definition
Rectanizer.h:15
skgpu::Rectanizer::width
int width() const
Definition
Rectanizer.h:26
skgpu::Rectanizer::height
int height() const
Definition
Rectanizer.h:27
y
double y
Definition
mouse-input-test.cc:83
x
double x
Definition
mouse-input-test.cc:82
skgpu
Definition
GpuTools.h:21
w
SkScalar w
Definition
pictureshadertile.cpp:30
h
SkScalar h
Definition
pictureshadertile.cpp:30
SkIPoint16
Definition
SkIPoint16.h:17
Generated on Fri Apr 26 2024 06:17:21 for Flutter Engine by
1.9.8