Home | History | Annotate | Download | only in core
      1 /*
      2  * Copyright 2018 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 "SkSurfaceCharacterization.h"
      9 
     10 #if SK_SUPPORT_GPU
     11 #include "GrCaps.h"
     12 #include "GrContextThreadSafeProxyPriv.h"
     13 
     14 bool SkSurfaceCharacterization::operator==(const SkSurfaceCharacterization& other) const {
     15     if (!this->isValid() || !other.isValid()) {
     16         return false;
     17     }
     18 
     19     if (fContextInfo != other.fContextInfo) {
     20         return false;
     21     }
     22 
     23     return fCacheMaxResourceBytes == other.fCacheMaxResourceBytes &&
     24            fOrigin == other.fOrigin &&
     25            fImageInfo == other.fImageInfo &&
     26            fConfig == other.fConfig &&
     27            fFSAAType == other.fFSAAType &&
     28            fStencilCnt == other.fStencilCnt &&
     29            fIsTextureable == other.fIsTextureable &&
     30            fIsMipMapped == other.fIsMipMapped &&
     31            fUsesGLFBO0 == other.fUsesGLFBO0 &&
     32            fVulkanSecondaryCBCompatible == other.fVulkanSecondaryCBCompatible &&
     33            fSurfaceProps == other.fSurfaceProps;
     34 }
     35 
     36 SkSurfaceCharacterization SkSurfaceCharacterization::createResized(int width, int height) const {
     37     const GrCaps* caps = fContextInfo->priv().caps();
     38     if (!caps) {
     39         return SkSurfaceCharacterization();
     40     }
     41 
     42     if (width <= 0 || height <= 0 || width > caps->maxRenderTargetSize() ||
     43         height > caps->maxRenderTargetSize()) {
     44         return SkSurfaceCharacterization();
     45     }
     46 
     47     return SkSurfaceCharacterization(fContextInfo, fCacheMaxResourceBytes,
     48                                      fImageInfo.makeWH(width, height), fOrigin, fConfig, fFSAAType,
     49                                      fStencilCnt, fIsTextureable, fIsMipMapped, fUsesGLFBO0,
     50                                      fVulkanSecondaryCBCompatible, fSurfaceProps);
     51 }
     52 
     53 #endif
     54