Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1408)

Unified Diff: cc/resources/tile_draw_info.h

Issue 793573006: Refactoring for merging ManagedTileState into Tile. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix a nit Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/resources/tile.cc ('k') | cc/resources/tile_draw_info.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/tile_draw_info.h
diff --git a/cc/resources/tile_draw_info.h b/cc/resources/tile_draw_info.h
new file mode 100644
index 0000000000000000000000000000000000000000..2abf93c34390261b7d92b55054c80ecb237c51ca
--- /dev/null
+++ b/cc/resources/tile_draw_info.h
@@ -0,0 +1,80 @@
+// 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.
+
+#ifndef CC_RESOURCES_TILE_DRAW_INFO_H_
+#define CC_RESOURCES_TILE_DRAW_INFO_H_
+
+#include "base/debug/trace_event_argument.h"
+#include "base/memory/scoped_ptr.h"
+#include "cc/resources/platform_color.h"
+#include "cc/resources/resource_provider.h"
+#include "cc/resources/scoped_resource.h"
+#include "cc/resources/tile_task_runner.h"
+
+namespace cc {
+
+// This class holds all the state relevant to drawing a tile.
+class CC_EXPORT TileDrawInfo {
+ public:
+ enum Mode { RESOURCE_MODE, SOLID_COLOR_MODE, PICTURE_PILE_MODE };
+
+ TileDrawInfo();
+ ~TileDrawInfo();
+
+ Mode mode() const { return mode_; }
+
+ bool IsReadyToDraw() const;
+
+ ResourceProvider::ResourceId get_resource_id() const {
+ DCHECK(mode_ == RESOURCE_MODE);
+ DCHECK(resource_);
+
+ return resource_->id();
+ }
+
+ SkColor get_solid_color() const {
+ DCHECK(mode_ == SOLID_COLOR_MODE);
+
+ return solid_color_;
+ }
+
+ bool contents_swizzled() const {
+ DCHECK(resource_);
+ return !PlatformColor::SameComponentOrder(resource_->format());
+ }
+
+ bool requires_resource() const {
+ return mode_ == RESOURCE_MODE || mode_ == PICTURE_PILE_MODE;
+ }
+
+ inline bool has_resource() const { return !!resource_; }
+
+ void SetSolidColorForTesting(SkColor color) { set_solid_color(color); }
+ void SetResourceForTesting(scoped_ptr<ScopedResource> resource) {
+ resource_ = resource.Pass();
+ }
+
+ void AsValueInto(base::debug::TracedValue* state) const;
+
+ private:
+ friend class Tile;
+ friend class TileManager;
+
+ void set_use_resource() { mode_ = RESOURCE_MODE; }
+
+ void set_solid_color(const SkColor& color) {
+ mode_ = SOLID_COLOR_MODE;
+ solid_color_ = color;
+ }
+
+ void set_rasterize_on_demand() { mode_ = PICTURE_PILE_MODE; }
+
+ Mode mode_;
+ SkColor solid_color_;
+ scoped_ptr<ScopedResource> resource_;
+};
+
+} // namespace cc
+
+#endif // CC_RESOURCES_TILE_DRAW_INFO_H_
« no previous file with comments | « cc/resources/tile.cc ('k') | cc/resources/tile_draw_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698