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

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

Issue 41903003: cc: Fix incomplete changes to add ETC1 support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased and moved pixel ref class to public cc Created 7 years, 1 month 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/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "cc/resources/etc1_pixel_ref.h"
9 #include "third_party/skia/include/core/SkBitmap.h" 10 #include "third_party/skia/include/core/SkBitmap.h"
11 #include "third_party/skia/include/core/SkPixelRef.h"
10 12
11 namespace cc { 13 namespace cc {
12 14
13 void UIResourceBitmap::Create(const skia::RefPtr<SkPixelRef>& pixel_ref, 15 void UIResourceBitmap::Create(const skia::RefPtr<SkPixelRef>& pixel_ref,
14 UIResourceFormat format, 16 UIResourceFormat format,
15 gfx::Size size) { 17 gfx::Size size) {
16 DCHECK(size.width()); 18 DCHECK(size.width());
17 DCHECK(size.height()); 19 DCHECK(size.height());
18 DCHECK(pixel_ref); 20 DCHECK(pixel_ref);
19 DCHECK(pixel_ref->isImmutable()); 21 DCHECK(pixel_ref->isImmutable());
(...skipping 12 matching lines...) Expand all
32 DCHECK(skbitmap.isImmutable()); 34 DCHECK(skbitmap.isImmutable());
33 35
34 skia::RefPtr<SkPixelRef> pixel_ref = skia::SharePtr(skbitmap.pixelRef()); 36 skia::RefPtr<SkPixelRef> pixel_ref = skia::SharePtr(skbitmap.pixelRef());
35 Create(pixel_ref, 37 Create(pixel_ref,
36 UIResourceBitmap::RGBA8, 38 UIResourceBitmap::RGBA8,
37 gfx::Size(skbitmap.width(), skbitmap.height())); 39 gfx::Size(skbitmap.width(), skbitmap.height()));
38 40
39 SetOpaque(skbitmap.isOpaque()); 41 SetOpaque(skbitmap.isOpaque());
40 } 42 }
41 43
42 UIResourceBitmap::UIResourceBitmap(const skia::RefPtr<SkPixelRef>& pixel_ref, 44 UIResourceBitmap::UIResourceBitmap(
43 UIResourceFormat format, 45 const skia::RefPtr<ETC1PixelRef>& etc1_pixel_ref,
44 gfx::Size size) { 46 gfx::Size size) {
45 Create(pixel_ref, format, size); 47 Create(etc1_pixel_ref, ETC1, size);
46 } 48 }
47 49
48 UIResourceBitmap::~UIResourceBitmap() {} 50 UIResourceBitmap::~UIResourceBitmap() {}
49 51
50 AutoLockUIResourceBitmap::AutoLockUIResourceBitmap( 52 AutoLockUIResourceBitmap::AutoLockUIResourceBitmap(
51 const UIResourceBitmap& bitmap) : bitmap_(bitmap) { 53 const UIResourceBitmap& bitmap) : bitmap_(bitmap) {
52 bitmap_.pixel_ref_->lockPixels(); 54 bitmap_.pixel_ref_->lockPixels();
53 } 55 }
54 56
55 AutoLockUIResourceBitmap::~AutoLockUIResourceBitmap() { 57 AutoLockUIResourceBitmap::~AutoLockUIResourceBitmap() {
56 bitmap_.pixel_ref_->unlockPixels(); 58 bitmap_.pixel_ref_->unlockPixels();
57 } 59 }
58 60
59 const uint8_t* AutoLockUIResourceBitmap::GetPixels() const { 61 const uint8_t* AutoLockUIResourceBitmap::GetPixels() const {
60 return static_cast<const uint8_t*>(bitmap_.pixel_ref_->pixels()); 62 return static_cast<const uint8_t*>(bitmap_.pixel_ref_->pixels());
61 } 63 }
62 64
63 } // namespace cc 65 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698