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

Side by Side Diff: content/browser/android/transient_ui_resource.cc

Issue 143803004: android: Migrate old content readback to use async readback (and delegated renderer) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 6 years, 10 months 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 2013 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/transient_ui_resource.h"
6
7 #include "base/basictypes.h"
8 #include "base/bind.h"
9 #include "cc/resources/ui_resource_bitmap.h"
10 #include "cc/trees/layer_tree_host.h"
11 #include "third_party/skia/include/core/SkBitmap.h"
12
13 namespace content {
14
15 scoped_ptr<TransientUIResource> TransientUIResource::Create(
16 cc::LayerTreeHost* host,
17 const cc::UIResourceBitmap& bitmap) {
18 return make_scoped_ptr(new TransientUIResource(host, bitmap));
19 }
20
21 TransientUIResource::TransientUIResource(cc::LayerTreeHost* host,
22 const cc::UIResourceBitmap& bitmap)
23 : bitmap_(new cc::UIResourceBitmap(bitmap)), host_(host) {
24 DCHECK(host_);
25 id_ = host_->CreateUIResource(this);
26 }
27
28 // User must make sure that host is still valid before this object goes out of
29 // scope.
30 TransientUIResource::~TransientUIResource() {
31 if (id_) {
32 DCHECK(host_);
33 host_->DeleteUIResource(id_);
34 }
35 }
36
37 cc::UIResourceBitmap TransientUIResource::GetBitmap(cc::UIResourceId uid,
38 bool resource_lost) {
39 if (bitmap_) {
40 cc::UIResourceBitmap out_bitmap = *bitmap_.get();
41 // Frees the bitmap after it's been accessed.
42 bitmap_.reset();
43 return out_bitmap;
44 }
45
46 SkBitmap place_holder;
47 place_holder.setConfig(SkBitmap::kARGB_8888_Config, 1, 1);
48 place_holder.allocPixels();
49 place_holder.setImmutable();
50 return cc::UIResourceBitmap(place_holder);
51 }
52
53 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698