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

          Line data    Source code
       1             : /*
       2             :  * Copyright 2016 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 "GrBitmapTextureMaker.h"
       9             : 
      10             : #include "GrContext.h"
      11             : #include "GrGpuResourcePriv.h"
      12             : #include "GrResourceProvider.h"
      13             : #include "SkBitmap.h"
      14             : #include "SkGr.h"
      15             : #include "SkPixelRef.h"
      16             : 
      17           0 : static bool bmp_is_alpha_only(const SkBitmap& bm) { return kAlpha_8_SkColorType == bm.colorType(); }
      18             : 
      19           0 : GrBitmapTextureMaker::GrBitmapTextureMaker(GrContext* context, const SkBitmap& bitmap)
      20           0 :     : INHERITED(context, bitmap.width(), bitmap.height(), bmp_is_alpha_only(bitmap))
      21           0 :     , fBitmap(bitmap) {
      22           0 :     if (!bitmap.isVolatile()) {
      23           0 :         SkIPoint origin = bitmap.pixelRefOrigin();
      24             :         SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, bitmap.width(),
      25           0 :                                            bitmap.height());
      26           0 :         GrMakeKeyFromImageID(&fOriginalKey, bitmap.pixelRef()->getGenerationID(), subset);
      27             :     }
      28           0 : }
      29             : 
      30           0 : sk_sp<GrTextureProxy> GrBitmapTextureMaker::refOriginalTextureProxy(bool willBeMipped,
      31             :                                                                     SkColorSpace* dstColorSpace) {
      32           0 :     sk_sp<GrTextureProxy> proxy;
      33             : 
      34           0 :     if (fOriginalKey.isValid()) {
      35           0 :         proxy = this->context()->resourceProvider()->findProxyByUniqueKey(fOriginalKey);
      36           0 :         if (proxy) {
      37           0 :             return proxy;
      38             :         }
      39             :     }
      40           0 :     if (willBeMipped) {
      41           0 :         proxy = GrGenerateMipMapsAndUploadToTextureProxy(this->context(), fBitmap, dstColorSpace);
      42             :     }
      43           0 :     if (!proxy) {
      44           0 :         proxy = GrUploadBitmapToTextureProxy(this->context()->resourceProvider(), fBitmap);
      45             :     }
      46           0 :     if (proxy && fOriginalKey.isValid()) {
      47           0 :         this->context()->resourceProvider()->assignUniqueKeyToProxy(fOriginalKey, proxy.get());
      48             :         // MDB TODO (caching): this has to play nice with the GrSurfaceProxy's caching
      49           0 :         GrInstallBitmapUniqueKeyInvalidator(fOriginalKey, fBitmap.pixelRef());
      50             :     }
      51           0 :     return proxy;
      52             : }
      53             : 
      54           0 : void GrBitmapTextureMaker::makeCopyKey(const CopyParams& copyParams, GrUniqueKey* copyKey,
      55             :                                        SkColorSpace* dstColorSpace) {
      56             :     // Destination color space is irrelevant - we always upload the bitmap's contents as-is
      57           0 :     if (fOriginalKey.isValid()) {
      58           0 :         MakeCopyKeyFromOrigKey(fOriginalKey, copyParams, copyKey);
      59             :     }
      60           0 : }
      61             : 
      62           0 : void GrBitmapTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) {
      63           0 :     GrInstallBitmapUniqueKeyInvalidator(copyKey, fBitmap.pixelRef());
      64           0 : }
      65             : 
      66           0 : SkAlphaType GrBitmapTextureMaker::alphaType() const {
      67           0 :     return fBitmap.alphaType();
      68             : }
      69             : 
      70           0 : sk_sp<SkColorSpace> GrBitmapTextureMaker::getColorSpace(SkColorSpace* dstColorSpace) {
      71             :     // Color space doesn't depend on destination color space - it's just whatever is in the bitmap
      72           0 :     return fBitmap.refColorSpace();
      73             : }

Generated by: LCOV version 1.13