OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrAtlas.h" | 9 #include "GrAtlas.h" |
10 #include "GrContext.h" | 10 #include "GrContext.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 { | 55 { |
56 fRects = GrRectanizer::Factory(GR_ATLAS_WIDTH - BORDER, | 56 fRects = GrRectanizer::Factory(GR_ATLAS_WIDTH - BORDER, |
57 GR_ATLAS_HEIGHT - BORDER); | 57 GR_ATLAS_HEIGHT - BORDER); |
58 fOffset.set(0, 0); | 58 fOffset.set(0, 0); |
59 } | 59 } |
60 | 60 |
61 GrPlot::~GrPlot() { | 61 GrPlot::~GrPlot() { |
62 delete fRects; | 62 delete fRects; |
63 } | 63 } |
64 | 64 |
65 static void adjust_for_offset(GrIPoint16* loc, const GrIPoint16& offset) { | 65 static inline void adjust_for_offset(GrIPoint16* loc, const GrIPoint16& offset)
{ |
66 loc->fX += offset.fX * GR_ATLAS_WIDTH; | 66 loc->fX += offset.fX * GR_ATLAS_WIDTH; |
67 loc->fY += offset.fY * GR_ATLAS_HEIGHT; | 67 loc->fY += offset.fY * GR_ATLAS_HEIGHT; |
68 } | 68 } |
69 | 69 |
70 static uint8_t* zero_fill(uint8_t* ptr, int count) { | 70 static inline uint8_t* zero_fill(uint8_t* ptr, size_t count) { |
71 while (--count >= 0) { | 71 sk_bzero(ptr, count); |
72 *ptr++ = 0; | 72 return ptr + count; |
73 } | |
74 return ptr; | |
75 } | 73 } |
76 | 74 |
77 bool GrPlot::addSubImage(int width, int height, const void* image, | 75 bool GrPlot::addSubImage(int width, int height, const void* image, |
78 GrIPoint16* loc) { | 76 GrIPoint16* loc) { |
79 if (!fRects->addRect(width + BORDER, height + BORDER, loc)) { | 77 if (!fRects->addRect(width + BORDER, height + BORDER, loc)) { |
80 return false; | 78 return false; |
81 } | 79 } |
82 | 80 |
83 SkAutoSMalloc<1024> storage; | 81 SkAutoSMalloc<1024> storage; |
84 int dstW = width + 2*BORDER; | 82 int dstW = width + 2*BORDER; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 119 |
122 /////////////////////////////////////////////////////////////////////////////// | 120 /////////////////////////////////////////////////////////////////////////////// |
123 | 121 |
124 GrAtlasMgr::GrAtlasMgr(GrGpu* gpu, GrPixelConfig config) { | 122 GrAtlasMgr::GrAtlasMgr(GrGpu* gpu, GrPixelConfig config) { |
125 fGpu = gpu; | 123 fGpu = gpu; |
126 fPixelConfig = config; | 124 fPixelConfig = config; |
127 gpu->ref(); | 125 gpu->ref(); |
128 fTexture = NULL; | 126 fTexture = NULL; |
129 | 127 |
130 // set up allocated plots | 128 // set up allocated plots |
131 int bpp = GrBytesPerPixel(fPixelConfig); | 129 size_t bpp = GrBytesPerPixel(fPixelConfig); |
132 fPlots = SkNEW_ARRAY(GrPlot, (GR_PLOT_WIDTH*GR_PLOT_HEIGHT)); | 130 fPlots = SkNEW_ARRAY(GrPlot, (GR_PLOT_WIDTH*GR_PLOT_HEIGHT)); |
133 fFreePlots = NULL; | 131 fFreePlots = NULL; |
134 GrPlot* currPlot = fPlots; | 132 GrPlot* currPlot = fPlots; |
135 for (int y = GR_PLOT_HEIGHT-1; y >= 0; --y) { | 133 for (int y = GR_PLOT_HEIGHT-1; y >= 0; --y) { |
136 for (int x = GR_PLOT_WIDTH-1; x >= 0; --x) { | 134 for (int x = GR_PLOT_WIDTH-1; x >= 0; --x) { |
137 currPlot->fAtlasMgr = this; | 135 currPlot->fAtlasMgr = this; |
138 currPlot->fOffset.set(x, y); | 136 currPlot->fOffset.set(x, y); |
139 currPlot->fBytesPerPixel = bpp; | 137 currPlot->fBytesPerPixel = bpp; |
140 | 138 |
141 // add to free list | 139 // add to free list |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 | 259 |
262 plot->fRects->reset(); | 260 plot->fRects->reset(); |
263 plot->fNext = fFreePlots; | 261 plot->fNext = fFreePlots; |
264 fFreePlots = plot; | 262 fFreePlots = plot; |
265 | 263 |
266 #ifdef SK_DEBUG | 264 #ifdef SK_DEBUG |
267 --gCounter; | 265 --gCounter; |
268 // GrPrintf("~GrPlot %p [%d %d] %d\n", this, plot->fOffset.fX, plot->fOffset.
fY, gCounter); | 266 // GrPrintf("~GrPlot %p [%d %d] %d\n", this, plot->fOffset.fX, plot->fOffset.
fY, gCounter); |
269 #endif | 267 #endif |
270 } | 268 } |
OLD | NEW |