OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, Google Inc. All rights reserved. |
3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
8 * met: | 8 * met: |
9 * | 9 * |
10 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 return nullptr; | 74 return nullptr; |
75 return WTF::wrapUnique(new ImageBuffer(std::move(surface))); | 75 return WTF::wrapUnique(new ImageBuffer(std::move(surface))); |
76 } | 76 } |
77 | 77 |
78 std::unique_ptr<ImageBuffer> ImageBuffer::create( | 78 std::unique_ptr<ImageBuffer> ImageBuffer::create( |
79 const IntSize& size, | 79 const IntSize& size, |
80 OpacityMode opacityMode, | 80 OpacityMode opacityMode, |
81 ImageInitializationMode initializationMode, | 81 ImageInitializationMode initializationMode, |
82 sk_sp<SkColorSpace> colorSpace) { | 82 sk_sp<SkColorSpace> colorSpace) { |
83 SkColorType colorType = kN32_SkColorType; | 83 SkColorType colorType = kN32_SkColorType; |
84 if (colorSpace && SkColorSpace::Equals(colorSpace.get(), | 84 if (colorSpace && |
85 SkColorSpace::MakeSRGBLinear().get())) | 85 SkColorSpace::Equals(colorSpace.get(), |
| 86 SkColorSpace::MakeSRGBLinear().get())) |
86 colorType = kRGBA_F16_SkColorType; | 87 colorType = kRGBA_F16_SkColorType; |
87 | 88 |
88 std::unique_ptr<ImageBufferSurface> surface(WTF::wrapUnique( | 89 std::unique_ptr<ImageBufferSurface> surface(WTF::wrapUnique( |
89 new UnacceleratedImageBufferSurface(size, opacityMode, initializationMode, | 90 new UnacceleratedImageBufferSurface(size, opacityMode, initializationMode, |
90 std::move(colorSpace), colorType))); | 91 std::move(colorSpace), colorType))); |
91 | 92 |
92 if (!surface->isValid()) | 93 if (!surface->isValid()) |
93 return nullptr; | 94 return nullptr; |
94 return WTF::wrapUnique(new ImageBuffer(std::move(surface))); | 95 return WTF::wrapUnique(new ImageBuffer(std::move(surface))); |
95 } | 96 } |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 DCHECK(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 609 DCHECK(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
609 | 610 |
610 Vector<unsigned char> result; | 611 Vector<unsigned char> result; |
611 if (!encodeImage(mimeType, quality, &result)) | 612 if (!encodeImage(mimeType, quality, &result)) |
612 return "data:,"; | 613 return "data:,"; |
613 | 614 |
614 return "data:" + mimeType + ";base64," + base64Encode(result); | 615 return "data:" + mimeType + ";base64," + base64Encode(result); |
615 } | 616 } |
616 | 617 |
617 } // namespace blink | 618 } // namespace blink |
OLD | NEW |