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

Side by Side Diff: Source/platform/graphics/PictureSnapshot.cpp

Issue 1022123002: Fix template angle bracket syntax leftovers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove Body.cpp change Created 5 years, 9 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 | « Source/platform/graphics/PictureSnapshot.h ('k') | Source/platform/heap/HeapTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 if (!imageDecoder) 60 if (!imageDecoder)
61 return false; 61 return false;
62 imageDecoder->setData(buffer.get(), true); 62 imageDecoder->setData(buffer.get(), true);
63 ImageFrame* frame = imageDecoder->frameBufferAtIndex(0); 63 ImageFrame* frame = imageDecoder->frameBufferAtIndex(0);
64 if (!frame) 64 if (!frame)
65 return true; 65 return true;
66 *result = frame->getSkBitmap(); 66 *result = frame->getSkBitmap();
67 return true; 67 return true;
68 } 68 }
69 69
70 PassRefPtr<PictureSnapshot> PictureSnapshot::load(const Vector<RefPtr<TilePictur eStream> >& tiles) 70 PassRefPtr<PictureSnapshot> PictureSnapshot::load(const Vector<RefPtr<TilePictur eStream>>& tiles)
71 { 71 {
72 ASSERT(!tiles.isEmpty()); 72 ASSERT(!tiles.isEmpty());
73 Vector<RefPtr<SkPicture> > pictures; 73 Vector<RefPtr<SkPicture>> pictures;
74 pictures.reserveCapacity(tiles.size()); 74 pictures.reserveCapacity(tiles.size());
75 FloatRect unionRect; 75 FloatRect unionRect;
76 for (const auto& tileStream : tiles) { 76 for (const auto& tileStream : tiles) {
77 SkMemoryStream stream(tileStream->data.begin(), tileStream->data.size()) ; 77 SkMemoryStream stream(tileStream->data.begin(), tileStream->data.size()) ;
78 RefPtr<SkPicture> picture = adoptRef(SkPicture::CreateFromStream(&stream , decodeBitmap)); 78 RefPtr<SkPicture> picture = adoptRef(SkPicture::CreateFromStream(&stream , decodeBitmap));
79 if (!picture) 79 if (!picture)
80 return nullptr; 80 return nullptr;
81 FloatRect cullRect(picture->cullRect()); 81 FloatRect cullRect(picture->cullRect());
82 cullRect.moveBy(tileStream->layerOffset); 82 cullRect.moveBy(tileStream->layerOffset);
83 unionRect.unite(cullRect); 83 unionRect.unite(cullRect);
84 pictures.append(picture); 84 pictures.append(picture);
85 } 85 }
86 if (tiles.size() == 1) 86 if (tiles.size() == 1)
87 return adoptRef(new PictureSnapshot(pictures[0])); 87 return adoptRef(new PictureSnapshot(pictures[0]));
88 SkPictureRecorder recorder; 88 SkPictureRecorder recorder;
89 SkCanvas* canvas = recorder.beginRecording(unionRect.width(), unionRect.heig ht(), 0, 0); 89 SkCanvas* canvas = recorder.beginRecording(unionRect.width(), unionRect.heig ht(), 0, 0);
90 for (size_t i = 0; i < pictures.size(); ++i) { 90 for (size_t i = 0; i < pictures.size(); ++i) {
91 canvas->save(); 91 canvas->save();
92 canvas->translate(tiles[i]->layerOffset.x() - unionRect.x(), tiles[i]->l ayerOffset.y() - unionRect.y()); 92 canvas->translate(tiles[i]->layerOffset.x() - unionRect.x(), tiles[i]->l ayerOffset.y() - unionRect.y());
93 pictures[i]->playback(canvas, 0); 93 pictures[i]->playback(canvas, 0);
94 canvas->restore(); 94 canvas->restore();
95 } 95 }
96 return adoptRef(new PictureSnapshot(adoptRef(recorder.endRecordingAsPicture( )))); 96 return adoptRef(new PictureSnapshot(adoptRef(recorder.endRecordingAsPicture( ))));
97 } 97 }
98 98
99 PassOwnPtr<Vector<char> > PictureSnapshot::replay(unsigned fromStep, unsigned to Step, double scale) const 99 PassOwnPtr<Vector<char>> PictureSnapshot::replay(unsigned fromStep, unsigned toS tep, double scale) const
100 { 100 {
101 const SkIRect bounds = m_picture->cullRect().roundOut(); 101 const SkIRect bounds = m_picture->cullRect().roundOut();
102 SkBitmap bitmap; 102 SkBitmap bitmap;
103 bitmap.allocPixels(SkImageInfo::MakeN32Premul(bounds.width(), bounds.height( ))); 103 bitmap.allocPixels(SkImageInfo::MakeN32Premul(bounds.width(), bounds.height( )));
104 bitmap.eraseARGB(0, 0, 0, 0); 104 bitmap.eraseARGB(0, 0, 0, 0);
105 { 105 {
106 ReplayingCanvas canvas(bitmap, fromStep, toStep); 106 ReplayingCanvas canvas(bitmap, fromStep, toStep);
107 canvas.scale(scale, scale); 107 canvas.scale(scale, scale);
108 canvas.resetStepCount(); 108 canvas.resetStepCount();
109 m_picture->playback(&canvas, &canvas); 109 m_picture->playback(&canvas, &canvas);
110 } 110 }
111 OwnPtr<Vector<char> > base64Data = adoptPtr(new Vector<char>()); 111 OwnPtr<Vector<char>> base64Data = adoptPtr(new Vector<char>());
112 Vector<char> encodedImage; 112 Vector<char> encodedImage;
113 if (!PNGImageEncoder::encode(bitmap, reinterpret_cast<Vector<unsigned char>* >(&encodedImage))) 113 if (!PNGImageEncoder::encode(bitmap, reinterpret_cast<Vector<unsigned char>* >(&encodedImage)))
114 return nullptr; 114 return nullptr;
115 base64Encode(encodedImage, *base64Data); 115 base64Encode(encodedImage, *base64Data);
116 return base64Data.release(); 116 return base64Data.release();
117 } 117 }
118 118
119 PassOwnPtr<PictureSnapshot::Timings> PictureSnapshot::profile(unsigned minRepeat Count, double minDuration, const FloatRect* clipRect) const 119 PassOwnPtr<PictureSnapshot::Timings> PictureSnapshot::profile(unsigned minRepeat Count, double minDuration, const FloatRect* clipRect) const
120 { 120 {
121 OwnPtr<PictureSnapshot::Timings> timings = adoptPtr(new PictureSnapshot::Tim ings()); 121 OwnPtr<PictureSnapshot::Timings> timings = adoptPtr(new PictureSnapshot::Tim ings());
(...skipping 22 matching lines...) Expand all
144 144
145 PassRefPtr<JSONArray> PictureSnapshot::snapshotCommandLog() const 145 PassRefPtr<JSONArray> PictureSnapshot::snapshotCommandLog() const
146 { 146 {
147 const SkIRect bounds = m_picture->cullRect().roundOut(); 147 const SkIRect bounds = m_picture->cullRect().roundOut();
148 LoggingCanvas canvas(bounds.width(), bounds.height()); 148 LoggingCanvas canvas(bounds.width(), bounds.height());
149 m_picture->playback(&canvas); 149 m_picture->playback(&canvas);
150 return canvas.log(); 150 return canvas.log();
151 } 151 }
152 152
153 } // namespace blink 153 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/graphics/PictureSnapshot.h ('k') | Source/platform/heap/HeapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698