Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / android / resources / ui_resource_android.cc
blobbc85bb88666a50033e24bc5d439c364d9ce7d5ab
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.
5 #include "ui/android/resources/ui_resource_android.h"
7 #include "base/logging.h"
8 #include "ui/android/resources/ui_resource_provider.h"
10 namespace ui {
12 scoped_ptr<UIResourceAndroid> UIResourceAndroid::CreateFromJavaBitmap(
13 ui::UIResourceProvider* provider,
14 const gfx::JavaBitmap& java_bitmap) {
15 SkBitmap skbitmap = gfx::CreateSkBitmapFromJavaBitmap(java_bitmap);
16 skbitmap.setImmutable();
18 return make_scoped_ptr(new UIResourceAndroid(provider, skbitmap));
21 UIResourceAndroid::~UIResourceAndroid() {
22 if (id_ && provider_)
23 provider_->DeleteUIResource(id_);
26 cc::UIResourceBitmap UIResourceAndroid::GetBitmap(cc::UIResourceId uid,
27 bool resource_lost) {
28 DCHECK(!bitmap_.empty());
29 return cc::UIResourceBitmap(bitmap_);
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_;
41 void UIResourceAndroid::UIResourceIsInvalid() {
42 id_ = 0;
45 UIResourceAndroid::UIResourceAndroid(ui::UIResourceProvider* provider,
46 const SkBitmap& skbitmap)
47 : provider_(provider), bitmap_(skbitmap), id_(0) {
50 } // namespace ui