Robert Phillips | c1267c6 | 2018-04-04 11:12:39 -0400 | [diff] [blame] | 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 |
Brian Salomon | c7fe0f7 | 2018-05-11 10:14:21 -0400 | [diff] [blame] | 11 | #include "GrCaps.h" |
Brian Salomon | 52aacd6 | 2018-05-10 12:57:17 -0400 | [diff] [blame] | 12 | #include "GrContextThreadSafeProxyPriv.h" |
| 13 | |
Robert Phillips | c1267c6 | 2018-04-04 11:12:39 -0400 | [diff] [blame] | 14 | bool SkSurfaceCharacterization::operator==(const SkSurfaceCharacterization& other) const { |
| 15 | if (!this->isValid() || !other.isValid()) { |
| 16 | return false; |
| 17 | } |
| 18 | |
Brian Salomon | 52aacd6 | 2018-05-10 12:57:17 -0400 | [diff] [blame] | 19 | if (fContextInfo != other.fContextInfo) { |
Robert Phillips | c1267c6 | 2018-04-04 11:12:39 -0400 | [diff] [blame] | 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 && |
Greg Daniel | a070ed7 | 2018-04-26 16:31:38 -0400 | [diff] [blame] | 31 | fUsesGLFBO0 == other.fUsesGLFBO0 && |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 32 | fVulkanSecondaryCBCompatible == other.fVulkanSecondaryCBCompatible && |
Robert Phillips | c1267c6 | 2018-04-04 11:12:39 -0400 | [diff] [blame] | 33 | fSurfaceProps == other.fSurfaceProps; |
| 34 | } |
| 35 | |
Brian Salomon | 52aacd6 | 2018-05-10 12:57:17 -0400 | [diff] [blame] | 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, |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 50 | fVulkanSecondaryCBCompatible, fSurfaceProps); |
Brian Salomon | 52aacd6 | 2018-05-10 12:57:17 -0400 | [diff] [blame] | 51 | } |
| 52 | |
Robert Phillips | c1267c6 | 2018-04-04 11:12:39 -0400 | [diff] [blame] | 53 | #endif |