| 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..3c45bbf1ec03303bc2441941d020e184f28bd38d
|
| --- /dev/null
|
| +++ b/ui/android/resources/ui_resource_android.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 "ui/android/resources/ui_resource_android.h"
|
| +
|
| +#include "base/logging.h"
|
| +#include "content/public/browser/android/ui_resource_provider.h"
|
| +
|
| +namespace ui {
|
| +namespace android {
|
| +
|
| +scoped_ptr<UIResourceAndroid> UIResourceAndroid::CreateFromJavaBitmap(
|
| + content::UIResourceProvider* provider,
|
| + jobject bitmap_object) {
|
| + if (!bitmap_object)
|
| + 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 android
|
| +} // namespace ui
|
|
|