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

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

Issue 283933002: Reland the 4x -> 1x allocation from "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 | « no previous file | no next file » | 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) { 16 :fReader(target) {
17 fBlock = NULL; 17 fBlock = NULL;
18 fBlockSize = fBytesWritten = 0; 18 fBlockSize = fBytesWritten = 0;
19 fReader.setBitmapDecoder(proc); 19 fReader.setBitmapDecoder(proc);
20 } 20 }
21 21
22 PipeController::~PipeController() { 22 PipeController::~PipeController() {
23 sk_free(fBlock); 23 sk_free(fBlock);
24 } 24 }
25 25
26 void* PipeController::requestBlock(size_t minRequest, size_t *actual) { 26 void* PipeController::requestBlock(size_t minRequest, size_t *actual) {
27 sk_free(fBlock); 27 sk_free(fBlock);
28 fBlockSize = minRequest * 4; 28 fBlockSize = minRequest;
29 fBlock = sk_malloc_throw(fBlockSize); 29 fBlock = sk_malloc_throw(fBlockSize);
30 fBytesWritten = 0; 30 fBytesWritten = 0;
31 *actual = fBlockSize; 31 *actual = fBlockSize;
32 return fBlock; 32 return fBlock;
33 } 33 }
34 34
35 void PipeController::notifyWritten(size_t bytes) { 35 void PipeController::notifyWritten(size_t bytes) {
36 fStatus = fReader.playback(this->getData(), bytes); 36 fStatus = fReader.playback(this->getData(), bytes);
37 SkASSERT(SkGPipeReader::kError_Status != fStatus); 37 SkASSERT(SkGPipeReader::kError_Status != fStatus);
38 fBytesWritten += bytes; 38 fBytesWritten += bytes;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 void ThreadSafePipeController::draw(SkCanvas* target) { 109 void ThreadSafePipeController::draw(SkCanvas* target) {
110 SkGPipeReader reader(target); 110 SkGPipeReader reader(target);
111 for (int currentBlock = 0; currentBlock < fBlockList.count(); currentBlock++ ) { 111 for (int currentBlock = 0; currentBlock < fBlockList.count(); currentBlock++ ) {
112 reader.playback(fBlockList[currentBlock].fBlock, fBlockList[currentBlock ].fBytes); 112 reader.playback(fBlockList[currentBlock].fBlock, fBlockList[currentBlock ].fBytes);
113 } 113 }
114 114
115 if (fBlock) { 115 if (fBlock) {
116 reader.playback(fBlock, fBytesWritten); 116 reader.playback(fBlock, fBytesWritten);
117 } 117 }
118 } 118 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698