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

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: Rebase 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
« no previous file with comments | « ui/android/resources/ui_resource_android.h ('k') | ui/android/ui_android.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
12 scoped_ptr<UIResourceAndroid> UIResourceAndroid::CreateFromJavaBitmap(
13 content::UIResourceProvider* provider,
14 const gfx::JavaBitmap& java_bitmap) {
15 SkBitmap skbitmap = gfx::CreateSkBitmapFromJavaBitmap(java_bitmap);
16 skbitmap.setImmutable();
17
18 return make_scoped_ptr(new UIResourceAndroid(provider, skbitmap));
19 }
20
21 UIResourceAndroid::~UIResourceAndroid() {
22 if (id_ && provider_)
23 provider_->DeleteUIResource(id_);
24 }
25
26 cc::UIResourceBitmap UIResourceAndroid::GetBitmap(cc::UIResourceId uid,
27 bool resource_lost) {
28 DCHECK(!bitmap_.empty());
29 return cc::UIResourceBitmap(bitmap_);
30 }
31
32 cc::UIResourceId UIResourceAndroid::id() {
33 if (id_)
34 return id_;
35 if (!provider_ || bitmap_.empty())
36 return 0;
37 id_ = provider_->CreateUIResource(this);
38 return id_;
39 }
40
41 void UIResourceAndroid::UIResourceIsInvalid() {
42 id_ = 0;
43 }
44
45 UIResourceAndroid::UIResourceAndroid(content::UIResourceProvider* provider,
46 const SkBitmap& skbitmap)
47 : provider_(provider), bitmap_(skbitmap), id_(0) {
48 }
49
50 } // namespace ui
OLDNEW
« no previous file with comments | « ui/android/resources/ui_resource_android.h ('k') | ui/android/ui_android.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698