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" |
11 #include "GrGpu.h" | 11 #include "GrGpu.h" |
12 #include "GrRectanizer.h" | 12 #include "GrRectanizer.h" |
| 13 #include "GrTracing.h" |
13 | 14 |
14 /////////////////////////////////////////////////////////////////////////////// | 15 /////////////////////////////////////////////////////////////////////////////// |
15 | 16 |
16 // for testing | 17 // for testing |
17 #define FONT_CACHE_STATS 0 | 18 #define FONT_CACHE_STATS 0 |
18 #if FONT_CACHE_STATS | 19 #if FONT_CACHE_STATS |
19 static int g_UploadCount = 0; | 20 static int g_UploadCount = 0; |
20 #endif | 21 #endif |
21 | 22 |
22 GrPlot::GrPlot() : fDrawToken(NULL, 0) | 23 GrPlot::GrPlot() : fDrawToken(NULL, 0) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 imagePtr += fBytesPerPixel*width; | 84 imagePtr += fBytesPerPixel*width; |
84 } | 85 } |
85 | 86 |
86 fDirtyRect.join(loc->fX, loc->fY, loc->fX + width, loc->fY + height); | 87 fDirtyRect.join(loc->fX, loc->fY, loc->fX + width, loc->fY + height); |
87 adjust_for_offset(loc, fOffset); | 88 adjust_for_offset(loc, fOffset); |
88 fDirty = true; | 89 fDirty = true; |
89 // otherwise, just upload the image directly | 90 // otherwise, just upload the image directly |
90 } else { | 91 } else { |
91 adjust_for_offset(loc, fOffset); | 92 adjust_for_offset(loc, fOffset); |
92 GrContext* context = fTexture->getContext(); | 93 GrContext* context = fTexture->getContext(); |
| 94 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), "GrPlot::uploadToTex
ture"); |
93 context->writeTexturePixels(fTexture, | 95 context->writeTexturePixels(fTexture, |
94 loc->fX, loc->fY, width, height, | 96 loc->fX, loc->fY, width, height, |
95 fTexture->config(), image, 0, | 97 fTexture->config(), image, 0, |
96 GrContext::kDontFlush_PixelOpsFlag); | 98 GrContext::kDontFlush_PixelOpsFlag); |
97 } | 99 } |
98 | 100 |
99 #if FONT_CACHE_STATS | 101 #if FONT_CACHE_STATS |
100 ++g_UploadCount; | 102 ++g_UploadCount; |
101 #endif | 103 #endif |
102 | 104 |
103 return true; | 105 return true; |
104 } | 106 } |
105 | 107 |
106 void GrPlot::uploadToTexture() { | 108 void GrPlot::uploadToTexture() { |
107 static const float kNearlyFullTolerance = 0.85f; | 109 static const float kNearlyFullTolerance = 0.85f; |
108 | 110 |
109 // should only do this if batching is enabled | 111 // should only do this if batching is enabled |
110 SkASSERT(fBatchUploads); | 112 SkASSERT(fBatchUploads); |
111 | 113 |
112 if (fDirty) { | 114 if (fDirty) { |
| 115 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), "GrPlot::uploadToTex
ture"); |
113 SkASSERT(NULL != fTexture); | 116 SkASSERT(NULL != fTexture); |
114 GrContext* context = fTexture->getContext(); | 117 GrContext* context = fTexture->getContext(); |
115 // We pass the flag that does not force a flush. We assume our caller is | 118 // We pass the flag that does not force a flush. We assume our caller is |
116 // smart and hasn't referenced the part of the texture we're about to up
date | 119 // smart and hasn't referenced the part of the texture we're about to up
date |
117 // since the last flush. | 120 // since the last flush. |
118 int rowBytes = fBytesPerPixel*fRects->width(); | 121 size_t rowBytes = fBytesPerPixel*fRects->width(); |
119 const unsigned char* dataPtr = fPlotData; | 122 const unsigned char* dataPtr = fPlotData; |
120 dataPtr += rowBytes*fDirtyRect.fTop; | 123 dataPtr += rowBytes*fDirtyRect.fTop; |
121 dataPtr += fBytesPerPixel*fDirtyRect.fLeft; | 124 dataPtr += fBytesPerPixel*fDirtyRect.fLeft; |
122 context->writeTexturePixels(fTexture, | 125 context->writeTexturePixels(fTexture, |
123 fOffset.fX + fDirtyRect.fLeft, fOffset.fY +
fDirtyRect.fTop, | 126 fOffset.fX + fDirtyRect.fLeft, fOffset.fY +
fDirtyRect.fTop, |
124 fDirtyRect.width(), fDirtyRect.height(), | 127 fDirtyRect.width(), fDirtyRect.height(), |
125 fTexture->config(), dataPtr, | 128 fTexture->config(), dataPtr, |
126 rowBytes, | 129 rowBytes, |
127 GrContext::kDontFlush_PixelOpsFlag); | 130 GrContext::kDontFlush_PixelOpsFlag); |
128 fDirtyRect.setEmpty(); | 131 fDirtyRect.setEmpty(); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 if (fBatchUploads) { | 284 if (fBatchUploads) { |
282 GrPlotList::Iter plotIter; | 285 GrPlotList::Iter plotIter; |
283 plotIter.init(fPlotList, GrPlotList::Iter::kHead_IterStart); | 286 plotIter.init(fPlotList, GrPlotList::Iter::kHead_IterStart); |
284 GrPlot* plot; | 287 GrPlot* plot; |
285 while (NULL != (plot = plotIter.get())) { | 288 while (NULL != (plot = plotIter.get())) { |
286 plot->uploadToTexture(); | 289 plot->uploadToTexture(); |
287 plotIter.next(); | 290 plotIter.next(); |
288 } | 291 } |
289 } | 292 } |
290 } | 293 } |
OLD | NEW |