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

Side by Side Diff: ui/gfx/android/java_bitmap.cc

Issue 2823003002: SkBitmap and SkPixelRef no longer need lock/unlock (Closed)
Patch Set: win fix after rebase Created 3 years, 8 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
« no previous file with comments | « ui/compositor/layer_unittest.cc ('k') | ui/gfx/blit_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/gfx/android/java_bitmap.h" 5 #include "ui/gfx/android/java_bitmap.h"
6 6
7 #include <android/bitmap.h> 7 #include <android/bitmap.h>
8 8
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 68
69 ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(const SkBitmap* skbitmap) { 69 ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(const SkBitmap* skbitmap) {
70 DCHECK(skbitmap); 70 DCHECK(skbitmap);
71 DCHECK(!skbitmap->isNull()); 71 DCHECK(!skbitmap->isNull());
72 SkColorType color_type = skbitmap->colorType(); 72 SkColorType color_type = skbitmap->colorType();
73 DCHECK((color_type == kRGB_565_SkColorType) || 73 DCHECK((color_type == kRGB_565_SkColorType) ||
74 (color_type == kN32_SkColorType)); 74 (color_type == kN32_SkColorType));
75 ScopedJavaLocalRef<jobject> jbitmap = CreateJavaBitmap( 75 ScopedJavaLocalRef<jobject> jbitmap = CreateJavaBitmap(
76 skbitmap->width(), skbitmap->height(), color_type); 76 skbitmap->width(), skbitmap->height(), color_type);
77 SkAutoLockPixels src_lock(*skbitmap);
78 JavaBitmap dst_lock(jbitmap); 77 JavaBitmap dst_lock(jbitmap);
79 void* src_pixels = skbitmap->getPixels(); 78 void* src_pixels = skbitmap->getPixels();
80 void* dst_pixels = dst_lock.pixels(); 79 void* dst_pixels = dst_lock.pixels();
81 memcpy(dst_pixels, src_pixels, skbitmap->getSize()); 80 memcpy(dst_pixels, src_pixels, skbitmap->getSize());
82 81
83 return jbitmap; 82 return jbitmap;
84 } 83 }
85 84
86 SkBitmap CreateSkBitmapFromJavaBitmap(const JavaBitmap& jbitmap) { 85 SkBitmap CreateSkBitmapFromJavaBitmap(const JavaBitmap& jbitmap) {
87 DCHECK(!jbitmap.size().IsEmpty()); 86 DCHECK(!jbitmap.size().IsEmpty());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 return kN32_SkColorType; 125 return kN32_SkColorType;
127 case BITMAP_FORMAT_RGB_565: 126 case BITMAP_FORMAT_RGB_565:
128 return kRGB_565_SkColorType; 127 return kRGB_565_SkColorType;
129 case BITMAP_FORMAT_NO_CONFIG: 128 case BITMAP_FORMAT_NO_CONFIG:
130 default: 129 default:
131 return kUnknown_SkColorType; 130 return kUnknown_SkColorType;
132 } 131 }
133 } 132 }
134 133
135 } // namespace gfx 134 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/compositor/layer_unittest.cc ('k') | ui/gfx/blit_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698