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

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

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 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
« no previous file with comments | « src/pipe/utils/SamplePipeControllers.h ('k') | src/ports/SkFontConfigInterface_direct.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 "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkGPipe.h" 11 #include "SkGPipe.h"
12 #include "SkMatrix.h" 12 #include "SkMatrix.h"
13 13
14 PipeController::PipeController(SkCanvas* target, SkPicture::InstallPixelRefProc proc) 14 PipeController::PipeController(SkCanvas* target, SkPicture::InstallPixelRefProc proc)
15 :fReader(target) { 15 :fReader(target) {
16 fBlock = NULL; 16 fBlock = nullptr;
17 fBlockSize = fBytesWritten = 0; 17 fBlockSize = fBytesWritten = 0;
18 fReader.setBitmapDecoder(proc); 18 fReader.setBitmapDecoder(proc);
19 } 19 }
20 20
21 PipeController::~PipeController() { 21 PipeController::~PipeController() {
22 sk_free(fBlock); 22 sk_free(fBlock);
23 } 23 }
24 24
25 void* PipeController::requestBlock(size_t minRequest, size_t *actual) { 25 void* PipeController::requestBlock(size_t minRequest, size_t *actual) {
26 sk_free(fBlock); 26 sk_free(fBlock);
27 fBlockSize = minRequest; 27 fBlockSize = minRequest;
28 fBlock = sk_malloc_throw(fBlockSize); 28 fBlock = sk_malloc_throw(fBlockSize);
29 fBytesWritten = 0; 29 fBytesWritten = 0;
30 *actual = fBlockSize; 30 *actual = fBlockSize;
31 return fBlock; 31 return fBlock;
32 } 32 }
33 33
34 void PipeController::notifyWritten(size_t bytes) { 34 void PipeController::notifyWritten(size_t bytes) {
35 fStatus = fReader.playback(this->getData(), bytes); 35 fStatus = fReader.playback(this->getData(), bytes);
36 SkASSERT(SkGPipeReader::kError_Status != fStatus); 36 SkASSERT(SkGPipeReader::kError_Status != fStatus);
37 fBytesWritten += bytes; 37 fBytesWritten += bytes;
38 } 38 }
39 39
40 //////////////////////////////////////////////////////////////////////////////// 40 ////////////////////////////////////////////////////////////////////////////////
41 41
42 TiledPipeController::TiledPipeController(const SkBitmap& bitmap, 42 TiledPipeController::TiledPipeController(const SkBitmap& bitmap,
43 SkPicture::InstallPixelRefProc proc, 43 SkPicture::InstallPixelRefProc proc,
44 const SkMatrix* initial) 44 const SkMatrix* initial)
45 : INHERITED(NULL, proc) { 45 : INHERITED(nullptr, proc) {
46 int32_t top = 0; 46 int32_t top = 0;
47 int32_t bottom; 47 int32_t bottom;
48 int32_t height = bitmap.height() / NumberOfTiles; 48 int32_t height = bitmap.height() / NumberOfTiles;
49 SkIRect rect; 49 SkIRect rect;
50 for (int i = 0; i < NumberOfTiles; i++) { 50 for (int i = 0; i < NumberOfTiles; i++) {
51 bottom = i + 1 == NumberOfTiles ? bitmap.height() : top + height; 51 bottom = i + 1 == NumberOfTiles ? bitmap.height() : top + height;
52 rect.setLTRB(0, top, bitmap.width(), bottom); 52 rect.setLTRB(0, top, bitmap.width(), bottom);
53 top = bottom; 53 top = bottom;
54 54
55 SkDEBUGCODE(bool extracted = )bitmap.extractSubset(&fBitmaps[i], rect); 55 SkDEBUGCODE(bool extracted = )bitmap.extractSubset(&fBitmaps[i], rect);
56 SkASSERT(extracted); 56 SkASSERT(extracted);
57 SkCanvas* canvas = new SkCanvas(fBitmaps[i]); 57 SkCanvas* canvas = new SkCanvas(fBitmaps[i]);
58 if (initial != NULL) { 58 if (initial != nullptr) {
59 canvas->setMatrix(*initial); 59 canvas->setMatrix(*initial);
60 } 60 }
61 canvas->translate(SkIntToScalar(-rect.left()), 61 canvas->translate(SkIntToScalar(-rect.left()),
62 SkIntToScalar(-rect.top())); 62 SkIntToScalar(-rect.top()));
63 if (0 == i) { 63 if (0 == i) {
64 fReader.setCanvas(canvas); 64 fReader.setCanvas(canvas);
65 } else { 65 } else {
66 fReaders[i - 1].setCanvas(canvas); 66 fReaders[i - 1].setCanvas(canvas);
67 fReaders[i - 1].setBitmapDecoder(proc); 67 fReaders[i - 1].setBitmapDecoder(proc);
68 } 68 }
69 canvas->unref(); 69 canvas->unref();
70 } 70 }
71 } 71 }
72 72
73 void TiledPipeController::notifyWritten(size_t bytes) { 73 void TiledPipeController::notifyWritten(size_t bytes) {
74 for (int i = 0; i < NumberOfTiles - 1; i++) { 74 for (int i = 0; i < NumberOfTiles - 1; i++) {
75 fReaders[i].playback(this->getData(), bytes); 75 fReaders[i].playback(this->getData(), bytes);
76 } 76 }
77 this->INHERITED::notifyWritten(bytes); 77 this->INHERITED::notifyWritten(bytes);
78 } 78 }
79 79
80 //////////////////////////////////////////////////////////////////////////////// 80 ////////////////////////////////////////////////////////////////////////////////
81 81
82 ThreadSafePipeController::ThreadSafePipeController(int numberOfReaders) 82 ThreadSafePipeController::ThreadSafePipeController(int numberOfReaders)
83 : fAllocator(kMinBlockSize) 83 : fAllocator(kMinBlockSize)
84 , fNumberOfReaders(numberOfReaders) { 84 , fNumberOfReaders(numberOfReaders) {
85 fBlock = NULL; 85 fBlock = nullptr;
86 fBytesWritten = 0; 86 fBytesWritten = 0;
87 } 87 }
88 88
89 void* ThreadSafePipeController::requestBlock(size_t minRequest, size_t *actual) { 89 void* ThreadSafePipeController::requestBlock(size_t minRequest, size_t *actual) {
90 if (fBlock) { 90 if (fBlock) {
91 // Save the previous block for later 91 // Save the previous block for later
92 PipeBlock previousBloc(fBlock, fBytesWritten); 92 PipeBlock previousBloc(fBlock, fBytesWritten);
93 fBlockList.push(previousBloc); 93 fBlockList.push(previousBloc);
94 } 94 }
95 int32_t blockSize = SkMax32(SkToS32(minRequest), kMinBlockSize); 95 int32_t blockSize = SkMax32(SkToS32(minRequest), kMinBlockSize);
(...skipping 10 matching lines...) Expand all
106 void ThreadSafePipeController::draw(SkCanvas* target) { 106 void ThreadSafePipeController::draw(SkCanvas* target) {
107 SkGPipeReader reader(target); 107 SkGPipeReader reader(target);
108 for (int currentBlock = 0; currentBlock < fBlockList.count(); currentBlock++ ) { 108 for (int currentBlock = 0; currentBlock < fBlockList.count(); currentBlock++ ) {
109 reader.playback(fBlockList[currentBlock].fBlock, fBlockList[currentBlock ].fBytes); 109 reader.playback(fBlockList[currentBlock].fBlock, fBlockList[currentBlock ].fBytes);
110 } 110 }
111 111
112 if (fBlock) { 112 if (fBlock) {
113 reader.playback(fBlock, fBytesWritten); 113 reader.playback(fBlock, fBytesWritten);
114 } 114 }
115 } 115 }
OLDNEW
« no previous file with comments | « src/pipe/utils/SamplePipeControllers.h ('k') | src/ports/SkFontConfigInterface_direct.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698