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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp

Issue 2518253002: Move Partition Allocator into Chromium base. (Closed)
Patch Set: Remove PRETTY_FUNCTION, and fix (?) ByteSwap for uintptr_t on macOS/iOS. Created 4 years 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) Research In Motion Limited 2009-2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 13 matching lines...) Expand all
24 #include "platform/RuntimeEnabledFeatures.h" 24 #include "platform/RuntimeEnabledFeatures.h"
25 #include "platform/graphics/BitmapImageMetrics.h" 25 #include "platform/graphics/BitmapImageMetrics.h"
26 #include "platform/image-decoders/FastSharedBufferReader.h" 26 #include "platform/image-decoders/FastSharedBufferReader.h"
27 #include "platform/image-decoders/bmp/BMPImageDecoder.h" 27 #include "platform/image-decoders/bmp/BMPImageDecoder.h"
28 #include "platform/image-decoders/gif/GIFImageDecoder.h" 28 #include "platform/image-decoders/gif/GIFImageDecoder.h"
29 #include "platform/image-decoders/ico/ICOImageDecoder.h" 29 #include "platform/image-decoders/ico/ICOImageDecoder.h"
30 #include "platform/image-decoders/jpeg/JPEGImageDecoder.h" 30 #include "platform/image-decoders/jpeg/JPEGImageDecoder.h"
31 #include "platform/image-decoders/png/PNGImageDecoder.h" 31 #include "platform/image-decoders/png/PNGImageDecoder.h"
32 #include "platform/image-decoders/webp/WEBPImageDecoder.h" 32 #include "platform/image-decoders/webp/WEBPImageDecoder.h"
33 #include "wtf/PtrUtil.h" 33 #include "wtf/PtrUtil.h"
34 #include "wtf/SpinLock.h"
34 #include <memory> 35 #include <memory>
35 36
36 namespace blink { 37 namespace blink {
37 38
38 inline bool matchesJPEGSignature(const char* contents) { 39 inline bool matchesJPEGSignature(const char* contents) {
39 return !memcmp(contents, "\xFF\xD8\xFF", 3); 40 return !memcmp(contents, "\xFF\xD8\xFF", 3);
40 } 41 }
41 42
42 inline bool matchesPNGSignature(const char* contents) { 43 inline bool matchesPNGSignature(const char* contents) {
43 return !memcmp(contents, "\x89PNG\r\n\x1A\n", 8); 44 return !memcmp(contents, "\x89PNG\r\n\x1A\n", 8);
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 } 506 }
506 507
507 size_t ImagePlanes::rowBytes(int i) const { 508 size_t ImagePlanes::rowBytes(int i) const {
508 ASSERT((i >= 0) && i < 3); 509 ASSERT((i >= 0) && i < 3);
509 return m_rowBytes[i]; 510 return m_rowBytes[i];
510 } 511 }
511 512
512 namespace { 513 namespace {
513 514
514 // The output device color space is global and shared across multiple threads. 515 // The output device color space is global and shared across multiple threads.
515 SpinLock gTargetColorSpaceLock; 516 WTF::SpinLock gTargetColorSpaceLock;
516 SkColorSpace* gTargetColorSpace = nullptr; 517 SkColorSpace* gTargetColorSpace = nullptr;
517 518
518 } // namespace 519 } // namespace
519 520
520 // static 521 // static
521 void ImageDecoder::setGlobalTargetColorProfile(const WebVector<char>& profile) { 522 void ImageDecoder::setGlobalTargetColorProfile(const WebVector<char>& profile) {
522 if (profile.isEmpty()) 523 if (profile.isEmpty())
523 return; 524 return;
524 525
525 // Take a lock around initializing and accessing the global device color 526 // Take a lock around initializing and accessing the global device color
526 // profile. 527 // profile.
527 SpinLock::Guard guard(gTargetColorSpaceLock); 528 WTF::SpinLock::Guard guard(gTargetColorSpaceLock);
528 529
529 // Layout tests expect that only the first call will take effect. 530 // Layout tests expect that only the first call will take effect.
530 if (gTargetColorSpace) 531 if (gTargetColorSpace)
531 return; 532 return;
532 533
533 gTargetColorSpace = 534 gTargetColorSpace =
534 SkColorSpace::MakeICC(profile.data(), profile.size()).release(); 535 SkColorSpace::MakeICC(profile.data(), profile.size()).release();
535 536
536 // UMA statistics. 537 // UMA statistics.
537 BitmapImageMetrics::countOutputGamma(gTargetColorSpace); 538 BitmapImageMetrics::countOutputGamma(gTargetColorSpace);
538 } 539 }
539 540
540 // static 541 // static
541 sk_sp<SkColorSpace> ImageDecoder::globalTargetColorSpace() { 542 sk_sp<SkColorSpace> ImageDecoder::globalTargetColorSpace() {
542 // Take a lock around initializing and accessing the global device color 543 // Take a lock around initializing and accessing the global device color
543 // profile. 544 // profile.
544 SpinLock::Guard guard(gTargetColorSpaceLock); 545 WTF::SpinLock::Guard guard(gTargetColorSpaceLock);
545 546
546 // Initialize the output device profile to sRGB if it has not yet been 547 // Initialize the output device profile to sRGB if it has not yet been
547 // initialized. 548 // initialized.
548 if (!gTargetColorSpace) { 549 if (!gTargetColorSpace) {
549 gTargetColorSpace = 550 gTargetColorSpace =
550 SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named).release(); 551 SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named).release();
551 } 552 }
552 553
553 gTargetColorSpace->ref(); 554 gTargetColorSpace->ref();
554 return sk_sp<SkColorSpace>(gTargetColorSpace); 555 return sk_sp<SkColorSpace>(gTargetColorSpace);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 m_targetColorSpace.get())) { 604 m_targetColorSpace.get())) {
604 return nullptr; 605 return nullptr;
605 } 606 }
606 607
607 m_sourceToTargetColorTransform = SkColorSpaceXform::New( 608 m_sourceToTargetColorTransform = SkColorSpaceXform::New(
608 m_embeddedColorSpace.get(), m_targetColorSpace.get()); 609 m_embeddedColorSpace.get(), m_targetColorSpace.get());
609 return m_sourceToTargetColorTransform.get(); 610 return m_sourceToTargetColorTransform.get();
610 } 611 }
611 612
612 } // namespace blink 613 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698