ChromeVox should only intercept 'tab' key if nothing has focus.
[chromium-blink-merge.git] / cc / resources / tile_draw_info.h
blobb6bc6d84b31cb4da10afc619a3e6ba122d30d540
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_RESOURCES_TILE_DRAW_INFO_H_
6 #define CC_RESOURCES_TILE_DRAW_INFO_H_
8 #include "base/debug/trace_event_argument.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "cc/resources/platform_color.h"
11 #include "cc/resources/resource_provider.h"
12 #include "cc/resources/scoped_resource.h"
13 #include "cc/resources/tile_task_runner.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, PICTURE_PILE_MODE };
22 TileDrawInfo();
23 ~TileDrawInfo();
25 Mode mode() const { return mode_; }
27 bool IsReadyToDraw() const;
29 ResourceProvider::ResourceId resource_id() const {
30 DCHECK(mode_ == RESOURCE_MODE);
31 DCHECK(resource_);
32 return resource_->id();
35 gfx::Size resource_size() const {
36 DCHECK(mode_ == RESOURCE_MODE);
37 DCHECK(resource_);
38 return resource_->size();
41 SkColor solid_color() const {
42 DCHECK(mode_ == SOLID_COLOR_MODE);
43 return solid_color_;
46 bool contents_swizzled() const {
47 DCHECK(resource_);
48 return !PlatformColor::SameComponentOrder(resource_->format());
51 bool requires_resource() const {
52 return mode_ == RESOURCE_MODE || mode_ == PICTURE_PILE_MODE;
55 inline bool has_resource() const { return !!resource_; }
57 void SetSolidColorForTesting(SkColor color) { set_solid_color(color); }
58 void SetResourceForTesting(scoped_ptr<ScopedResource> resource) {
59 resource_ = resource.Pass();
62 void AsValueInto(base::debug::TracedValue* state) const;
64 private:
65 friend class Tile;
66 friend class TileManager;
68 void set_use_resource() { mode_ = RESOURCE_MODE; }
70 void set_solid_color(const SkColor& color) {
71 mode_ = SOLID_COLOR_MODE;
72 solid_color_ = color;
75 void set_rasterize_on_demand() { mode_ = PICTURE_PILE_MODE; }
77 Mode mode_;
78 SkColor solid_color_;
79 scoped_ptr<ScopedResource> resource_;
82 } // namespace cc
84 #endif // CC_RESOURCES_TILE_DRAW_INFO_H_