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

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

Issue 2518253002: Move Partition Allocator into Chromium base. (Closed)
Patch Set: Respond to more of Primiano's comments; move PartitionAllocator.* back to wtf; some build fixes 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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 } 455 }
455 456
456 size_t ImagePlanes::rowBytes(int i) const { 457 size_t ImagePlanes::rowBytes(int i) const {
457 ASSERT((i >= 0) && i < 3); 458 ASSERT((i >= 0) && i < 3);
458 return m_rowBytes[i]; 459 return m_rowBytes[i];
459 } 460 }
460 461
461 namespace { 462 namespace {
462 463
463 // The output device color space is global and shared across multiple threads. 464 // The output device color space is global and shared across multiple threads.
464 SpinLock gTargetColorSpaceLock; 465 WTF::SpinLock gTargetColorSpaceLock;
465 SkColorSpace* gTargetColorSpace = nullptr; 466 SkColorSpace* gTargetColorSpace = nullptr;
466 467
467 } // namespace 468 } // namespace
468 469
469 // static 470 // static
470 void ImageDecoder::setGlobalTargetColorProfile(const WebVector<char>& profile) { 471 void ImageDecoder::setGlobalTargetColorProfile(const WebVector<char>& profile) {
471 if (profile.isEmpty()) 472 if (profile.isEmpty())
472 return; 473 return;
473 474
474 // Take a lock around initializing and accessing the global device color 475 // Take a lock around initializing and accessing the global device color
475 // profile. 476 // profile.
476 SpinLock::Guard guard(gTargetColorSpaceLock); 477 WTF::SpinLock::Guard guard(gTargetColorSpaceLock);
477 478
478 // Layout tests expect that only the first call will take effect. 479 // Layout tests expect that only the first call will take effect.
479 if (gTargetColorSpace) 480 if (gTargetColorSpace)
480 return; 481 return;
481 482
482 gTargetColorSpace = 483 gTargetColorSpace =
483 SkColorSpace::MakeICC(profile.data(), profile.size()).release(); 484 SkColorSpace::MakeICC(profile.data(), profile.size()).release();
484 485
485 // UMA statistics. 486 // UMA statistics.
486 BitmapImageMetrics::countOutputGamma(gTargetColorSpace); 487 BitmapImageMetrics::countOutputGamma(gTargetColorSpace);
487 } 488 }
488 489
489 // static 490 // static
490 sk_sp<SkColorSpace> ImageDecoder::globalTargetColorSpace() { 491 sk_sp<SkColorSpace> ImageDecoder::globalTargetColorSpace() {
491 // Take a lock around initializing and accessing the global device color 492 // Take a lock around initializing and accessing the global device color
492 // profile. 493 // profile.
493 SpinLock::Guard guard(gTargetColorSpaceLock); 494 WTF::SpinLock::Guard guard(gTargetColorSpaceLock);
494 495
495 // Initialize the output device profile to sRGB if it has not yet been 496 // Initialize the output device profile to sRGB if it has not yet been
496 // initialized. 497 // initialized.
497 if (!gTargetColorSpace) { 498 if (!gTargetColorSpace) {
498 gTargetColorSpace = 499 gTargetColorSpace =
499 SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named).release(); 500 SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named).release();
500 } 501 }
501 502
502 gTargetColorSpace->ref(); 503 gTargetColorSpace->ref();
503 return sk_sp<SkColorSpace>(gTargetColorSpace); 504 return sk_sp<SkColorSpace>(gTargetColorSpace);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 m_targetColorSpace.get())) { 553 m_targetColorSpace.get())) {
553 return nullptr; 554 return nullptr;
554 } 555 }
555 556
556 m_sourceToTargetColorTransform = SkColorSpaceXform::New( 557 m_sourceToTargetColorTransform = SkColorSpaceXform::New(
557 m_embeddedColorSpace.get(), m_targetColorSpace.get()); 558 m_embeddedColorSpace.get(), m_targetColorSpace.get());
558 return m_sourceToTargetColorTransform.get(); 559 return m_sourceToTargetColorTransform.get();
559 } 560 }
560 561
561 } // namespace blink 562 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698