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"
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() {
23 provider_
->DeleteUIResource(id_
);
26 cc::UIResourceBitmap
UIResourceAndroid::GetBitmap(cc::UIResourceId uid
,
28 DCHECK(!bitmap_
.empty());
29 return cc::UIResourceBitmap(bitmap_
);
32 cc::UIResourceId
UIResourceAndroid::id() {
35 if (!provider_
|| bitmap_
.empty())
37 id_
= provider_
->CreateUIResource(this);
41 void UIResourceAndroid::UIResourceIsInvalid() {
45 UIResourceAndroid::UIResourceAndroid(ui::UIResourceProvider
* provider
,
46 const SkBitmap
& skbitmap
)
47 : provider_(provider
), bitmap_(skbitmap
), id_(0) {