summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorjdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-08 18:12:05 +0000
committerjdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-08 18:12:05 +0000
commit420c7d0513bf76da520bc2b8987d634b5579a824 (patch)
tree53c71fe658765d5b61701554d224876baf20834c /ui
parent2c8f5285e1081a5a438d9917524c30d4b0b9042a (diff)
downloadchromium_src-420c7d0513bf76da520bc2b8987d634b5579a824.zip
chromium_src-420c7d0513bf76da520bc2b8987d634b5579a824.tar.gz
chromium_src-420c7d0513bf76da520bc2b8987d634b5579a824.tar.bz2
Revert of Revert of [Android] Use UIResource for overscroll glow (https://codereview.chromium.org/454863003/)
Reason for revert: The ToT builder failures appear to be unrelated to this change, and the upstream instrumentation already exercise these code paths. Tentatively reverting the revert and will keep an eye on downstream rolls. Original issue's description: > Revert of [Android] Use UIResource for overscroll glow (https://codereview.chromium.org/422013003/) > > Reason for revert: > This is breaking chrome ToT downstream and the change quie complex so > I don't feel qualified to try to fix it in place. > > The failure we hit is > F/chromium( 2961): [FATAL:system_ui_resource_manager_impl.cc(35)] Check failed: !bitmap.empty(). > > See an example of a failed run in > https://uberchromegw.corp.google.com/i/clank.tot/builders/instrumentation-yakju-clankium-tot/builds/32007 > > (but just trying to boot clank with this patch will trigger it) > > > Original issue's description: > > [Android] Use UIResource for overscroll glow > > > > Introduce a SystemUIResourceManager class for loading and providing access to > > shared UIResourceId's. Wire this class to the existing OverscrollGlow effect, > > using the shared id's with a UIResourceLayer for both glow and edge layers. > > > > This patch is a subset of powei@'s original SystemUIResource patch found at > > https://codereview.chromium.org/377013002/. > > > > BUG=326326 > > > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=288095 > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=288330 TBR=aelias@chromium.org,powei@chromium.org,yfriedman@chromium.org,sky@chromium.org,miguelg@chromium.org NOTREECHECKS=true NOTRY=true BUG=326326 Review URL: https://codereview.chromium.org/454113002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288392 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/base/BUILD.gn1
-rw-r--r--ui/base/android/system_ui_resource_manager.h41
-rw-r--r--ui/base/android/window_android_compositor.h2
-rw-r--r--ui/base/ui_base.gyp1
-rw-r--r--ui/gfx/android/java_bitmap.cc32
-rw-r--r--ui/gfx/android/java_bitmap.h12
6 files changed, 72 insertions, 17 deletions
diff --git a/ui/base/BUILD.gn b/ui/base/BUILD.gn
index ddadf1b..76dcaa4 100644
--- a/ui/base/BUILD.gn
+++ b/ui/base/BUILD.gn
@@ -21,6 +21,7 @@ component("base") {
"accelerators/platform_accelerator.h",
"accelerators/platform_accelerator_cocoa.h",
"accelerators/platform_accelerator_cocoa.mm",
+ "android/system_ui_resource_manager.h",
"android/ui_base_jni_registrar.cc",
"android/ui_base_jni_registrar.h",
"android/view_android.cc",
diff --git a/ui/base/android/system_ui_resource_manager.h b/ui/base/android/system_ui_resource_manager.h
new file mode 100644
index 0000000..03a112d
--- /dev/null
+++ b/ui/base/android/system_ui_resource_manager.h
@@ -0,0 +1,41 @@
+// 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 UI_BASE_ANDROID_SYSTEM_UI_RESOURCE_MANAGER_H_
+#define UI_BASE_ANDROID_SYSTEM_UI_RESOURCE_MANAGER_H_
+
+#include "cc/resources/ui_resource_client.h"
+#include "ui/base/ui_base_export.h"
+
+namespace ui {
+
+// Interface for loading and accessing shared system UI resources.
+class UI_BASE_EXPORT SystemUIResourceManager {
+ public:
+ enum ResourceType {
+ OVERSCROLL_EDGE = 0,
+ OVERSCROLL_GLOW,
+ RESOURCE_TYPE_FIRST = OVERSCROLL_EDGE,
+ RESOURCE_TYPE_LAST = OVERSCROLL_GLOW
+ };
+
+ virtual ~SystemUIResourceManager() {}
+
+ // Optionally trigger bitmap loading for a given |resource|, if necessary.
+ // Note that this operation may be asynchronous, and subsequent queries to
+ // |GetUIResourceId()| will yield a valid result only after loading finishes.
+ // This method is particularly useful for idly loading a resource before an
+ // explicit cc::UIResourceId is required. Repeated calls will be ignored.
+ virtual void PreloadResource(ResourceType resource) = 0;
+
+ // Return the resource id associated with |resource|. If loading hasn't yet
+ // begun for the given |resource|, it will be triggered immediately. If
+ // loading is asynchronous, 0 will be returned until loading has finished, and
+ // the caller is responsible for re-querying until a valid id is returned.
+ virtual cc::UIResourceId GetUIResourceId(ResourceType resource) = 0;
+};
+
+} // namespace ui
+
+#endif // UI_BASE_ANDROID_SYSTEM_UI_RESOURCE_MANAGER_H_
diff --git a/ui/base/android/window_android_compositor.h b/ui/base/android/window_android_compositor.h
index eb55a7b..eee3357 100644
--- a/ui/base/android/window_android_compositor.h
+++ b/ui/base/android/window_android_compositor.h
@@ -6,6 +6,7 @@
#define UI_BASE_ANDROID_WINDOW_ANDROID_COMPOSITOR_H_
#include "cc/output/copy_output_request.h"
+#include "ui/base/android/system_ui_resource_manager.h"
#include "ui/base/ui_base_export.h"
namespace cc {
@@ -25,6 +26,7 @@ class UI_BASE_EXPORT WindowAndroidCompositor {
virtual void OnVSync(base::TimeTicks frame_time,
base::TimeDelta vsync_period) = 0;
virtual void SetNeedsAnimate() = 0;
+ virtual SystemUIResourceManager& GetSystemUIResourceManager() = 0;
};
} // namespace ui
diff --git a/ui/base/ui_base.gyp b/ui/base/ui_base.gyp
index 6e6a316..887e8e4 100644
--- a/ui/base/ui_base.gyp
+++ b/ui/base/ui_base.gyp
@@ -47,6 +47,7 @@
'accelerators/platform_accelerator.h',
'accelerators/platform_accelerator_cocoa.h',
'accelerators/platform_accelerator_cocoa.mm',
+ 'android/system_ui_resource_manager.h',
'android/ui_base_jni_registrar.cc',
'android/ui_base_jni_registrar.h',
'android/view_android.cc',
diff --git a/ui/gfx/android/java_bitmap.cc b/ui/gfx/android/java_bitmap.cc
index 5988befe..d1f644f 100644
--- a/ui/gfx/android/java_bitmap.cc
+++ b/ui/gfx/android/java_bitmap.cc
@@ -9,6 +9,7 @@
#include "base/android/jni_string.h"
#include "base/logging.h"
#include "jni/BitmapHelper_jni.h"
+#include "skia/ext/image_operations.h"
#include "ui/gfx/size.h"
using base::android::AttachCurrentThread;
@@ -68,17 +69,6 @@ ScopedJavaLocalRef<jobject> CreateJavaBitmap(int width,
AttachCurrentThread(), width, height, java_bitmap_config);
}
-ScopedJavaLocalRef<jobject> CreateJavaBitmapFromAndroidResource(
- const char* name,
- gfx::Size size) {
- DCHECK(name);
- DCHECK(!size.IsEmpty());
- JNIEnv* env = AttachCurrentThread();
- ScopedJavaLocalRef<jstring> jname(ConvertUTF8ToJavaString(env, name));
- return Java_BitmapHelper_decodeDrawableResource(
- env, jname.obj(), size.width(), size.height());
-}
-
ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(const SkBitmap* skbitmap) {
DCHECK(skbitmap);
DCHECK(!skbitmap->isNull());
@@ -96,6 +86,26 @@ ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(const SkBitmap* skbitmap) {
return jbitmap;
}
+SkBitmap CreateSkBitmapFromAndroidResource(const char* name, gfx::Size size) {
+ DCHECK(name);
+ DCHECK(!size.IsEmpty());
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jstring> jname(ConvertUTF8ToJavaString(env, name));
+ base::android::ScopedJavaLocalRef<jobject> jobj =
+ Java_BitmapHelper_decodeDrawableResource(
+ env, jname.obj(), size.width(), size.height());
+
+ if (jobj.is_null())
+ return SkBitmap();
+
+ SkBitmap bitmap = CreateSkBitmapFromJavaBitmap(gfx::JavaBitmap(jobj.obj()));
+ if (bitmap.isNull())
+ return bitmap;
+
+ return skia::ImageOperations::Resize(
+ bitmap, skia::ImageOperations::RESIZE_BOX, size.width(), size.height());
+}
+
SkBitmap CreateSkBitmapFromJavaBitmap(const JavaBitmap& jbitmap) {
// TODO(jdduke): Convert to DCHECK's when sufficient data has been capture for
// crbug.com/341406.
diff --git a/ui/gfx/android/java_bitmap.h b/ui/gfx/android/java_bitmap.h
index befb09b..34cd26a 100644
--- a/ui/gfx/android/java_bitmap.h
+++ b/ui/gfx/android/java_bitmap.h
@@ -57,12 +57,12 @@ GFX_EXPORT base::android::ScopedJavaLocalRef<jobject> CreateJavaBitmap(
int height,
SkColorType color_type);
-// Loads a Java-backed bitmap (android.graphics.Bitmap) from the provided
-// drawable resource identifier (e.g., android:drawable/overscroll_glow). If the
-// resource loads successfully, it will be integrally scaled down, preserving
-// aspect ratio, to a size no smaller than |size|. Otherwise, null is returned.
-GFX_EXPORT base::android::ScopedJavaLocalRef<jobject>
- CreateJavaBitmapFromAndroidResource(const char* name, gfx::Size size);
+// Loads an SkBitmap from the provided drawable resource identifier (e.g.,
+// android:drawable/overscroll_glow). If the resource loads successfully, it
+// will be integrally scaled down, preserving aspect ratio, to a size no smaller
+// than |size|. Otherwise, an empty bitmap is returned.
+GFX_EXPORT SkBitmap
+ CreateSkBitmapFromAndroidResource(const char* name, gfx::Size size);
// Converts |skbitmap| to a Java-backed bitmap (android.graphics.Bitmap).
// Note: |skbitmap| is assumed to be non-null, non-empty and one of RGBA_8888 or