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

Unified Diff: content/browser/android/ui_resource_provider_impl.h

Issue 287593002: android: content::UIResourceProvider and content::UIResourceClientAndroid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: user->listener Created 6 years, 7 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: 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..67eda4b2e7c08ef86d6c440748f16201d844af2d
--- /dev/null
+++ b/content/browser/android/ui_resource_provider_impl.h
@@ -0,0 +1,82 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
David Trainor- moved to gerrit 2014/05/13 20:38:00 2014 here and all files
powei 2014/05/13 23:38:03 Done.
+// 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();
+
+ 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
David Trainor- moved to gerrit 2014/05/13 20:38:00 We release the resource right after building it?
powei 2014/05/13 23:38:03 See comment in cpp.
+ // 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|.
David Trainor- moved to gerrit 2014/05/13 20:38:00 :( copies so sad for large thumbnails...
+ // 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;
+
+ 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_

Powered by Google App Engine
This is Rietveld 408576698