disable two ClientCertStoreChromeOSTest.* unit_tests on Valgrind bots
[chromium-blink-merge.git] / cc / tiles / tile_draw_info.h
blob05596ba921637cac6ddf0391dfc98944a0426a6d
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CC_TILES_TILE_DRAW_INFO_H_
6 #define CC_TILES_TILE_DRAW_INFO_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/trace_event/trace_event_argument.h"
10 #include "cc/raster/tile_task_runner.h"
11 #include "cc/resources/platform_color.h"
12 #include "cc/resources/resource_provider.h"
13 #include "cc/resources/scoped_resource.h"
15 namespace cc {
17 // This class holds all the state relevant to drawing a tile.
18 class CC_EXPORT TileDrawInfo {
19 public:
20 enum Mode { RESOURCE_MODE, SOLID_COLOR_MODE, OOM_MODE };
22 TileDrawInfo();
23 ~TileDrawInfo();
25 Mode mode() const { return mode_; }
27 bool IsReadyToDraw() const {
28 switch (mode_) {
29 case RESOURCE_MODE:
30 return !!resource_;
31 case SOLID_COLOR_MODE:
32 case OOM_MODE:
33 return true;
35 NOTREACHED();
36 return false;
38 bool NeedsRaster() const {
39 switch (mode_) {
40 case RESOURCE_MODE:
41 return !resource_;
42 case SOLID_COLOR_MODE:
43 return false;
44 case OOM_MODE:
45 return true;
47 NOTREACHED();
48 return false;
51 ResourceId resource_id() const {
52 DCHECK(mode_ == RESOURCE_MODE);
53 DCHECK(resource_);
54 return resource_->id();
57 gfx::Size resource_size() const {
58 DCHECK(mode_ == RESOURCE_MODE);
59 DCHECK(resource_);
60 return resource_->size();
63 SkColor solid_color() const {
64 DCHECK(mode_ == SOLID_COLOR_MODE);
65 return solid_color_;
68 bool contents_swizzled() const { return contents_swizzled_; }
70 bool requires_resource() const {
71 return mode_ == RESOURCE_MODE || mode_ == OOM_MODE;
74 inline bool has_resource() const { return !!resource_; }
76 void SetSolidColorForTesting(SkColor color) { set_solid_color(color); }
78 void AsValueInto(base::trace_event::TracedValue* state) const;
80 void set_was_ever_ready_to_draw() { was_ever_ready_to_draw_ = true; }
81 void set_was_ever_used_to_draw() { was_ever_used_to_draw_ = true; }
83 private:
84 friend class Tile;
85 friend class TileManager;
87 void set_use_resource() { mode_ = RESOURCE_MODE; }
89 void set_solid_color(const SkColor& color) {
90 mode_ = SOLID_COLOR_MODE;
91 solid_color_ = color;
94 void set_oom() { mode_ = OOM_MODE; }
96 Mode mode_;
97 SkColor solid_color_;
98 Resource* resource_;
99 bool contents_swizzled_;
101 // Used for gathering UMA stats.
102 bool was_ever_ready_to_draw_;
103 bool was_ever_used_to_draw_;
106 } // namespace cc
108 #endif // CC_TILES_TILE_DRAW_INFO_H_