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

Side by Side Diff: src/core/SkRecordedDrawable.cpp

Issue 1950523002: Remove GrLayerHoister (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Forgot to remove some files Created 4 years, 5 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 | « src/core/SkRecordedDrawable.h ('k') | src/gpu/GrContext.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 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkLayerInfo.h"
9 #include "SkMatrix.h" 8 #include "SkMatrix.h"
10 #include "SkPictureData.h" 9 #include "SkPictureData.h"
11 #include "SkPicturePlayback.h" 10 #include "SkPicturePlayback.h"
12 #include "SkPictureRecord.h" 11 #include "SkPictureRecord.h"
13 #include "SkPictureRecorder.h" 12 #include "SkPictureRecorder.h"
14 #include "SkPictureUtils.h" 13 #include "SkPictureUtils.h"
15 #include "SkRecordedDrawable.h" 14 #include "SkRecordedDrawable.h"
16 #include "SkRecordDraw.h" 15 #include "SkRecordDraw.h"
17 16
18 void SkRecordedDrawable::onDraw(SkCanvas* canvas) { 17 void SkRecordedDrawable::onDraw(SkCanvas* canvas) {
19 SkDrawable* const* drawables = nullptr; 18 SkDrawable* const* drawables = nullptr;
20 int drawableCount = 0; 19 int drawableCount = 0;
21 if (fDrawableList) { 20 if (fDrawableList) {
22 drawables = fDrawableList->begin(); 21 drawables = fDrawableList->begin();
23 drawableCount = fDrawableList->count(); 22 drawableCount = fDrawableList->count();
24 } 23 }
25 SkRecordDraw(*fRecord, canvas, nullptr, drawables, drawableCount, fBBH, null ptr/*callback*/); 24 SkRecordDraw(*fRecord, canvas, nullptr, drawables, drawableCount, fBBH, null ptr/*callback*/);
26 } 25 }
27 26
28 SkPicture* SkRecordedDrawable::onNewPictureSnapshot() { 27 SkPicture* SkRecordedDrawable::onNewPictureSnapshot() {
29 SkBigPicture::SnapshotArray* pictList = nullptr; 28 SkBigPicture::SnapshotArray* pictList = nullptr;
30 if (fDrawableList) { 29 if (fDrawableList) {
31 // TODO: should we plumb-down the BBHFactory and recordFlags from our ho st 30 // TODO: should we plumb-down the BBHFactory and recordFlags from our ho st
32 // PictureRecorder? 31 // PictureRecorder?
33 pictList = fDrawableList->newDrawableSnapshot(); 32 pictList = fDrawableList->newDrawableSnapshot();
34 } 33 }
35 34
36 SkAutoTUnref<SkLayerInfo> saveLayerData;
37 if (fBBH && fDoSaveLayerInfo) {
38 // TODO: can we avoid work by not allocating / filling these bounds?
39 SkAutoTMalloc<SkRect> scratchBounds(fRecord->count());
40 saveLayerData.reset(new SkLayerInfo);
41
42 SkRecordComputeLayers(fBounds, *fRecord, scratchBounds, pictList, saveLa yerData);
43 }
44
45 size_t subPictureBytes = 0; 35 size_t subPictureBytes = 0;
46 for (int i = 0; pictList && i < pictList->count(); i++) { 36 for (int i = 0; pictList && i < pictList->count(); i++) {
47 subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->begin( )[i]); 37 subPictureBytes += SkPictureUtils::ApproximateBytesUsed(pictList->begin( )[i]);
48 } 38 }
49 // SkBigPicture will take ownership of a ref on both fRecord and fBBH. 39 // SkBigPicture will take ownership of a ref on both fRecord and fBBH.
50 // We're not willing to give up our ownership, so we must ref them for SkPic ture. 40 // We're not willing to give up our ownership, so we must ref them for SkPic ture.
51 return new SkBigPicture(fBounds, SkRef(fRecord.get()), pictList, SkSafeRef(f BBH.get()), 41 return new SkBigPicture(fBounds, SkRef(fRecord.get()), pictList, SkSafeRef(f BBH.get()),
52 saveLayerData.release(), subPictureBytes); 42 subPictureBytes);
53 } 43 }
54 44
55 void SkRecordedDrawable::flatten(SkWriteBuffer& buffer) const { 45 void SkRecordedDrawable::flatten(SkWriteBuffer& buffer) const {
56 // Write the bounds. 46 // Write the bounds.
57 buffer.writeRect(fBounds); 47 buffer.writeRect(fBounds);
58 48
59 // Create an SkPictureRecord to record the draw commands. 49 // Create an SkPictureRecord to record the draw commands.
60 SkPictInfo info; 50 SkPictInfo info;
61 SkPictureRecord pictureRecord(SkISize::Make(fBounds.width(), fBounds.height( )), 0); 51 SkPictureRecord pictureRecord(SkISize::Make(fBounds.width(), fBounds.height( )), 0);
62 52
(...skipping 30 matching lines...) Expand all
93 if (!pictureData) { 83 if (!pictureData) {
94 return nullptr; 84 return nullptr;
95 } 85 }
96 86
97 // Create a drawable. 87 // Create a drawable.
98 SkPicturePlayback playback(pictureData); 88 SkPicturePlayback playback(pictureData);
99 SkPictureRecorder recorder; 89 SkPictureRecorder recorder;
100 playback.draw(recorder.beginRecording(bounds), nullptr, &buffer); 90 playback.draw(recorder.beginRecording(bounds), nullptr, &buffer);
101 return recorder.finishRecordingAsDrawable(); 91 return recorder.finishRecordingAsDrawable();
102 } 92 }
OLDNEW
« no previous file with comments | « src/core/SkRecordedDrawable.h ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698