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

Side by Side 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: Fix clang build failure Created 6 years 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/android/resources/ui_resource_android.h"
6
7 #include "base/logging.h"
8 #include "content/public/browser/android/ui_resource_provider.h"
9
10 namespace ui {
11 namespace android {
12
13 scoped_ptr<UIResourceAndroid> UIResourceAndroid::CreateFromJavaBitmap(
14 content::UIResourceProvider* provider,
15 jobject bitmap_object) {
16 if (!bitmap_object)
17 return make_scoped_ptr(new UIResourceAndroid(provider, SkBitmap()));
18
19 const gfx::JavaBitmap java_bitmap_lock(bitmap_object);
20 return UIResourceAndroid::CreateFromJavaBitmap(provider, java_bitmap_lock);
21 }
22
23 scoped_ptr<UIResourceAndroid> UIResourceAndroid::CreateFromJavaBitmap(
24 content::UIResourceProvider* provider,
25 const gfx::JavaBitmap& java_bitmap) {
26 SkBitmap skbitmap = gfx::CreateSkBitmapFromJavaBitmap(java_bitmap);
27 skbitmap.setImmutable();
28
29 return make_scoped_ptr(new UIResourceAndroid(provider, skbitmap));
30 }
31
32 UIResourceAndroid::~UIResourceAndroid() {
33 if (id_ && provider_)
34 provider_->DeleteUIResource(id_);
35 }
36
37 cc::UIResourceBitmap UIResourceAndroid::GetBitmap(cc::UIResourceId uid,
38 bool resource_lost) {
39 DCHECK(!bitmap_.empty());
40 return cc::UIResourceBitmap(bitmap_);
41 }
42
43 cc::UIResourceId UIResourceAndroid::id() {
44 if (id_)
45 return id_;
46 if (!provider_ || bitmap_.empty())
47 return 0;
48 id_ = provider_->CreateUIResource(this);
49 return id_;
50 }
51
52 void UIResourceAndroid::UIResourceIsInvalid() {
53 id_ = 0;
54 }
55
56 UIResourceAndroid::UIResourceAndroid(content::UIResourceProvider* provider,
57 const SkBitmap& skbitmap)
58 : provider_(provider), bitmap_(skbitmap), id_(0) {
59 }
60
61 } // namespace android
62 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698