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 | 9 |
10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
11 | 11 |
12 #include "GrCaps.h" | 12 #include "GrCaps.h" |
13 #include "GrContext.h" | 13 #include "GrContext.h" |
14 #include "GrGpuResourcePriv.h" | 14 #include "GrGpuResourcePriv.h" |
15 #include "GrIndexBuffer.h" | 15 #include "GrIndexBuffer.h" |
16 #include "GrPathRendering.h" | 16 #include "GrPathRendering.h" |
17 #include "GrResourceCache.h" | 17 #include "GrResourceCache.h" |
18 #include "GrRenderTargetPriv.h" | 18 #include "GrRenderTargetPriv.h" |
19 #include "GrStencilAttachment.h" | 19 #include "GrStencilAttachment.h" |
| 20 #include "GrSurfacePriv.h" |
20 #include "GrVertexBuffer.h" | 21 #include "GrVertexBuffer.h" |
21 #include "GrVertices.h" | 22 #include "GrVertices.h" |
22 | 23 |
23 GrVertices& GrVertices::operator =(const GrVertices& di) { | 24 GrVertices& GrVertices::operator =(const GrVertices& di) { |
24 fPrimitiveType = di.fPrimitiveType; | 25 fPrimitiveType = di.fPrimitiveType; |
25 fStartVertex = di.fStartVertex; | 26 fStartVertex = di.fStartVertex; |
26 fStartIndex = di.fStartIndex; | 27 fStartIndex = di.fStartIndex; |
27 fVertexCount = di.fVertexCount; | 28 fVertexCount = di.fVertexCount; |
28 fIndexCount = di.fIndexCount; | 29 fIndexCount = di.fIndexCount; |
29 | 30 |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 this->onClearStencilClip(renderTarget, rect, insideClip); | 233 this->onClearStencilClip(renderTarget, rect, insideClip); |
233 } | 234 } |
234 | 235 |
235 bool GrGpu::getReadPixelsInfo(GrSurface* srcSurface, int width, int height, size
_t rowBytes, | 236 bool GrGpu::getReadPixelsInfo(GrSurface* srcSurface, int width, int height, size
_t rowBytes, |
236 GrPixelConfig readConfig, DrawPreference* drawPref
erence, | 237 GrPixelConfig readConfig, DrawPreference* drawPref
erence, |
237 ReadPixelTempDrawInfo* tempDrawInfo) { | 238 ReadPixelTempDrawInfo* tempDrawInfo) { |
238 SkASSERT(drawPreference); | 239 SkASSERT(drawPreference); |
239 SkASSERT(tempDrawInfo); | 240 SkASSERT(tempDrawInfo); |
240 SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference); | 241 SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference); |
241 | 242 |
| 243 // We currently do not support reading into a compressed buffer |
| 244 if (GrPixelConfigIsCompressed(readConfig)) { |
| 245 return false; |
| 246 } |
| 247 |
242 if (!this->onGetReadPixelsInfo(srcSurface, width, height, rowBytes, readConf
ig, drawPreference, | 248 if (!this->onGetReadPixelsInfo(srcSurface, width, height, rowBytes, readConf
ig, drawPreference, |
243 tempDrawInfo)) { | 249 tempDrawInfo)) { |
244 return false; | 250 return false; |
245 } | 251 } |
246 | 252 |
247 // Check to see if we're going to request that the caller draw when drawing
is not possible. | 253 // Check to see if we're going to request that the caller draw when drawing
is not possible. |
248 if (!srcSurface->asTexture() || | 254 if (!srcSurface->asTexture() || |
249 !this->caps()->isConfigRenderable(tempDrawInfo->fTempSurfaceDesc.fConfig
, false)) { | 255 !this->caps()->isConfigRenderable(tempDrawInfo->fTempSurfaceDesc.fConfig
, false)) { |
250 // If we don't have a fallback to a straight read then fail. | 256 // If we don't have a fallback to a straight read then fail. |
251 if (kRequireDraw_DrawPreference == *drawPreference) { | 257 if (kRequireDraw_DrawPreference == *drawPreference) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 *drawPreference = kNoDraw_DrawPreference; | 291 *drawPreference = kNoDraw_DrawPreference; |
286 } | 292 } |
287 return true; | 293 return true; |
288 } | 294 } |
289 | 295 |
290 bool GrGpu::readPixels(GrSurface* surface, | 296 bool GrGpu::readPixels(GrSurface* surface, |
291 int left, int top, int width, int height, | 297 int left, int top, int width, int height, |
292 GrPixelConfig config, void* buffer, | 298 GrPixelConfig config, void* buffer, |
293 size_t rowBytes) { | 299 size_t rowBytes) { |
294 this->handleDirtyContext(); | 300 this->handleDirtyContext(); |
295 return this->onReadPixels(surface, left, top, width, height, config, buffer,
rowBytes); | 301 |
| 302 // We cannot read pixels into a compressed buffer |
| 303 if (GrPixelConfigIsCompressed(config)) { |
| 304 return false; |
| 305 } |
| 306 |
| 307 size_t bpp = GrBytesPerPixel(config); |
| 308 if (!GrSurfacePriv::AdjustReadPixelParams(surface->width(), surface->height(
), bpp, |
| 309 &left, &top, &width, &height, |
| 310 &buffer, |
| 311 &rowBytes)) { |
| 312 return false; |
| 313 } |
| 314 |
| 315 return this->onReadPixels(surface, |
| 316 left, top, width, height, |
| 317 config, buffer, |
| 318 rowBytes); |
296 } | 319 } |
297 | 320 |
298 bool GrGpu::writePixels(GrSurface* surface, | 321 bool GrGpu::writePixels(GrSurface* surface, |
299 int left, int top, int width, int height, | 322 int left, int top, int width, int height, |
300 GrPixelConfig config, const void* buffer, | 323 GrPixelConfig config, const void* buffer, |
301 size_t rowBytes) { | 324 size_t rowBytes) { |
302 this->handleDirtyContext(); | 325 this->handleDirtyContext(); |
303 if (this->onWritePixels(surface, left, top, width, height, config, buffer, r
owBytes)) { | 326 if (this->onWritePixels(surface, left, top, width, height, config, buffer, r
owBytes)) { |
304 fStats.incTextureUploads(); | 327 fStats.incTextureUploads(); |
305 return true; | 328 return true; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 //////////////////////////////////////////////////////////////////////////////// | 380 //////////////////////////////////////////////////////////////////////////////// |
358 | 381 |
359 void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) { | 382 void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) { |
360 this->handleDirtyContext(); | 383 this->handleDirtyContext(); |
361 GrVertices::Iterator iter; | 384 GrVertices::Iterator iter; |
362 const GrNonInstancedVertices* verts = iter.init(vertices); | 385 const GrNonInstancedVertices* verts = iter.init(vertices); |
363 do { | 386 do { |
364 this->onDraw(args, *verts); | 387 this->onDraw(args, *verts); |
365 } while ((verts = iter.next())); | 388 } while ((verts = iter.next())); |
366 } | 389 } |
OLD | NEW |