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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
285 *drawPreference = kNoDraw_DrawPreference; | 286 *drawPreference = kNoDraw_DrawPreference; |
286 } | 287 } |
287 return true; | 288 return true; |
288 } | 289 } |
289 | 290 |
290 bool GrGpu::readPixels(GrSurface* surface, | 291 bool GrGpu::readPixels(GrSurface* surface, |
291 int left, int top, int width, int height, | 292 int left, int top, int width, int height, |
292 GrPixelConfig config, void* buffer, | 293 GrPixelConfig config, void* buffer, |
293 size_t rowBytes) { | 294 size_t rowBytes) { |
294 this->handleDirtyContext(); | 295 this->handleDirtyContext(); |
295 return this->onReadPixels(surface, left, top, width, height, config, buffer, rowBytes); | 296 |
297 // We cannot read pixels into a compressed buffer | |
egdaniel
2015/07/30 18:00:49
It can be argued this one is dependent on the back
bsalomon
2015/07/30 18:27:22
If we're going to do this then we should also move
egdaniel
2015/07/30 18:47:34
Done.
| |
298 if (GrPixelConfigIsCompressed(config)) { | |
299 return false; | |
300 } | |
301 | |
302 size_t bpp = GrBytesPerPixel(config); | |
303 if (!GrSurfacePriv::AdjustReadPixelParams(surface->width(), surface->height( ), bpp, | |
304 &left, &top, &width, &height, | |
305 &buffer, | |
306 &rowBytes)) { | |
307 return false; | |
308 } | |
309 | |
310 size_t tightRowBytes = bpp * width; | |
311 if (0 == rowBytes) { | |
bsalomon
2015/07/30 18:27:22
AdjustReadPixelParams already does this (sets rowB
egdaniel
2015/07/30 18:47:34
Done.
| |
312 rowBytes = tightRowBytes; | |
313 } | |
314 | |
315 return this->onReadPixels(surface, | |
316 left, top, width, height, | |
317 config, buffer, | |
318 rowBytes ? rowBytes : tightRowBytes, | |
319 tightRowBytes); | |
296 } | 320 } |
297 | 321 |
298 bool GrGpu::writePixels(GrSurface* surface, | 322 bool GrGpu::writePixels(GrSurface* surface, |
299 int left, int top, int width, int height, | 323 int left, int top, int width, int height, |
300 GrPixelConfig config, const void* buffer, | 324 GrPixelConfig config, const void* buffer, |
301 size_t rowBytes) { | 325 size_t rowBytes) { |
302 this->handleDirtyContext(); | 326 this->handleDirtyContext(); |
303 if (this->onWritePixels(surface, left, top, width, height, config, buffer, r owBytes)) { | 327 if (this->onWritePixels(surface, left, top, width, height, config, buffer, r owBytes)) { |
304 fStats.incTextureUploads(); | 328 fStats.incTextureUploads(); |
305 return true; | 329 return true; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 //////////////////////////////////////////////////////////////////////////////// | 381 //////////////////////////////////////////////////////////////////////////////// |
358 | 382 |
359 void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) { | 383 void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) { |
360 this->handleDirtyContext(); | 384 this->handleDirtyContext(); |
361 GrVertices::Iterator iter; | 385 GrVertices::Iterator iter; |
362 const GrNonInstancedVertices* verts = iter.init(vertices); | 386 const GrNonInstancedVertices* verts = iter.init(vertices); |
363 do { | 387 do { |
364 this->onDraw(args, *verts); | 388 this->onDraw(args, *verts); |
365 } while ((verts = iter.next())); | 389 } while ((verts = iter.next())); |
366 } | 390 } |
OLD | NEW |