| 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_
|
|
|