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

Unified Diff: content/browser/android/ui_resource_android_impl.cc

Issue 731133002: Upstream ResourceManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply David's comments Created 6 years, 1 month 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_android_impl.cc
diff --git a/content/browser/android/ui_resource_android_impl.cc b/content/browser/android/ui_resource_android_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7cd651fc3a1686d60a5c14ef7dc7566ec85b8177
--- /dev/null
+++ b/content/browser/android/ui_resource_android_impl.cc
@@ -0,0 +1,62 @@
+// 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.
+
+#include "content/browser/android/ui_resource_android_impl.h"
+
+#include "base/logging.h"
+#include "content/public/browser/android/ui_resource_provider.h"
+
+namespace content {
+
+scoped_ptr<UIResourceAndroidImpl> UIResourceAndroidImpl::CreateFromJavaBitmap(
+ content::UIResourceProvider* provider,
+ jobject bitmap_object) {
+ if (!bitmap_object)
+ return make_scoped_ptr(new UIResourceAndroidImpl(provider, SkBitmap()));
+
+ const gfx::JavaBitmap java_bitmap_lock(bitmap_object);
+ return UIResourceAndroidImpl::CreateFromJavaBitmap(provider,
+ java_bitmap_lock);
+}
+
+scoped_ptr<UIResourceAndroidImpl> UIResourceAndroidImpl::CreateFromJavaBitmap(
+ content::UIResourceProvider* provider,
+ const gfx::JavaBitmap& java_bitmap) {
+ SkBitmap skbitmap = gfx::CreateSkBitmapFromJavaBitmap(java_bitmap);
+ skbitmap.setImmutable();
+
+ return make_scoped_ptr(new UIResourceAndroidImpl(provider, skbitmap));
+}
+
+UIResourceAndroidImpl::~UIResourceAndroidImpl() {
+ if (id_ && provider_)
+ provider_->DeleteUIResource(id_);
+}
+
+cc::UIResourceBitmap UIResourceAndroidImpl::GetBitmap(cc::UIResourceId uid,
+ bool resource_lost) {
+ DCHECK(!bitmap_.empty());
+ return cc::UIResourceBitmap(bitmap_);
+}
+
+cc::UIResourceId UIResourceAndroidImpl::id() {
+ if (id_)
+ return id_;
+ if (!provider_ || bitmap_.empty())
+ return 0;
+ id_ = provider_->CreateUIResource(this);
+ return id_;
+}
+
+void UIResourceAndroidImpl::UIResourceIsInvalid() {
+ id_ = 0;
+}
+
+UIResourceAndroidImpl::UIResourceAndroidImpl(
+ content::UIResourceProvider* provider,
+ const SkBitmap& skbitmap)
+ : provider_(provider), bitmap_(skbitmap), id_(0) {
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698