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

Unified Diff: cc/resources/ui_resource_manager.h

Issue 18191020: UI Resource Manager (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 5 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/resources/ui_resource_manager.h
===================================================================
--- cc/resources/ui_resource_manager.h (revision 0)
+++ cc/resources/ui_resource_manager.h (revision 0)
@@ -0,0 +1,69 @@
+// 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_UI_RESOURCE_MANAGER_H_
+#define CC_RESOURCES_UI_RESOURCE_MANAGER_H_
+
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "skia/ext/refptr.h"
+#include "ui/gfx/size.h"
+
+namespace cc {
+
+typedef int UIResourceId;
+
+class UIResourceManagerClient {
+ public:
+ enum UIResourceStatus {
+ NOT_READY,
+ READY,
+ LOST
+ };
+
+ virtual ~UIResourceManagerClient() {}
+
+ // This is called on the main thread when a recently created resource
+ // has been fully uploaded to a texture. Users of large resources may
+ // wish to wait for this callback before using the resource ID on a layer,
+ // to avoid jank until the upload completes.
+ virtual void UIResourceReady(UIResourceId id) = 0;
+
+ // This id is now invalid. The client is expected to keep track of all
+ // layers that were using it, and change them to stop using it (for
+ // example by calling CreateUIResource and assigning the new id to the
+ // layer).
+ virtual void UIResourceLost(UIResourceId id) = 0;
+};
+
+// Ref-counted bitmap class (can’t use SkBitmap because of ETC1)
+class UIResourceBitmap : public base::RefCountedThreadSafe<UIResourceBitmap> {
+ public:
+ enum UIResourceFormat {
+ RGBA8,
+ ETC1
+ };
+
+ ~UIResourceBitmap();
+
+ // Takes ownership of “pixels”.
+ static scoped_refptr<UIResourceBitmap> Create(void* pixels,
+ UIResourceFormat format,
+ gfx::Size size);
+
+ gfx::Size GetSize() const { return size_; }
+ UIResourceFormat GetFormat() const { return format_; }
+ void* GetPixels() { return pixels_; }
+
+ private:
+ void* pixels_;
+ UIResourceFormat format_;
+ gfx::Size size_;
+};
+
+} // namespace cc
+
+#endif // CC_RESOURCES_UI_RESOURCE_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698