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

Side by Side Diff: ui/gfx/skia_util.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/gfx/skbitmap_operations_unittest.cc ('k') | ui/views/controls/image_view.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/skia_util.h" 5 #include "ui/gfx/skia_util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 flattened->set(7, SkMScalarToScalar(transform.matrix().get(3, 1))); 90 flattened->set(7, SkMScalarToScalar(transform.matrix().get(3, 1)));
91 flattened->set(8, SkMScalarToScalar(transform.matrix().get(3, 3))); 91 flattened->set(8, SkMScalarToScalar(transform.matrix().get(3, 3)));
92 } 92 }
93 93
94 bool BitmapsAreEqual(const SkBitmap& bitmap1, const SkBitmap& bitmap2) { 94 bool BitmapsAreEqual(const SkBitmap& bitmap1, const SkBitmap& bitmap2) {
95 void* addr1 = NULL; 95 void* addr1 = NULL;
96 void* addr2 = NULL; 96 void* addr2 = NULL;
97 size_t size1 = 0; 97 size_t size1 = 0;
98 size_t size2 = 0; 98 size_t size2 = 0;
99 99
100 bitmap1.lockPixels();
101 addr1 = bitmap1.getAddr32(0, 0); 100 addr1 = bitmap1.getAddr32(0, 0);
102 size1 = bitmap1.getSize(); 101 size1 = bitmap1.getSize();
103 bitmap1.unlockPixels();
104 102
105 bitmap2.lockPixels();
106 addr2 = bitmap2.getAddr32(0, 0); 103 addr2 = bitmap2.getAddr32(0, 0);
107 size2 = bitmap2.getSize(); 104 size2 = bitmap2.getSize();
108 bitmap2.unlockPixels();
109 105
110 return (size1 == size2) && (0 == memcmp(addr1, addr2, bitmap1.getSize())); 106 return (size1 == size2) && (0 == memcmp(addr1, addr2, bitmap1.getSize()));
111 } 107 }
112 108
113 void ConvertSkiaToRGBA(const unsigned char* skia, 109 void ConvertSkiaToRGBA(const unsigned char* skia,
114 int pixel_width, 110 int pixel_width,
115 unsigned char* rgba) { 111 unsigned char* rgba) {
116 int total_length = pixel_width * 4; 112 int total_length = pixel_width * 4;
117 for (int i = 0; i < total_length; i += 4) { 113 for (int i = 0; i < total_length; i += 4) {
118 const uint32_t pixel_in = *reinterpret_cast<const uint32_t*>(&skia[i]); 114 const uint32_t pixel_in = *reinterpret_cast<const uint32_t*>(&skia[i]);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 static const SkScalar kSkToHbRatio = SK_Scalar1 / kHbUnit1; 148 static const SkScalar kSkToHbRatio = SK_Scalar1 / kHbUnit1;
153 return kSkToHbRatio * value; 149 return kSkToHbRatio * value;
154 } 150 }
155 151
156 float HarfBuzzUnitsToFloat(int value) { 152 float HarfBuzzUnitsToFloat(int value) {
157 static const float kFloatToHbRatio = 1.0f / kHbUnit1; 153 static const float kFloatToHbRatio = 1.0f / kHbUnit1;
158 return kFloatToHbRatio * value; 154 return kFloatToHbRatio * value;
159 } 155 }
160 156
161 } // namespace gfx 157 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/skbitmap_operations_unittest.cc ('k') | ui/views/controls/image_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698