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" |
(...skipping 27 matching lines...) Expand all Loading... |
38 fIndexBuffer.reset(di.indexBuffer()); | 38 fIndexBuffer.reset(di.indexBuffer()); |
39 | 39 |
40 return *this; | 40 return *this; |
41 } | 41 } |
42 | 42 |
43 //////////////////////////////////////////////////////////////////////////////// | 43 //////////////////////////////////////////////////////////////////////////////// |
44 | 44 |
45 GrGpu::GrGpu(GrContext* context) | 45 GrGpu::GrGpu(GrContext* context) |
46 : fResetTimestamp(kExpiredTimestamp+1) | 46 : fResetTimestamp(kExpiredTimestamp+1) |
47 , fResetBits(kAll_GrBackendState) | 47 , fResetBits(kAll_GrBackendState) |
48 , fGpuTraceMarkerCount(0) | |
49 , fContext(context) { | 48 , fContext(context) { |
50 } | 49 } |
51 | 50 |
52 GrGpu::~GrGpu() {} | 51 GrGpu::~GrGpu() {} |
53 | 52 |
54 void GrGpu::contextAbandoned() {} | 53 void GrGpu::contextAbandoned() {} |
55 | 54 |
56 //////////////////////////////////////////////////////////////////////////////// | 55 //////////////////////////////////////////////////////////////////////////////// |
57 | 56 |
58 static GrSurfaceOrigin resolve_origin(GrSurfaceOrigin origin, bool renderTarget)
{ | 57 static GrSurfaceOrigin resolve_origin(GrSurfaceOrigin origin, bool renderTarget)
{ |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 } | 338 } |
340 return false; | 339 return false; |
341 } | 340 } |
342 | 341 |
343 void GrGpu::resolveRenderTarget(GrRenderTarget* target) { | 342 void GrGpu::resolveRenderTarget(GrRenderTarget* target) { |
344 SkASSERT(target); | 343 SkASSERT(target); |
345 this->handleDirtyContext(); | 344 this->handleDirtyContext(); |
346 this->onResolveRenderTarget(target); | 345 this->onResolveRenderTarget(target); |
347 } | 346 } |
348 | 347 |
349 typedef GrTraceMarkerSet::Iter TMIter; | |
350 void GrGpu::saveActiveTraceMarkers() { | |
351 if (this->caps()->gpuTracingSupport()) { | |
352 SkASSERT(0 == fStoredTraceMarkers.count()); | |
353 fStoredTraceMarkers.addSet(fActiveTraceMarkers); | |
354 for (TMIter iter = fStoredTraceMarkers.begin(); iter != fStoredTraceMark
ers.end(); ++iter) { | |
355 this->removeGpuTraceMarker(&(*iter)); | |
356 } | |
357 } | |
358 } | |
359 | |
360 void GrGpu::restoreActiveTraceMarkers() { | |
361 if (this->caps()->gpuTracingSupport()) { | |
362 SkASSERT(0 == fActiveTraceMarkers.count()); | |
363 for (TMIter iter = fStoredTraceMarkers.begin(); iter != fStoredTraceMark
ers.end(); ++iter) { | |
364 this->addGpuTraceMarker(&(*iter)); | |
365 } | |
366 for (TMIter iter = fActiveTraceMarkers.begin(); iter != fActiveTraceMark
ers.end(); ++iter) { | |
367 this->fStoredTraceMarkers.remove(*iter); | |
368 } | |
369 } | |
370 } | |
371 | |
372 void GrGpu::addGpuTraceMarker(const GrGpuTraceMarker* marker) { | |
373 if (this->caps()->gpuTracingSupport()) { | |
374 SkASSERT(fGpuTraceMarkerCount >= 0); | |
375 this->fActiveTraceMarkers.add(*marker); | |
376 this->didAddGpuTraceMarker(); | |
377 ++fGpuTraceMarkerCount; | |
378 } | |
379 } | |
380 | |
381 void GrGpu::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { | |
382 if (this->caps()->gpuTracingSupport()) { | |
383 SkASSERT(fGpuTraceMarkerCount >= 1); | |
384 this->fActiveTraceMarkers.remove(*marker); | |
385 this->didRemoveGpuTraceMarker(); | |
386 --fGpuTraceMarkerCount; | |
387 } | |
388 } | |
389 | |
390 //////////////////////////////////////////////////////////////////////////////// | 348 //////////////////////////////////////////////////////////////////////////////// |
391 | 349 |
392 void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) { | 350 void GrGpu::draw(const DrawArgs& args, const GrVertices& vertices) { |
393 this->handleDirtyContext(); | 351 this->handleDirtyContext(); |
394 if (GrXferBarrierType barrierType = args.fPipeline->xferBarrierType(*this->c
aps())) { | 352 if (GrXferBarrierType barrierType = args.fPipeline->xferBarrierType(*this->c
aps())) { |
395 this->xferBarrier(args.fPipeline->getRenderTarget(), barrierType); | 353 this->xferBarrier(args.fPipeline->getRenderTarget(), barrierType); |
396 } | 354 } |
397 | 355 |
398 GrVertices::Iterator iter; | 356 GrVertices::Iterator iter; |
399 const GrNonInstancedVertices* verts = iter.init(vertices); | 357 const GrNonInstancedVertices* verts = iter.init(vertices); |
400 do { | 358 do { |
401 this->onDraw(args, *verts); | 359 this->onDraw(args, *verts); |
402 } while ((verts = iter.next())); | 360 } while ((verts = iter.next())); |
403 } | 361 } |
OLD | NEW |