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

Side by Side Diff: src/pipe/utils/SamplePipeControllers.cpp

Issue 277653004: Manually revert "4x allocation in PipeController is probably overkill." (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 7 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/pipe/utils/SamplePipeControllers.h ('k') | tests/DeferredCanvasTest.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 2012 Google Inc. 2 * Copyright 2012 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 "SamplePipeControllers.h" 8 #include "SamplePipeControllers.h"
9 9
10 #include "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 #include "SkGPipe.h" 12 #include "SkGPipe.h"
13 #include "SkMatrix.h" 13 #include "SkMatrix.h"
14 14
15 PipeController::PipeController(SkCanvas* target, SkPicture::InstallPixelRefProc proc) 15 PipeController::PipeController(SkCanvas* target, SkPicture::InstallPixelRefProc proc)
16 : fReader(target), fBlockSize(0), fBytesWritten(0) { 16 :fReader(target) {
17 fBlock = NULL;
18 fBlockSize = fBytesWritten = 0;
17 fReader.setBitmapDecoder(proc); 19 fReader.setBitmapDecoder(proc);
18 } 20 }
19 21
20 void* PipeController::requestBlock(size_t minRequest, size_t* actual) { 22 PipeController::~PipeController() {
21 fBlockSize = minRequest; 23 sk_free(fBlock);
22 fBlock.reset(fBlockSize); 24 }
25
26 void* PipeController::requestBlock(size_t minRequest, size_t *actual) {
27 sk_free(fBlock);
28 fBlockSize = minRequest * 4;
29 fBlock = sk_malloc_throw(fBlockSize);
23 fBytesWritten = 0; 30 fBytesWritten = 0;
24 *actual = fBlockSize; 31 *actual = fBlockSize;
25 return fBlock.get(); 32 return fBlock;
26 } 33 }
27 34
28 void PipeController::notifyWritten(size_t bytes) { 35 void PipeController::notifyWritten(size_t bytes) {
29 fStatus = fReader.playback(this->getData(), bytes); 36 fStatus = fReader.playback(this->getData(), bytes);
30 SkASSERT(SkGPipeReader::kError_Status != fStatus); 37 SkASSERT(SkGPipeReader::kError_Status != fStatus);
31 fBytesWritten += bytes; 38 fBytesWritten += bytes;
32 } 39 }
33 40
34 //////////////////////////////////////////////////////////////////////////////// 41 ////////////////////////////////////////////////////////////////////////////////
35 42
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 void ThreadSafePipeController::draw(SkCanvas* target) { 109 void ThreadSafePipeController::draw(SkCanvas* target) {
103 SkGPipeReader reader(target); 110 SkGPipeReader reader(target);
104 for (int currentBlock = 0; currentBlock < fBlockList.count(); currentBlock++ ) { 111 for (int currentBlock = 0; currentBlock < fBlockList.count(); currentBlock++ ) {
105 reader.playback(fBlockList[currentBlock].fBlock, fBlockList[currentBlock ].fBytes); 112 reader.playback(fBlockList[currentBlock].fBlock, fBlockList[currentBlock ].fBytes);
106 } 113 }
107 114
108 if (fBlock) { 115 if (fBlock) {
109 reader.playback(fBlock, fBytesWritten); 116 reader.playback(fBlock, fBytesWritten);
110 } 117 }
111 } 118 }
OLDNEW
« no previous file with comments | « src/pipe/utils/SamplePipeControllers.h ('k') | tests/DeferredCanvasTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698