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

Side by Side Diff: cc/resources/ui_resource_bitmap.cc

Issue 22870016: Update the nine patch layer to use UI resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing and addressing previous comments Created 7 years, 4 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/resources/ui_resource_bitmap.h" 5 #include "cc/resources/ui_resource_bitmap.h"
6 6
7 #include "base/logging.h"
7 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "third_party/skia/include/core/SkBitmap.h"
10 #include "ui/gfx/android/java_bitmap.h"
8 11
9 namespace cc { 12 namespace cc {
10 13
11 scoped_refptr<UIResourceBitmap> 14 scoped_refptr<UIResourceBitmap>
12 UIResourceBitmap::Create(uint8_t* pixels, 15 UIResourceBitmap::Create(uint8_t* pixels,
13 UIResourceFormat format, 16 UIResourceFormat format,
14 gfx::Size size) { 17 gfx::Size size) {
18 // Check for a non-empty bitmap.
19 DCHECK(size.width() && size.height());
20
15 scoped_refptr<UIResourceBitmap> ret = new UIResourceBitmap(); 21 scoped_refptr<UIResourceBitmap> ret = new UIResourceBitmap();
16 ret->pixels_ = scoped_ptr<uint8_t[]>(pixels); 22 ret->pixels_ = scoped_ptr<uint8_t[]>(pixels);
17 ret->format_ = format; 23 ret->format_ = format;
18 ret->size_ = size; 24 ret->size_ = size;
19 25
20 return ret; 26 return ret;
21 } 27 }
22 28
23 UIResourceBitmap::UIResourceBitmap() {} 29 UIResourceBitmap::UIResourceBitmap() {}
30
24 UIResourceBitmap::~UIResourceBitmap() {} 31 UIResourceBitmap::~UIResourceBitmap() {}
25 32
33 scoped_refptr<UIResourceBitmap> CreateUIResourceBitmapFromSkBitmap(
34 const SkBitmap& skbitmap) {
35 DCHECK_EQ(skbitmap.config(), SkBitmap::kARGB_8888_Config);
36
37 gfx::Size size(skbitmap.width(), skbitmap.height());
38 uint8_t* dst_pixels = new uint8_t[size.GetArea() * 4];
39 uint8_t* src_pixels = static_cast<uint8_t*>(skbitmap.getPixels());
40 memcpy(dst_pixels, src_pixels, size.GetArea() * 4);
41 return UIResourceBitmap::Create(dst_pixels, UIResourceBitmap::RGBA8, size);
42 }
43
26 } // namespace cc 44 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698