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

Side by Side Diff: sky/compositor/picture_serializer.cc

Issue 853863003: Serialize SkPictures to the file system (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months 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
« no previous file with comments | « sky/compositor/picture_serializer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "sky/compositor/picture_serializer.h"
6
7 #include "third_party/skia/include/core/SkData.h"
8 #include "third_party/skia/include/core/SkPixelSerializer.h"
9 #include "third_party/skia/include/core/SkStream.h"
10 #include "ui/gfx/codec/png_codec.h"
11
12 namespace sky {
13
14 class PngPixelSerializer : public SkPixelSerializer {
15 public:
16 bool onUseEncodedData(const void*, size_t) override { return true; }
17 SkData* onEncodePixels(const SkImageInfo& info, const void* pixels,
18 size_t row_bytes) override {
19 std::vector<unsigned char> data;
20
21 SkBitmap bm;
22 if (!bm.installPixels(info, const_cast<void*>(pixels), row_bytes))
23 return nullptr;
24 if (!gfx::PNGCodec::EncodeBGRASkBitmap(bm, false, &data))
25 return nullptr;
26 return SkData::NewWithCopy(&data.front(), data.size());
27 }
28 };
29
30 void SerializePicture(const char* file_name, SkPicture* picture) {
31 SkFILEWStream stream(file_name);
32 PngPixelSerializer serializer;
33 picture->serialize(&stream, &serializer);
34 }
35
36 } // namespace sky
OLDNEW
« no previous file with comments | « sky/compositor/picture_serializer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698