Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(693)

Side by Side Diff: src/gpu/GrTextureParamsAdjuster.cpp

Issue 2242373002: simplify GrTextureAdjuster given there is only one subclass (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrTextureParamsAdjuster.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrTextureParamsAdjuster.h" 8 #include "GrTextureParamsAdjuster.h"
9 9
10 #include "GrCaps.h" 10 #include "GrCaps.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 localRect.fBottom *= sy; 105 localRect.fBottom *= sy;
106 } else { 106 } else {
107 localRect = SkRect::MakeWH(1.f, 1.f); 107 localRect = SkRect::MakeWH(1.f, 1.f);
108 } 108 }
109 109
110 SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight); 110 SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight);
111 copyDC->fillRectToRect(GrNoClip(), paint, SkMatrix::I(), dstRect, localRect) ; 111 copyDC->fillRectToRect(GrNoClip(), paint, SkMatrix::I(), dstRect, localRect) ;
112 return copyDC->asTexture().release(); 112 return copyDC->asTexture().release();
113 } 113 }
114 114
115 GrTextureAdjuster::GrTextureAdjuster(GrTexture* original, 115 GrTextureAdjuster::GrTextureAdjuster(GrTexture* original, const SkIRect& content Area,
116 const SkIRect& contentArea, 116 uint32_t uniqueID, SkColorSpace* cs)
117 bool isAlphaOnly) 117 : INHERITED(contentArea.width(), contentArea.height(),
118 : INHERITED(contentArea.width(), contentArea.height(), isAlphaOnly) 118 GrPixelConfigIsAlphaOnly(original->config()))
119 , fOriginal(original) { 119 , fOriginal(original)
120 , fColorSpace(cs)
121 , fUniqueID(uniqueID)
122 {
120 SkASSERT(SkIRect::MakeWH(original->width(), original->height()).contains(con tentArea)); 123 SkASSERT(SkIRect::MakeWH(original->width(), original->height()).contains(con tentArea));
121 if (contentArea.fLeft > 0 || contentArea.fTop > 0 || 124 if (contentArea.fLeft > 0 || contentArea.fTop > 0 ||
122 contentArea.fRight < original->width() || contentArea.fBottom < original ->height()) { 125 contentArea.fRight < original->width() || contentArea.fBottom < original ->height()) {
123 fContentArea.set(contentArea); 126 fContentArea.set(contentArea);
124 } 127 }
125 } 128 }
126 129
130 void GrTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyK ey) {
131 GrUniqueKey baseKey;
132 GrMakeKeyFromImageID(&baseKey, fUniqueID, SkIRect::MakeWH(this->width(), thi s->height()));
133 MakeCopyKeyFromOrigKey(baseKey, params, copyKey);
134 }
135
136 void GrTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) {
137 // We don't currently have a mechanism for notifications on Images!
138 }
139
140 SkColorSpace* GrTextureAdjuster::getColorSpace() {
141 return fColorSpace;
142 }
143
127 GrTexture* GrTextureAdjuster::refCopy(const CopyParams& copyParams) { 144 GrTexture* GrTextureAdjuster::refCopy(const CopyParams& copyParams) {
128 GrTexture* texture = this->originalTexture(); 145 GrTexture* texture = this->originalTexture();
129 GrContext* context = texture->getContext(); 146 GrContext* context = texture->getContext();
130 const SkIRect* contentArea = this->contentAreaOrNull(); 147 const SkIRect* contentArea = this->contentAreaOrNull();
131 GrUniqueKey key; 148 GrUniqueKey key;
132 this->makeCopyKey(copyParams, &key); 149 this->makeCopyKey(copyParams, &key);
133 if (key.isValid()) { 150 if (key.isValid()) {
134 GrTexture* cachedCopy = context->textureProvider()->findAndRefTextureByU niqueKey(key); 151 GrTexture* cachedCopy = context->textureProvider()->findAndRefTextureByU niqueKey(key);
135 if (cachedCopy) { 152 if (cachedCopy) {
136 return cachedCopy; 153 return cachedCopy;
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 } 533 }
517 534
518 GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams , bool willBeMipped, 535 GrTexture* GrTextureMaker::generateTextureForParams(const CopyParams& copyParams , bool willBeMipped,
519 SkSourceGammaTreatment gamma Treatment) { 536 SkSourceGammaTreatment gamma Treatment) {
520 SkAutoTUnref<GrTexture> original(this->refOriginalTexture(willBeMipped, gamm aTreatment)); 537 SkAutoTUnref<GrTexture> original(this->refOriginalTexture(willBeMipped, gamm aTreatment));
521 if (!original) { 538 if (!original) {
522 return nullptr; 539 return nullptr;
523 } 540 }
524 return copy_on_gpu(original, nullptr, copyParams); 541 return copy_on_gpu(original, nullptr, copyParams);
525 } 542 }
OLDNEW
« no previous file with comments | « src/gpu/GrTextureParamsAdjuster.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698