aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrTexture.cpp
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2017-10-12 11:23:36 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-10-12 16:12:42 +0000
commit0fc4d2d269c0aff1eadf57da2e571d0d54c38f5a (patch)
treedaab2c8050304d504d014c5c93732d738c1f651b /src/gpu/GrTexture.cpp
parenta8c63075260337277d3ed405e97ba5ff89af3679 (diff)
Use enum to track MipMapsStatus throughout Texture creation
Bug: skia: Change-Id: I1de1105d74b45f7b02ff52e6b8333801d98ef1ce Reviewed-on: https://skia-review.googlesource.com/58501 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrTexture.cpp')
-rw-r--r--src/gpu/GrTexture.cpp45
1 files changed, 19 insertions, 26 deletions
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index c134c64c29..250b6dd167 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -17,20 +17,20 @@
#include "SkMipMap.h"
#include "SkTypes.h"
-void GrTexture::dirtyMipMaps(bool mipMapsDirty) {
- if (mipMapsDirty) {
- if (kInvalid_MipMapsStatus == fMipMapsStatus || kClean_MipMapsStatus == fMipMapsStatus) {
- fMipMapsStatus = kDirty_MipMapsStatus;
- }
- } else {
- const bool sizeChanged = kNotAllocated_MipMapsStatus == fMipMapsStatus;
- fMipMapsStatus = kClean_MipMapsStatus;
- if (sizeChanged) {
- // This must not be called until after changing fMipMapsStatus.
- this->didChangeGpuMemorySize();
- // TODO(http://skbug.com/4548) - The desc and scratch key should be
- // updated to reflect the newly-allocated mipmaps.
- }
+void GrTexture::markMipMapsDirty() {
+ if (GrMipMapsStatus::kValid == fMipMapsStatus) {
+ fMipMapsStatus = GrMipMapsStatus::kDirty;
+ }
+}
+
+void GrTexture::markMipMapsClean() {
+ const bool sizeChanged = GrMipMapsStatus::kNotAllocated == fMipMapsStatus;
+ fMipMapsStatus = GrMipMapsStatus::kValid;
+ if (sizeChanged) {
+ // This must not be called until after changing fMipMapsStatus.
+ this->didChangeGpuMemorySize();
+ // TODO(http://skbug.com/4548) - The desc and scratch key should be
+ // updated to reflect the newly-allocated mipmaps.
}
}
@@ -42,24 +42,17 @@ size_t GrTexture::onGpuMemorySize() const {
/////////////////////////////////////////////////////////////////////////////
GrTexture::GrTexture(GrGpu* gpu, const GrSurfaceDesc& desc, GrSLType samplerType,
GrSamplerState::Filter highestFilterMode,
- bool mipsAllocated, bool wasFullMipMapDataProvided)
+ GrMipMapsStatus mipMapsStatus)
: INHERITED(gpu, desc)
, fSamplerType(samplerType)
, fHighestFilterMode(highestFilterMode)
+ , fMipMapsStatus(mipMapsStatus)
// Mip color mode is explicitly set after creation via GrTexturePriv
, fMipColorMode(SkDestinationSurfaceColorMode::kLegacy) {
- if (mipsAllocated) {
- if (wasFullMipMapDataProvided) {
- fMipMapsStatus = kClean_MipMapsStatus;
- } else {
- // Currently we should only hit this case when none of the mips were uploaded including
- // the base. Thus we set this to invalid.
- fMipMapsStatus = kInvalid_MipMapsStatus;
- }
- fMaxMipMapLevel = SkMipMap::ComputeLevelCount(this->width(), this->height());
- } else {
- fMipMapsStatus = kNotAllocated_MipMapsStatus;
+ if (GrMipMapsStatus::kNotAllocated == fMipMapsStatus) {
fMaxMipMapLevel = 0;
+ } else {
+ fMaxMipMapLevel = SkMipMap::ComputeLevelCount(this->width(), this->height());
}
}