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

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

Issue 377013002: android: Use UIResource for overscroll glow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments Created 6 years, 5 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/system_ui_resource.cc
diff --git a/content/browser/android/system_ui_resource.cc b/content/browser/android/system_ui_resource.cc
new file mode 100644
index 0000000000000000000000000000000000000000..885698d0990035b4fb3cdfa20743cf0cd7f0bf67
--- /dev/null
+++ b/content/browser/android/system_ui_resource.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 "content/browser/android/system_ui_resource.h"
+
+#include "base/logging.h"
+#include "cc/resources/ui_resource_bitmap.h"
+#include "content/public/browser/android/ui_resource_provider.h"
+
+namespace content {
+
+scoped_ptr<SystemUIResource> SystemUIResource::Create(
+ const SkBitmap& bitmap,
+ UIResourceProvider* provider) {
+ return make_scoped_ptr(new SystemUIResource(bitmap, provider));
+}
+
+SystemUIResource::SystemUIResource(const SkBitmap& bitmap,
+ UIResourceProvider* provider)
+ : bitmap_(bitmap), id_(0), provider_(provider), client_(NULL) {
+ DCHECK(provider_);
+ Load();
+}
+
+SystemUIResource::~SystemUIResource() {
+ if (id_)
+ provider_->DeleteUIResource(id_);
+ id_ = 0;
+ if (client_)
+ client_->OnUIResourceIdChanged();
+}
+
+cc::UIResourceBitmap SystemUIResource::GetBitmap(cc::UIResourceId uid,
+ bool resource_lost) {
+ DCHECK(!bitmap_.empty());
+ return cc::UIResourceBitmap(bitmap_);
+}
+
+void SystemUIResource::UIResourceIsInvalid() {
+ id_ = 0;
jdduke (slow) 2014/07/28 20:45:38 Is early return worthwhile here? if (!id_) retu
+ if (client_)
+ client_->OnUIResourceIdChanged();
+}
+
+void SystemUIResource::Load() {
+ if (id_)
+ return;
+
+ id_ = provider_->CreateUIResource(this);
+
+ if (client_)
+ client_->OnUIResourceIdChanged();
+}
+
+void SystemUIResource::SetClient(SystemUIResourceClient* client) {
+ client_ = client;
jdduke (slow) 2014/07/28 20:45:38 What if the client is set after Load has been call
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698