summaryrefslogtreecommitdiff
path: root/chromium/cc/resources/ui_resource_bitmap.h
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@digia.com>2013-08-15 21:46:11 +0200
committerZeno Albisser <zeno.albisser@digia.com>2013-08-15 21:46:11 +0200
commit679147eead574d186ebf3069647b4c23e8ccace6 (patch)
treefc247a0ac8ff119f7c8550879ebb6d3dd8d1ff69 /chromium/cc/resources/ui_resource_bitmap.h
downloadqtwebengine-chromium-679147eead574d186ebf3069647b4c23e8ccace6.tar.gz
Initial import.
Diffstat (limited to 'chromium/cc/resources/ui_resource_bitmap.h')
-rw-r--r--chromium/cc/resources/ui_resource_bitmap.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/chromium/cc/resources/ui_resource_bitmap.h b/chromium/cc/resources/ui_resource_bitmap.h
new file mode 100644
index 00000000000..dbf70690792
--- /dev/null
+++ b/chromium/cc/resources/ui_resource_bitmap.h
@@ -0,0 +1,50 @@
+// 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_BITMAP_H_
+#define CC_RESOURCES_UI_RESOURCE_BITMAP_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "cc/base/cc_export.h"
+#include "third_party/skia/include/core/SkTypes.h"
+#include "ui/gfx/size.h"
+
+namespace cc {
+
+// Ref-counted bitmap class (can’t use SkBitmap because of ETC1). Thread-safety
+// ensures that both main and impl threads can hold references to the bitmap and
+// that asynchronous uploads are allowed.
+class CC_EXPORT UIResourceBitmap
+ : public base::RefCountedThreadSafe<UIResourceBitmap> {
+ public:
+ enum UIResourceFormat {
+ RGBA8
+ };
+
+ // Takes ownership of “pixels”.
+ static scoped_refptr<UIResourceBitmap> Create(uint8_t* pixels,
+ UIResourceFormat format,
+ gfx::Size size);
+
+ gfx::Size GetSize() const { return size_; }
+ UIResourceFormat GetFormat() const { return format_; }
+ uint8_t* GetPixels() { return pixels_.get(); }
+
+ private:
+ friend class base::RefCountedThreadSafe<UIResourceBitmap>;
+
+ UIResourceBitmap();
+ ~UIResourceBitmap();
+
+ scoped_ptr<uint8_t[]> pixels_;
+ UIResourceFormat format_;
+ gfx::Size size_;
+
+ DISALLOW_COPY_AND_ASSIGN(UIResourceBitmap);
+};
+
+} // namespace cc
+
+#endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_