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

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

Issue 23740010: Revert 223162 "Update the nine patch layer to use UI resources" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
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"
8 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
9 #include "third_party/skia/include/core/SkBitmap.h"
10 8
11 namespace cc { 9 namespace cc {
12 10
13 uint8_t* UIResourceBitmap::GetPixels() const { 11 scoped_refptr<UIResourceBitmap>
14 if (!pixel_ref_) 12 UIResourceBitmap::Create(uint8_t* pixels,
15 return NULL; 13 UIResourceFormat format,
16 return static_cast<uint8_t*>(pixel_ref_->pixels()); 14 UIResourceWrapMode wrap_mode,
15 gfx::Size size) {
16 scoped_refptr<UIResourceBitmap> ret = new UIResourceBitmap();
17 ret->pixels_ = scoped_ptr<uint8_t[]>(pixels);
18 ret->format_ = format;
19 ret->wrap_mode_ = wrap_mode;
20 ret->size_ = size;
21
22 return ret;
17 } 23 }
18 24
19 void UIResourceBitmap::Create(const skia::RefPtr<SkPixelRef>& pixel_ref, 25 UIResourceBitmap::UIResourceBitmap() {}
20 UIResourceFormat format,
21 UIResourceWrapMode wrap_mode,
22 gfx::Size size) {
23 DCHECK(size.width());
24 DCHECK(size.height());
25 DCHECK(pixel_ref);
26 DCHECK(pixel_ref->isImmutable());
27 format_ = format;
28 wrap_mode_ = wrap_mode;
29 size_ = size;
30 pixel_ref_ = pixel_ref;
31 }
32
33 UIResourceBitmap::UIResourceBitmap(const SkBitmap& skbitmap,
34 UIResourceWrapMode wrap_mode) {
35 DCHECK_EQ(skbitmap.config(), SkBitmap::kARGB_8888_Config);
36 DCHECK_EQ(skbitmap.width(), skbitmap.rowBytesAsPixels());
37 DCHECK(skbitmap.isImmutable());
38
39 skia::RefPtr<SkPixelRef> pixel_ref = skia::SharePtr(skbitmap.pixelRef());
40 Create(pixel_ref,
41 UIResourceBitmap::RGBA8,
42 wrap_mode,
43 gfx::Size(skbitmap.width(), skbitmap.height()));
44 }
45
46 UIResourceBitmap::~UIResourceBitmap() {} 26 UIResourceBitmap::~UIResourceBitmap() {}
47 27
48 } // namespace cc 28 } // namespace cc
OLDNEW
« no previous file with comments | « trunk/src/cc/resources/ui_resource_bitmap.h ('k') | trunk/src/cc/resources/ui_resource_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698