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"
17 // This class holds all the state relevant to drawing a tile.
18 class CC_EXPORT TileDrawInfo
{
20 enum Mode
{ RESOURCE_MODE
, SOLID_COLOR_MODE
, OOM_MODE
};
25 Mode
mode() const { return mode_
; }
27 bool IsReadyToDraw() const {
31 case SOLID_COLOR_MODE
:
38 bool NeedsRaster() const {
42 case SOLID_COLOR_MODE
:
51 ResourceId
resource_id() const {
52 DCHECK(mode_
== RESOURCE_MODE
);
54 return resource_
->id();
57 gfx::Size
resource_size() const {
58 DCHECK(mode_
== RESOURCE_MODE
);
60 return resource_
->size();
63 SkColor
solid_color() const {
64 DCHECK(mode_
== SOLID_COLOR_MODE
);
68 bool contents_swizzled() const {
70 return !PlatformColor::SameComponentOrder(resource_
->format());
73 bool requires_resource() const {
74 return mode_
== RESOURCE_MODE
|| mode_
== OOM_MODE
;
77 inline bool has_resource() const { return !!resource_
; }
79 void SetSolidColorForTesting(SkColor color
) { set_solid_color(color
); }
80 void SetResourceForTesting(scoped_ptr
<ScopedResource
> resource
) {
81 resource_
= resource
.Pass();
84 void AsValueInto(base::trace_event::TracedValue
* state
) const;
88 friend class TileManager
;
90 void set_use_resource() { mode_
= RESOURCE_MODE
; }
92 void set_solid_color(const SkColor
& color
) {
93 mode_
= SOLID_COLOR_MODE
;
97 void set_oom() { mode_
= OOM_MODE
; }
100 SkColor solid_color_
;
101 scoped_ptr
<ScopedResource
> resource_
;
106 #endif // CC_TILES_TILE_DRAW_INFO_H_