| Index: cc/resources/picture.cc
|
| diff --git a/cc/resources/picture.cc b/cc/resources/picture.cc
|
| index 2b6eca8777fbc0c3d7d280170d3f7008ce85d990..367e510a272d1ad1c162a4d06083e1aea710da77 100644
|
| --- a/cc/resources/picture.cc
|
| +++ b/cc/resources/picture.cc
|
| @@ -2,15 +2,18 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "cc/resources/picture.h"
|
| +
|
| +#include "base/base64.h"
|
| #include "base/debug/trace_event.h"
|
| #include "cc/debug/rendering_stats.h"
|
| #include "cc/layers/content_layer_client.h"
|
| -#include "cc/resources/picture.h"
|
| #include "skia/ext/analysis_canvas.h"
|
| #include "third_party/skia/include/core/SkCanvas.h"
|
| #include "third_party/skia/include/core/SkData.h"
|
| #include "third_party/skia/include/core/SkDrawFilter.h"
|
| #include "third_party/skia/include/core/SkPaint.h"
|
| +#include "third_party/skia/include/core/SkStream.h"
|
| #include "third_party/skia/include/utils/SkPictureUtils.h"
|
| #include "ui/gfx/rect_conversions.h"
|
| #include "ui/gfx/skia_util.h"
|
| @@ -178,4 +181,21 @@ void Picture::GatherPixelRefs(const gfx::Rect& layer_rect,
|
| pixel_refs->unref();
|
| }
|
|
|
| +void Picture::AsBase64String(std::string* output) const {
|
| + SkDynamicMemoryWStream stream;
|
| + picture_->serialize(&stream);
|
| + size_t serialized_size = stream.bytesWritten();
|
| + scoped_ptr<char[]> serialized_picture(new char[serialized_size]);
|
| + stream.copyTo(serialized_picture.get());
|
| + base::Base64Encode(std::string(serialized_picture.get(), serialized_size),
|
| + output);
|
| +}
|
| +
|
| +void Picture::SetPictureFromBase64String(const std::string & encoded) {
|
| + std::string decoded;
|
| + base::Base64Decode(encoded, &decoded);
|
| + SkMemoryStream stream(decoded.data(), decoded.size());
|
| + picture_ = skia::AdoptRef(new SkPicture(&stream));
|
| +}
|
| +
|
| } // namespace cc
|
|
|