Chromium Code Reviews| Index: content/browser/android/ui_resource_provider_impl.h |
| diff --git a/content/browser/android/ui_resource_provider_impl.h b/content/browser/android/ui_resource_provider_impl.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5ead3a19e3813417eaecf392704db35087d20a3e |
| --- /dev/null |
| +++ b/content/browser/android/ui_resource_provider_impl.h |
| @@ -0,0 +1,82 @@ |
| +// Copyright 2014 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 CONTENT_BROWSER_ANDROID_UI_RESOURCE_PROVIDER_IMPL_H_ |
| +#define CONTENT_BROWSER_ANDROID_UI_RESOURCE_PROVIDER_IMPL_H_ |
| + |
| +#include <list> |
| + |
| +#include "base/containers/scoped_ptr_hash_map.h" |
| +#include "cc/resources/ui_resource_client.h" |
| +#include "content/public/browser/android/ui_resource_provider.h" |
| + |
| +class SkBitmap; |
| +class SkPixelRef; |
| + |
| +namespace cc { |
| +class LayerTreeHost; |
| +class UIResourceClient; |
| +} |
| + |
| +namespace content { |
| + |
| +class UIResourceListener; |
| + |
| +class UIResourceProviderImpl : public UIResourceProvider { |
| + public: |
| + UIResourceProviderImpl(); |
| + |
| + ~UIResourceProviderImpl(); |
|
no sievers
2014/05/16 20:12:19
nit: virtual
powei
2014/05/19 18:49:46
Done.
|
| + |
| + virtual void SetLayerTreeHost(cc::LayerTreeHost* host) OVERRIDE; |
| + |
| + virtual void AddListener(UIResourceListener* listener) OVERRIDE; |
| + |
| + virtual void RemoveListener(UIResourceListener* listener) OVERRIDE; |
| + |
| + // Generates a UIResource and returns a UIResourceId. |is_transient| |
| + // indicates whether or not to release the resource once the bitmap |
| + // has been uploaded. May return 0. |
| + virtual cc::UIResourceId GenerateUIResource(const SkBitmap& bitmap, |
| + bool is_transient) OVERRIDE; |
| + |
| + // Generates an ETC1 compressed UIResource. See above for |is_transient|. |
| + // May return 0. |
| + virtual cc::UIResourceId GenerateCompressedUIResource( |
| + const skia::RefPtr<SkPixelRef>& pixel_ref, |
| + bool is_transient) OVERRIDE; |
| + |
| + // Same as above method but makes a copy of |pixels|. |
| + // TODO(powei): should be removed once the thumbnail work is in place. |
| + virtual cc::UIResourceId GenerateCompressedUIResource( |
| + const gfx::Size& size, |
| + void* pixels, |
| + bool is_transient) OVERRIDE; |
| + |
| + // Deletes a UIResource. We allow deleting a resource that is not allocated. |
| + virtual void DeleteUIResource(cc::UIResourceId resource_id) OVERRIDE; |
| + |
| + private: |
| + void UIResourcesAreInvalid(); |
| + void RecreateUIResources(); |
| + |
| + cc::UIResourceId GenerateUIResourceFromUIResourceBitmap( |
| + const cc::UIResourceBitmap& bitmap, |
| + bool is_transient); |
| + |
| + typedef base::ScopedPtrHashMap<cc::UIResourceId, cc::UIResourceClient> |
| + UIResourceMap; |
| + typedef std::list<UIResourceListener*> UIResourceListenerList; |
|
no sievers
2014/05/16 20:12:19
Maybe use ObserverList for this?
powei
2014/05/19 18:49:46
Done.
|
| + |
| + UIResourceMap ui_resource_map_; |
| + UIResourceListenerList listeners_; |
| + |
| + cc::LayerTreeHost* host_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(UIResourceProviderImpl); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_ANDROID_UI_RESOURCE_PROVIDER_IMPL_H_ |