blob: 63014db0c5de957b9ff6ca289d32a9059dd5d093 [file] [log] [blame]
Robert Phillipsc1267c62018-04-04 11:12:39 -04001/*
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 Salomonc7fe0f72018-05-11 10:14:21 -040011#include "GrCaps.h"
Brian Salomon52aacd62018-05-10 12:57:17 -040012#include "GrContextThreadSafeProxyPriv.h"
13
Robert Phillipsc1267c62018-04-04 11:12:39 -040014bool SkSurfaceCharacterization::operator==(const SkSurfaceCharacterization& other) const {
15 if (!this->isValid() || !other.isValid()) {
16 return false;
17 }
18
Brian Salomon52aacd62018-05-10 12:57:17 -040019 if (fContextInfo != other.fContextInfo) {
Robert Phillipsc1267c62018-04-04 11:12:39 -040020 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 Daniela070ed72018-04-26 16:31:38 -040031 fUsesGLFBO0 == other.fUsesGLFBO0 &&
Greg Danielb46add82019-01-02 14:51:29 -050032 fVulkanSecondaryCBCompatible == other.fVulkanSecondaryCBCompatible &&
Robert Phillipsc1267c62018-04-04 11:12:39 -040033 fSurfaceProps == other.fSurfaceProps;
34}
35
Brian Salomon52aacd62018-05-10 12:57:17 -040036SkSurfaceCharacterization 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 Danielb46add82019-01-02 14:51:29 -050050 fVulkanSecondaryCBCompatible, fSurfaceProps);
Brian Salomon52aacd62018-05-10 12:57:17 -040051}
52
Robert Phillipsc1267c62018-04-04 11:12:39 -040053#endif