LCOV - code coverage report
Current view: top level - gfx/skia/skia/src/gpu/ops - GrOp.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 15 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 8 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright 2015 Google Inc.
       3             :  *
       4             :  * Use of this source code is governed by a BSD-style license that can be
       5             :  * found in the LICENSE file.
       6             :  */
       7             : 
       8             : #include "GrOp.h"
       9             : 
      10             : #include "GrMemoryPool.h"
      11             : #include "SkSpinlock.h"
      12             : 
      13             : // TODO I noticed a small benefit to using a larger exclusive pool for ops. Its very small, but
      14             : // seems to be mostly consistent.  There is a lot in flux right now, but we should really revisit
      15             : // this.
      16             : 
      17             : 
      18             : // We use a global pool protected by a mutex(spinlock). Chrome may use the same GrContext on
      19             : // different threads. The GrContext is not used concurrently on different threads and there is a
      20             : // memory barrier between accesses of a context on different threads. Also, there may be multiple
      21             : // GrContexts and those contexts may be in use concurrently on different threads.
      22             : namespace {
      23             : static SkSpinlock gOpPoolSpinLock;
      24             : class MemoryPoolAccessor {
      25             : public:
      26             : 
      27             : // We know in the Android framework there is only one GrContext.
      28             : #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
      29             :     MemoryPoolAccessor() {}
      30             :     ~MemoryPoolAccessor() {}
      31             : #else
      32           0 :     MemoryPoolAccessor() { gOpPoolSpinLock.acquire(); }
      33           0 :     ~MemoryPoolAccessor() { gOpPoolSpinLock.release(); }
      34             : #endif
      35             : 
      36           0 :     GrMemoryPool* pool() const {
      37           0 :         static GrMemoryPool gPool(16384, 16384);
      38           0 :         return &gPool;
      39             :     }
      40             : };
      41             : }
      42             : 
      43             : int32_t GrOp::gCurrOpClassID = GrOp::kIllegalOpID;
      44             : 
      45             : int32_t GrOp::gCurrOpUniqueID = GrOp::kIllegalOpID;
      46             : 
      47           0 : void* GrOp::operator new(size_t size) {
      48           0 :     return MemoryPoolAccessor().pool()->allocate(size);
      49             : }
      50             : 
      51           0 : void GrOp::operator delete(void* target) {
      52           0 :     return MemoryPoolAccessor().pool()->release(target);
      53             : }
      54             : 
      55           0 : GrOp::GrOp(uint32_t classID)
      56             :     : fClassID(classID)
      57           0 :     , fUniqueID(kIllegalOpID) {
      58           0 :     SkASSERT(classID == SkToU32(fClassID));
      59           0 :     SkDEBUGCODE(fBoundsFlags = kUninitialized_BoundsFlag);
      60           0 : }
      61             : 
      62           0 : GrOp::~GrOp() {}

Generated by: LCOV version 1.13