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

Side by Side Diff: skia/public/interfaces/bitmap_skbitmap_struct_traits.cc

Issue 2823003002: SkBitmap and SkPixelRef no longer need lock/unlock (Closed)
Patch Set: 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "skia/public/interfaces/bitmap_skbitmap_struct_traits.h" 5 #include "skia/public/interfaces/bitmap_skbitmap_struct_traits.h"
6 6
7 namespace mojo { 7 namespace mojo {
8 8
9 namespace { 9 namespace {
10 10
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 MojoAlphaTypeToSk(data.alpha_type()), 173 MojoAlphaTypeToSk(data.alpha_type()),
174 MojoProfileTypeToSk(data.profile_type())), 174 MojoProfileTypeToSk(data.profile_type())),
175 data.row_bytes())) { 175 data.row_bytes())) {
176 return false; 176 return false;
177 } 177 }
178 178
179 // If the image is empty, return success after setting the image info. 179 // If the image is empty, return success after setting the image info.
180 if (data.width() == 0 || data.height() == 0) 180 if (data.width() == 0 || data.height() == 0)
181 return true; 181 return true;
182 182
183 SkAutoPixmapUnlock pixmap;
184 mojo::ArrayDataView<uint8_t> data_view; 183 mojo::ArrayDataView<uint8_t> data_view;
185 data.GetPixelDataDataView(&data_view); 184 data.GetPixelDataDataView(&data_view);
186 if (static_cast<uint32_t>(b->width()) != data.width() || 185 if (static_cast<uint32_t>(b->width()) != data.width() ||
187 static_cast<uint32_t>(b->height()) != data.height() || 186 static_cast<uint32_t>(b->height()) != data.height() ||
188 static_cast<uint64_t>(b->rowBytes()) != data.row_bytes() || 187 static_cast<uint64_t>(b->rowBytes()) != data.row_bytes() ||
189 b->getSize() != data_view.size() || !b->requestLock(&pixmap) || 188 b->getSize() != data_view.size() || !b->readyToDraw()) {
190 !b->readyToDraw()) {
191 return false; 189 return false;
192 } 190 }
193 191
194 BitmapBuffer bitmap_buffer = {0, b->getSize(), 192 BitmapBuffer bitmap_buffer = {0, b->getSize(),
195 static_cast<uint8_t*>(b->getPixels())}; 193 static_cast<uint8_t*>(b->getPixels())};
196 if (!data.ReadPixelData(&bitmap_buffer) || bitmap_buffer.size != b->getSize()) 194 if (!data.ReadPixelData(&bitmap_buffer) || bitmap_buffer.size != b->getSize())
197 return false; 195 return false;
198 196
199 b->notifyPixelsChanged(); 197 b->notifyPixelsChanged();
200 return true; 198 return true;
201 } 199 }
202 200
203 // static 201 // static
204 void* StructTraits<skia::mojom::BitmapDataView, SkBitmap>::SetUpContext( 202 void* StructTraits<skia::mojom::BitmapDataView, SkBitmap>::SetUpContext(
dcheng 2017/04/17 22:03:10 Nit: please remove these members, since they're no
reed1 2017/04/18 12:53:01 Done.
205 const SkBitmap& b) { 203 const SkBitmap& b) {
206 b.lockPixels();
207 return nullptr; 204 return nullptr;
208 } 205 }
209 206
210 // static 207 // static
211 void StructTraits<skia::mojom::BitmapDataView, SkBitmap>::TearDownContext( 208 void StructTraits<skia::mojom::BitmapDataView, SkBitmap>::TearDownContext(
212 const SkBitmap& b, 209 const SkBitmap& b,
213 void* context) { 210 void* context) {
214 b.unlockPixels();
215 } 211 }
216 212
217 } // namespace mojo 213 } // namespace mojo
OLDNEW
« no previous file with comments | « skia/ext/platform_canvas_unittest.cc ('k') | third_party/WebKit/Source/platform/DragImageTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698