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

          Line data    Source code
       1             : /*
       2             :  * Copyright 2014 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 "SkImage.h"
       9             : #include "SkImageGenerator.h"
      10             : #include "SkNextID.h"
      11             : 
      12           0 : SkImageGenerator::SkImageGenerator(const SkImageInfo& info, uint32_t uniqueID)
      13             :     : fInfo(info)
      14           0 :     , fUniqueID(kNeedNewImageUniqueID == uniqueID ? SkNextID::ImageID() : uniqueID)
      15           0 : {}
      16             : 
      17           0 : bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
      18             :                                  SkPMColor ctable[], int* ctableCount) {
      19           0 :     if (kUnknown_SkColorType == info.colorType()) {
      20           0 :         return false;
      21             :     }
      22           0 :     if (nullptr == pixels) {
      23           0 :         return false;
      24             :     }
      25           0 :     if (rowBytes < info.minRowBytes()) {
      26           0 :         return false;
      27             :     }
      28             : 
      29           0 :     if (kIndex_8_SkColorType == info.colorType()) {
      30           0 :         if (nullptr == ctable || nullptr == ctableCount) {
      31           0 :             return false;
      32             :         }
      33             :     } else {
      34           0 :         if (ctableCount) {
      35           0 :             *ctableCount = 0;
      36             :         }
      37           0 :         ctableCount = nullptr;
      38           0 :         ctable = nullptr;
      39             :     }
      40             : 
      41           0 :     const bool success = this->onGetPixels(info, pixels, rowBytes, ctable, ctableCount);
      42           0 :     if (success && ctableCount) {
      43           0 :         SkASSERT(*ctableCount >= 0 && *ctableCount <= 256);
      44             :     }
      45           0 :     return success;
      46             : }
      47             : 
      48           0 : bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
      49             :                                  const Options* opts) {
      50           0 :     Options defaultOpts;
      51           0 :     if (!opts) {
      52           0 :         opts = &defaultOpts;
      53             :     }
      54           0 :     return this->onGetPixels(info, pixels, rowBytes, *opts);
      55             : }
      56             : 
      57           0 : bool SkImageGenerator::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) {
      58           0 :     SkASSERT(kIndex_8_SkColorType != info.colorType());
      59           0 :     if (kIndex_8_SkColorType == info.colorType()) {
      60           0 :         return false;
      61             :     }
      62           0 :     return this->getPixels(info, pixels, rowBytes, nullptr, nullptr);
      63             : }
      64             : 
      65           0 : bool SkImageGenerator::queryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const {
      66           0 :     SkASSERT(sizeInfo);
      67             : 
      68           0 :     return this->onQueryYUV8(sizeInfo, colorSpace);
      69             : }
      70             : 
      71           0 : bool SkImageGenerator::getYUV8Planes(const SkYUVSizeInfo& sizeInfo, void* planes[3]) {
      72           0 :     SkASSERT(sizeInfo.fSizes[SkYUVSizeInfo::kY].fWidth >= 0);
      73           0 :     SkASSERT(sizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight >= 0);
      74           0 :     SkASSERT(sizeInfo.fSizes[SkYUVSizeInfo::kU].fWidth >= 0);
      75           0 :     SkASSERT(sizeInfo.fSizes[SkYUVSizeInfo::kU].fHeight >= 0);
      76           0 :     SkASSERT(sizeInfo.fSizes[SkYUVSizeInfo::kV].fWidth >= 0);
      77           0 :     SkASSERT(sizeInfo.fSizes[SkYUVSizeInfo::kV].fHeight >= 0);
      78           0 :     SkASSERT(sizeInfo.fWidthBytes[SkYUVSizeInfo::kY] >=
      79             :             (size_t) sizeInfo.fSizes[SkYUVSizeInfo::kY].fWidth);
      80           0 :     SkASSERT(sizeInfo.fWidthBytes[SkYUVSizeInfo::kU] >=
      81             :             (size_t) sizeInfo.fSizes[SkYUVSizeInfo::kU].fWidth);
      82           0 :     SkASSERT(sizeInfo.fWidthBytes[SkYUVSizeInfo::kV] >=
      83             :             (size_t) sizeInfo.fSizes[SkYUVSizeInfo::kV].fWidth);
      84           0 :     SkASSERT(planes && planes[0] && planes[1] && planes[2]);
      85             : 
      86           0 :     return this->onGetYUV8Planes(sizeInfo, planes);
      87             : }
      88             : 
      89             : #if SK_SUPPORT_GPU
      90             : #include "GrTextureProxy.h"
      91             : 
      92           0 : sk_sp<GrTextureProxy> SkImageGenerator::generateTexture(GrContext* ctx, const SkImageInfo& info,
      93             :                                                         const SkIPoint& origin) {
      94           0 :     SkIRect srcRect = SkIRect::MakeXYWH(origin.x(), origin.y(), info.width(), info.height());
      95           0 :     if (!SkIRect::MakeWH(fInfo.width(), fInfo.height()).contains(srcRect)) {
      96           0 :         return nullptr;
      97             :     }
      98           0 :     return this->onGenerateTexture(ctx, info, origin);
      99             : }
     100             : 
     101           0 : sk_sp<GrTextureProxy> SkImageGenerator::onGenerateTexture(GrContext*, const SkImageInfo&,
     102             :                                                           const SkIPoint&) {
     103           0 :     return nullptr;
     104             : }
     105             : #endif
     106             : 
     107             : /////////////////////////////////////////////////////////////////////////////////////////////
     108             : 
     109           0 : SkData* SkImageGenerator::onRefEncodedData(GrContext* ctx) {
     110           0 :     return nullptr;
     111             : }
     112             : 
     113           0 : bool SkImageGenerator::onGetPixels(const SkImageInfo& info, void* dst, size_t rb,
     114             :                                    SkPMColor* colors, int* colorCount) {
     115           0 :     return false;
     116             : }
     117             : 
     118             : ///////////////////////////////////////////////////////////////////////////////////////////////////
     119             : 
     120             : #include "SkBitmap.h"
     121             : #include "SkColorTable.h"
     122             : 
     123             : #include "SkGraphics.h"
     124             : 
     125             : static SkGraphics::ImageGeneratorFromEncodedDataFactory gFactory;
     126             : 
     127             : SkGraphics::ImageGeneratorFromEncodedDataFactory
     128           0 : SkGraphics::SetImageGeneratorFromEncodedDataFactory(ImageGeneratorFromEncodedDataFactory factory)
     129             : {
     130           0 :     ImageGeneratorFromEncodedDataFactory prev = gFactory;
     131           0 :     gFactory = factory;
     132           0 :     return prev;
     133             : }
     134             : 
     135           0 : std::unique_ptr<SkImageGenerator> SkImageGenerator::MakeFromEncoded(sk_sp<SkData> data) {
     136           0 :     if (!data) {
     137           0 :         return nullptr;
     138             :     }
     139           0 :     if (gFactory) {
     140           0 :         if (std::unique_ptr<SkImageGenerator> generator = gFactory(data)) {
     141           0 :             return generator;
     142             :         }
     143             :     }
     144           0 :     return SkImageGenerator::MakeFromEncodedImpl(std::move(data));
     145             : }

Generated by: LCOV version 1.13