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

Unified Diff: cc/tile_drawing_info.h

Issue 12353003: cc: Refactored Tile::GetResourceId (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months 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
Index: cc/tile_drawing_info.h
diff --git a/cc/tile_drawing_info.h b/cc/tile_drawing_info.h
new file mode 100644
index 0000000000000000000000000000000000000000..cec460813aea697ac02e2c33a5f15e2841f84c00
--- /dev/null
+++ b/cc/tile_drawing_info.h
@@ -0,0 +1,78 @@
+// found in the LICENSE file.
+
+#ifndef CC_TILE_DRAWING_INFO_H_
+#define CC_TILE_DRAWING_INFO_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "cc/resource_pool.h"
+#include "cc/resource_provider.h"
+
+namespace cc {
+
+class TileManager;
+class ManagedTileState;
+
+class CC_EXPORT TileDrawingInfo {
nduca 2013/03/12 19:44:34 Maybe you should instead pull ManagedTileState out
reveman 2013/03/12 21:54:41 I like this idea. tile.h wouldn't have to include
+ public:
+ enum Mode {
+ TEXTURE_MODE,
+ SOLID_COLOR_MODE,
+ TRANSPARENT_MODE,
nduca 2013/03/12 19:44:34 Yeah, basically I see this as a inner struct on Ma
+ PICTURE_PILE_MODE,
+ NUM_MODES
+ };
+
+ TileDrawingInfo()
+ : mode_(TEXTURE_MODE),
+ resource_is_being_initialized_(false),
+ can_be_freed_(true),
+ contents_swizzled_(false) {}
+
+ Mode mode() const {
+ return mode_;
+ }
+
+ bool IsReadyToDraw() const;
+
+ ResourceProvider::ResourceId get_resource_id() const {
+ DCHECK(mode_ == TEXTURE_MODE);
+ DCHECK(resource_);
+ DCHECK(!resource_is_being_initialized_);
+ return resource_->id();
+ }
+
+ SkColor get_solid_color() const {
+ DCHECK(mode_ == SOLID_COLOR_MODE);
+
+ return solid_color_;
+ }
+
+ bool contents_swizzled() const {
+ return contents_swizzled_;
+ }
+
+ private:
+ friend class TileManager;
+ friend class ManagedTileState;
+
+ void set_transparent() {
+ mode_ = TRANSPARENT_MODE;
+ }
+
+ void set_solid_color(const SkColor& color) {
+ mode_ = SOLID_COLOR_MODE;
+ solid_color_ = color;
+ }
+
+ Mode mode_;
+ SkColor solid_color_;
+
+ scoped_ptr<ResourcePool::Resource> resource_;
+ bool resource_is_being_initialized_;
+ bool can_be_freed_;
+ bool contents_swizzled_;
+};
+
+} // namespace cc
+
+#endif // CC_TILE_DRAWING_INFO_H_

Powered by Google App Engine
This is Rietveld 408576698