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

Side by Side Diff: blimp/engine/renderer/blimp_engine_picture_cache.cc

Issue 2343993002: use SkData oriented picture serialize api (Closed)
Patch Set: remove another unused SkStream.h include Created 4 years, 3 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
OLDNEW
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/blimp_engine_picture_cache.h" 5 #include "blimp/engine/renderer/blimp_engine_picture_cache.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "third_party/skia/include/core/SkStream.h"
10 9
11 namespace blimp { 10 namespace blimp {
12 namespace engine { 11 namespace engine {
13 12
14 BlimpEnginePictureCache::BlimpEnginePictureCache( 13 BlimpEnginePictureCache::BlimpEnginePictureCache(
15 SkPixelSerializer* pixel_serializer) 14 SkPixelSerializer* pixel_serializer)
16 : pixel_serializer_(pixel_serializer) {} 15 : pixel_serializer_(pixel_serializer) {}
17 16
18 BlimpEnginePictureCache::~BlimpEnginePictureCache() = default; 17 BlimpEnginePictureCache::~BlimpEnginePictureCache() = default;
19 18
(...skipping 25 matching lines...) Expand all
45 } 44 }
46 45
47 // All new items will be sent to the client, so clear everything. 46 // All new items will be sent to the client, so clear everything.
48 pictures_.clear(); 47 pictures_.clear();
49 reference_tracker_.ClearRefCounts(); 48 reference_tracker_.ClearRefCounts();
50 49
51 return update; 50 return update;
52 } 51 }
53 52
54 void BlimpEnginePictureCache::Put(const SkPicture* picture) { 53 void BlimpEnginePictureCache::Put(const SkPicture* picture) {
55 SkDynamicMemoryWStream stream; 54 sk_sp<SkData> data = picture->serialize(pixel_serializer_);
56 picture->serialize(&stream, pixel_serializer_); 55 DCHECK_GE(data->size(), 0u);
Wez 2016/09/16 16:34:02 Should this be DCHECK_GT? Is it possible for a pic
reed1 2016/09/16 20:06:29 Well, an empty picture could be zero bytes. I don'
Wez 2016/09/17 01:50:03 Oh my question was just a question, to check that
57 DCHECK_GE(stream.bytesWritten(), 0u);
58 56
59 // Store the picture data until it is sent to the client. 57 // Store the picture data until it is sent to the client.
60 pictures_.insert( 58 pictures_.insert(
61 std::make_pair(picture->uniqueID(), 59 std::make_pair(picture->uniqueID(),
62 cc::PictureData(picture->uniqueID(), 60 cc::PictureData(picture->uniqueID(), data)));
63 sk_sp<SkData>(stream.copyToData()))));
64 } 61 }
65 62
66 } // namespace engine 63 } // namespace engine
67 } // namespace blimp 64 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698