OLD | NEW |
---|---|
(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 "content/browser/android/system_ui_resource.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "cc/resources/ui_resource_bitmap.h" | |
9 #include "content/public/browser/android/ui_resource_provider.h" | |
10 | |
11 namespace content { | |
12 | |
13 scoped_ptr<SystemUIResource> SystemUIResource::Create( | |
14 const SkBitmap& bitmap, | |
15 UIResourceProvider* provider) { | |
16 return make_scoped_ptr(new SystemUIResource(bitmap, provider)); | |
17 } | |
18 | |
19 SystemUIResource::SystemUIResource(const SkBitmap& bitmap, | |
20 UIResourceProvider* provider) | |
21 : bitmap_(bitmap), id_(0), provider_(provider), client_(NULL) { | |
22 DCHECK(provider_); | |
23 Load(); | |
24 } | |
25 | |
26 SystemUIResource::~SystemUIResource() { | |
27 if (id_) | |
28 provider_->DeleteUIResource(id_); | |
29 id_ = 0; | |
30 if (client_) | |
31 client_->OnUIResourceIdChanged(); | |
32 } | |
33 | |
34 cc::UIResourceBitmap SystemUIResource::GetBitmap(cc::UIResourceId uid, | |
35 bool resource_lost) { | |
36 DCHECK(!bitmap_.empty()); | |
37 return cc::UIResourceBitmap(bitmap_); | |
38 } | |
39 | |
40 void SystemUIResource::UIResourceIsInvalid() { | |
41 id_ = 0; | |
jdduke (slow)
2014/07/28 20:45:38
Is early return worthwhile here?
if (!id_)
retu
| |
42 if (client_) | |
43 client_->OnUIResourceIdChanged(); | |
44 } | |
45 | |
46 void SystemUIResource::Load() { | |
47 if (id_) | |
48 return; | |
49 | |
50 id_ = provider_->CreateUIResource(this); | |
51 | |
52 if (client_) | |
53 client_->OnUIResourceIdChanged(); | |
54 } | |
55 | |
56 void SystemUIResource::SetClient(SystemUIResourceClient* client) { | |
57 client_ = client; | |
jdduke (slow)
2014/07/28 20:45:38
What if the client is set after Load has been call
| |
58 } | |
59 | |
60 } // namespace content | |
OLD | NEW |