[M108 Migration][VD] Avoid pending frame counter becoming negative
[platform/framework/web/chromium-efl.git] / cc / tiles / tile_draw_info.cc
1 // Copyright 2013 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "cc/tiles/tile_draw_info.h"
6
7 #include <utility>
8
9 #include "base/metrics/histogram_macros.h"
10 #include "cc/base/math_util.h"
11
12 namespace cc {
13
14 TileDrawInfo::TileDrawInfo() = default;
15 TileDrawInfo::~TileDrawInfo() {
16   DCHECK(!resource_);
17 }
18
19 void TileDrawInfo::AsValueInto(base::trace_event::TracedValue* state) const {
20   state->SetBoolean("is_solid_color", mode_ == SOLID_COLOR_MODE);
21   state->SetBoolean("is_transparent",
22                     mode_ == SOLID_COLOR_MODE && !solid_color_.isOpaque());
23 }
24
25 void TileDrawInfo::SetResource(ResourcePool::InUsePoolResource resource,
26                                bool resource_is_checker_imaged,
27                                bool is_premultiplied) {
28   DCHECK(!resource_);
29   DCHECK(resource);
30
31   mode_ = RESOURCE_MODE;
32   is_resource_ready_to_draw_ = false;
33   resource_is_checker_imaged_ = resource_is_checker_imaged;
34   is_premultiplied_ = is_premultiplied;
35   resource_ = std::move(resource);
36 }
37
38 const ResourcePool::InUsePoolResource& TileDrawInfo::GetResource() const {
39   DCHECK_EQ(mode_, RESOURCE_MODE);
40   DCHECK(resource_);
41   return resource_;
42 }
43
44 ResourcePool::InUsePoolResource TileDrawInfo::TakeResource() {
45   DCHECK_EQ(mode_, RESOURCE_MODE);
46   DCHECK(resource_);
47   is_resource_ready_to_draw_ = false;
48   resource_is_checker_imaged_ = false;
49   is_premultiplied_ = false;
50   return std::move(resource_);
51 }
52
53 }  // namespace cc