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

Unified Diff: ui/android/resources/ui_resource_android.cc

Issue 731133002: Upstream ResourceManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename namespace 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: ui/android/resources/ui_resource_android.cc
diff --git a/ui/android/resources/ui_resource_android.cc b/ui/android/resources/ui_resource_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5ea929b066a4e4bf7eab0308ae752f2d7a3f0c79
--- /dev/null
+++ b/ui/android/resources/ui_resource_android.cc
@@ -0,0 +1,60 @@
+// 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 "ui/android/resources/ui_resource_android.h"
+
+#include "base/logging.h"
no sievers 2014/12/02 00:25:06 nit: unused
Jaekyun Seok (inactive) 2014/12/02 03:13:13 DCHECK requires this.
+#include "content/public/browser/android/ui_resource_provider.h"
+
+namespace ui {
+
+scoped_ptr<UIResourceAndroid> UIResourceAndroid::CreateFromJavaBitmap(
+ content::UIResourceProvider* provider,
+ jobject bitmap_object) {
+ if (!bitmap_object)
no sievers 2014/12/02 00:25:06 Why do we need to handle this? Should it be DCHECK
Jaekyun Seok (inactive) 2014/12/02 03:13:12 This method isn't used at all. I will remove it.
+ return make_scoped_ptr(new UIResourceAndroid(provider, SkBitmap()));
+
+ const gfx::JavaBitmap java_bitmap_lock(bitmap_object);
+ return UIResourceAndroid::CreateFromJavaBitmap(provider, java_bitmap_lock);
+}
+
+scoped_ptr<UIResourceAndroid> UIResourceAndroid::CreateFromJavaBitmap(
+ content::UIResourceProvider* provider,
+ const gfx::JavaBitmap& java_bitmap) {
+ SkBitmap skbitmap = gfx::CreateSkBitmapFromJavaBitmap(java_bitmap);
+ skbitmap.setImmutable();
+
+ return make_scoped_ptr(new UIResourceAndroid(provider, skbitmap));
+}
+
+UIResourceAndroid::~UIResourceAndroid() {
+ if (id_ && provider_)
+ provider_->DeleteUIResource(id_);
+}
+
+cc::UIResourceBitmap UIResourceAndroid::GetBitmap(cc::UIResourceId uid,
+ bool resource_lost) {
+ DCHECK(!bitmap_.empty());
+ return cc::UIResourceBitmap(bitmap_);
+}
+
+cc::UIResourceId UIResourceAndroid::id() {
+ if (id_)
+ return id_;
+ if (!provider_ || bitmap_.empty())
+ return 0;
+ id_ = provider_->CreateUIResource(this);
+ return id_;
+}
+
+void UIResourceAndroid::UIResourceIsInvalid() {
+ id_ = 0;
+}
+
+UIResourceAndroid::UIResourceAndroid(content::UIResourceProvider* provider,
+ const SkBitmap& skbitmap)
+ : provider_(provider), bitmap_(skbitmap), id_(0) {
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698