blob: 62fe6861dd6e5c402bd4ceb9c8371e08e54b9aeb (
plain)
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
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/picture_pile_base.h"
#include "base/logging.h"
namespace cc {
PicturePileBase::PicturePileBase()
: min_contents_scale_(0),
buffer_pixels_(0) {
SetMinContentsScale(1);
}
PicturePileBase::~PicturePileBase() {
}
void PicturePileBase::Resize(gfx::Size size) {
if (size_ == size)
return;
pile_.clear();
size_ = size;
}
void PicturePileBase::SetMinContentsScale(float min_contents_scale) {
DCHECK(min_contents_scale);
if (min_contents_scale_ == min_contents_scale)
return;
pile_.clear();
min_contents_scale_ = min_contents_scale;
// Picture contents are played back scaled. When the final contents scale is
// less than 1 (i.e. low res), then multiple recorded pixels will be used
// to raster one final pixel. To avoid splitting a final pixel across
// pictures (which would result in incorrect rasterization due to blending), a
// buffer margin is added so that any picture can be snapped to integral
// final pixels.
//
// For example, if a 1/4 contents scale is used, then that would be 3 buffer
// pixels, since that's the minimum number of pixels to add so that resulting
// content can be snapped to a four pixel aligned grid.
buffer_pixels_ = static_cast<int>(ceil(1 / min_contents_scale_) - 1);
buffer_pixels_ = std::max(0, buffer_pixels_);
}
void PicturePileBase::PushPropertiesTo(PicturePileBase* other) {
other->pile_ = pile_;
other->size_ = size_;
other->min_contents_scale_ = min_contents_scale_;
other->buffer_pixels_ = buffer_pixels_;
}
} // namespace cc
|