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

Side by Side Diff: third_party/WebKit/Source/platform/wtf/HashTraits.h

Issue 2787053004: Respect colorSpace in DecodingImageGenerator::onGetPixels() (Closed)
Patch Set: AlphaOption 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 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 } 332 }
333 static bool IsDeletedValue(const TraitType& value) { 333 static bool IsDeletedValue(const TraitType& value) {
334 return FirstTraits::IsDeletedValue(value.first); 334 return FirstTraits::IsDeletedValue(value.first);
335 } 335 }
336 }; 336 };
337 337
338 template <typename First, typename Second> 338 template <typename First, typename Second>
339 struct HashTraits<std::pair<First, Second>> 339 struct HashTraits<std::pair<First, Second>>
340 : public PairHashTraits<HashTraits<First>, HashTraits<Second>> {}; 340 : public PairHashTraits<HashTraits<First>, HashTraits<Second>> {};
341 341
342 template <typename FirstTraitsArg,
343 typename SecondTraitsArg,
344 typename ThirdTraitsArg>
345 struct TupleHashTraits
346 : GenericHashTraits<std::tuple<typename FirstTraitsArg::TraitType,
347 typename SecondTraitsArg::TraitType,
348 typename ThirdTraitsArg::TraitType>> {
349 typedef FirstTraitsArg FirstTraits;
350 typedef SecondTraitsArg SecondTraits;
351 typedef ThirdTraitsArg ThirdTraits;
352 typedef std::tuple<typename FirstTraits::TraitType,
353 typename SecondTraits::TraitType,
354 typename ThirdTraits::TraitType>
355 TraitType;
356 typedef std::tuple<typename FirstTraits::EmptyValueType,
357 typename SecondTraits::EmptyValueType,
358 typename ThirdTraits::EmptyValueType>
359 EmptyValueType;
360
361 static const bool kEmptyValueIsZero = FirstTraits::kEmptyValueIsZero &&
362 SecondTraits::kEmptyValueIsZero &&
363 ThirdTraits::kEmptyValueIsZero;
364 static EmptyValueType EmptyValue() {
365 return std::make_tuple(FirstTraits::EmptyValue(),
366 SecondTraits::EmptyValue(),
367 ThirdTraits::EmptyValue());
368 }
369
370 static const bool kHasIsEmptyValueFunction =
371 FirstTraits::kHasIsEmptyValueFunction ||
372 SecondTraits::kHasIsEmptyValueFunction ||
373 ThirdTraits::kHasIsEmptyValueFunction;
374 static bool IsEmptyValue(const TraitType& value) {
375 return IsHashTraitsEmptyValue<FirstTraits>(std::get<0>(value)) &&
376 IsHashTraitsEmptyValue<SecondTraits>(std::get<1>(value)) &&
377 IsHashTraitsEmptyValue<ThirdTraits>(std::get<2>(value));
378 }
379
380 static const unsigned kMinimumTableSize = FirstTraits::kMinimumTableSize;
381
382 static void ConstructDeletedValue(TraitType& slot, bool zero_value) {
383 FirstTraits::ConstructDeletedValue(std::get<0>(slot), zero_value);
384 // For GC collections the memory for the backing is zeroed when it is
385 // allocated, and the constructors may take advantage of that,
386 // especially if a GC occurs during insertion of an entry into the
387 // table. This slot is being marked deleted, but If the slot is reused
388 // at a later point, the same assumptions around memory zeroing must
389 // hold as they did at the initial allocation. Therefore we zero the
390 // value part of the slot here for GC collections.
391 if (zero_value) {
392 memset(reinterpret_cast<void*>(&std::get<1>(slot)), 0,
393 sizeof(std::get<1>(slot)));
394 memset(reinterpret_cast<void*>(&std::get<2>(slot)), 0,
395 sizeof(std::get<2>(slot)));
396 }
397 }
398 static bool IsDeletedValue(const TraitType& value) {
399 return FirstTraits::IsDeletedValue(std::get<0>(value));
400 }
401 };
402
403 template <typename First, typename Second, typename Third>
404 struct HashTraits<std::tuple<First, Second, Third>>
405 : public TupleHashTraits<HashTraits<First>,
406 HashTraits<Second>,
407 HashTraits<Third>> {};
408
342 template <typename KeyTypeArg, typename ValueTypeArg> 409 template <typename KeyTypeArg, typename ValueTypeArg>
343 struct KeyValuePair { 410 struct KeyValuePair {
344 typedef KeyTypeArg KeyType; 411 typedef KeyTypeArg KeyType;
345 412
346 template <typename IncomingKeyType, typename IncomingValueType> 413 template <typename IncomingKeyType, typename IncomingValueType>
347 KeyValuePair(IncomingKeyType&& key, IncomingValueType&& value) 414 KeyValuePair(IncomingKeyType&& key, IncomingValueType&& value)
348 : key(std::forward<IncomingKeyType>(key)), 415 : key(std::forward<IncomingKeyType>(key)),
349 value(std::forward<IncomingValueType>(value)) {} 416 value(std::forward<IncomingValueType>(value)) {}
350 417
351 template <typename OtherKeyType, typename OtherValueType> 418 template <typename OtherKeyType, typename OtherValueType>
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 template <typename T> 483 template <typename T>
417 struct NullableHashTraits : public HashTraits<T> { 484 struct NullableHashTraits : public HashTraits<T> {
418 static const bool kEmptyValueIsZero = false; 485 static const bool kEmptyValueIsZero = false;
419 static T EmptyValue() { return reinterpret_cast<T>(1); } 486 static T EmptyValue() { return reinterpret_cast<T>(1); }
420 }; 487 };
421 488
422 } // namespace WTF 489 } // namespace WTF
423 490
424 using WTF::HashTraits; 491 using WTF::HashTraits;
425 using WTF::PairHashTraits; 492 using WTF::PairHashTraits;
493 using WTF::TupleHashTraits;
426 using WTF::NullableHashTraits; 494 using WTF::NullableHashTraits;
427 using WTF::SimpleClassHashTraits; 495 using WTF::SimpleClassHashTraits;
428 496
429 #endif // WTF_HashTraits_h 497 #endif // WTF_HashTraits_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698