| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "platform/graphics/PictureSnapshot.h" | 31 #include "platform/graphics/PictureSnapshot.h" |
| 32 | 32 |
| 33 #include "platform/geometry/IntSize.h" | 33 #include "platform/geometry/IntSize.h" |
| 34 #include "platform/graphics/ImageBuffer.h" | 34 #include "platform/graphics/ImageBuffer.h" |
| 35 #include "platform/graphics/LoggingCanvas.h" | 35 #include "platform/graphics/LoggingCanvas.h" |
| 36 #include "platform/graphics/ProfilingCanvas.h" | 36 #include "platform/graphics/ProfilingCanvas.h" |
| 37 #include "platform/graphics/ReplayingCanvas.h" | 37 #include "platform/graphics/ReplayingCanvas.h" |
| 38 #include "platform/graphics/skia/ImagePixelLocker.h" | 38 #include "platform/graphics/skia/ImagePixelLocker.h" |
| 39 #include "platform/image-decoders/ImageDecoder.h" | 39 #include "platform/image-decoders/ImageDecoder.h" |
| 40 #include "platform/image-decoders/ImageFrame.h" | 40 #include "platform/image-decoders/ImageFrame.h" |
| 41 #include "platform/image-decoders/SegmentReader.h" |
| 41 #include "platform/image-encoders/skia/PNGImageEncoder.h" | 42 #include "platform/image-encoders/skia/PNGImageEncoder.h" |
| 43 #include "third_party/skia/include/core/SkData.h" |
| 42 #include "third_party/skia/include/core/SkImage.h" | 44 #include "third_party/skia/include/core/SkImage.h" |
| 43 #include "third_party/skia/include/core/SkPictureRecorder.h" | 45 #include "third_party/skia/include/core/SkPictureRecorder.h" |
| 44 #include "third_party/skia/include/core/SkStream.h" | 46 #include "third_party/skia/include/core/SkStream.h" |
| 45 #include "wtf/CurrentTime.h" | 47 #include "wtf/CurrentTime.h" |
| 46 #include "wtf/HexNumber.h" | 48 #include "wtf/HexNumber.h" |
| 47 #include "wtf/text/Base64.h" | 49 #include "wtf/text/Base64.h" |
| 48 #include "wtf/text/TextEncoding.h" | 50 #include "wtf/text/TextEncoding.h" |
| 49 | 51 |
| 50 namespace blink { | 52 namespace blink { |
| 51 | 53 |
| 52 PictureSnapshot::PictureSnapshot(PassRefPtr<const SkPicture> picture) | 54 PictureSnapshot::PictureSnapshot(PassRefPtr<const SkPicture> picture) |
| 53 : m_picture(picture) | 55 : m_picture(picture) |
| 54 { | 56 { |
| 55 } | 57 } |
| 56 | 58 |
| 57 static bool decodeBitmap(const void* data, size_t length, SkBitmap* result) | 59 static bool decodeBitmap(const void* data, size_t length, SkBitmap* result) |
| 58 { | 60 { |
| 59 RefPtr<SharedBuffer> buffer = SharedBuffer::create(static_cast<const char*>(
data), length); | 61 OwnPtr<ImageDecoder> imageDecoder = ImageDecoder::create(static_cast<const c
har*>(data), length, |
| 60 OwnPtr<ImageDecoder> imageDecoder = ImageDecoder::create(*buffer, ImageDecod
er::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileIgnored); | 62 ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileIgno
red); |
| 61 if (!imageDecoder) | 63 if (!imageDecoder) |
| 62 return false; | 64 return false; |
| 63 imageDecoder->setData(buffer.get(), true); | 65 |
| 66 // No need to copy the data; this decodes immediately. |
| 67 RefPtr<SegmentReader> segmentReader = SegmentReader::createFromSkData(adoptR
ef(SkData::NewWithoutCopy(data, length))); |
| 68 imageDecoder->setData(segmentReader.release(), true); |
| 64 ImageFrame* frame = imageDecoder->frameBufferAtIndex(0); | 69 ImageFrame* frame = imageDecoder->frameBufferAtIndex(0); |
| 65 if (!frame) | 70 if (!frame) |
| 66 return true; | 71 return true; |
| 67 *result = frame->getSkBitmap(); | 72 *result = frame->getSkBitmap(); |
| 68 return true; | 73 return true; |
| 69 } | 74 } |
| 70 | 75 |
| 71 PassRefPtr<PictureSnapshot> PictureSnapshot::load(const Vector<RefPtr<TilePictur
eStream>>& tiles) | 76 PassRefPtr<PictureSnapshot> PictureSnapshot::load(const Vector<RefPtr<TilePictur
eStream>>& tiles) |
| 72 { | 77 { |
| 73 ASSERT(!tiles.isEmpty()); | 78 ASSERT(!tiles.isEmpty()); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 174 |
| 170 PassRefPtr<JSONArray> PictureSnapshot::snapshotCommandLog() const | 175 PassRefPtr<JSONArray> PictureSnapshot::snapshotCommandLog() const |
| 171 { | 176 { |
| 172 const SkIRect bounds = m_picture->cullRect().roundOut(); | 177 const SkIRect bounds = m_picture->cullRect().roundOut(); |
| 173 LoggingCanvas canvas(bounds.width(), bounds.height()); | 178 LoggingCanvas canvas(bounds.width(), bounds.height()); |
| 174 m_picture->playback(&canvas); | 179 m_picture->playback(&canvas); |
| 175 return canvas.log(); | 180 return canvas.log(); |
| 176 } | 181 } |
| 177 | 182 |
| 178 } // namespace blink | 183 } // namespace blink |
| OLD | NEW |