| OLD | NEW |
| 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 "blimp/engine/renderer/engine_image_serialization_processor.h" | 5 #include "blimp/engine/renderer/engine_image_serialization_processor.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 std::vector<unsigned char> data; | 60 std::vector<unsigned char> data; |
| 61 picture.custom_ptr = &data; | 61 picture.custom_ptr = &data; |
| 62 | 62 |
| 63 // Use our own WebPWriterFunction implementation. | 63 // Use our own WebPWriterFunction implementation. |
| 64 picture.writer = &WebPImageEncoder::WriteOutput; | 64 picture.writer = &WebPImageEncoder::WriteOutput; |
| 65 | 65 |
| 66 // Setup the configuration for the output WebP picture. This is currently | 66 // Setup the configuration for the output WebP picture. This is currently |
| 67 // the same as the default configuration for WebP, but since any change in | 67 // the same as the default configuration for WebP, but since any change in |
| 68 // the WebP defaults would invalidate all caches they are hard coded. | 68 // the WebP defaults would invalidate all caches they are hard coded. |
| 69 config.quality = 75.0; // between 0 (smallest file) and 100 (biggest). | 69 config.quality = 75.0; // between 0 (smallest file) and 100 (biggest). |
| 70 config.method = 4; // quality/speed trade-off (0=fast, 6=slower-better). | 70 |
| 71 // TODO(nyquist): Move image encoding to a different thread when |
| 72 // asynchronous loading of images is possible. The encode work currently |
| 73 // blocks the render thread so we are dropping the method down to 0. |
| 74 // crbug.com/603643. |
| 75 config.method = 0; // quality/speed trade-off (0=fast, 6=slower-better). |
| 71 | 76 |
| 72 // Encode the picture using the given configuration. | 77 // Encode the picture using the given configuration. |
| 73 bool success = WebPEncode(&config, &picture); | 78 bool success = WebPEncode(&config, &picture); |
| 74 | 79 |
| 75 // Release the memory allocated by WebPPictureImport*(). This does not free | 80 // Release the memory allocated by WebPPictureImport*(). This does not free |
| 76 // the memory used by the picture object itself. | 81 // the memory used by the picture object itself. |
| 77 WebPPictureFree(&picture); | 82 WebPPictureFree(&picture); |
| 78 | 83 |
| 79 if (!success) | 84 if (!success) |
| 80 return nullptr; | 85 return nullptr; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 return pixel_serializer_.get(); | 165 return pixel_serializer_.get(); |
| 161 } | 166 } |
| 162 | 167 |
| 163 SkPicture::InstallPixelRefProc | 168 SkPicture::InstallPixelRefProc |
| 164 EngineImageSerializationProcessor::GetPixelDeserializer() { | 169 EngineImageSerializationProcessor::GetPixelDeserializer() { |
| 165 return nullptr; | 170 return nullptr; |
| 166 } | 171 } |
| 167 | 172 |
| 168 } // namespace engine | 173 } // namespace engine |
| 169 } // namespace blimp | 174 } // namespace blimp |
| OLD | NEW |