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

Side by Side Diff: src/gpu/GrImageIDTextureAdjuster.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/GrImageIDTextureAdjuster.h ('k') | src/gpu/GrTextureParamsAdjuster.h » ('j') | 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 "GrImageIDTextureAdjuster.h" 8 #include "GrImageIDTextureAdjuster.h"
9 9
10 #include "GrContext.h" 10 #include "GrContext.h"
11 #include "GrGpuResourcePriv.h" 11 #include "GrGpuResourcePriv.h"
12 #include "SkBitmap.h" 12 #include "SkBitmap.h"
13 #include "SkGrPriv.h" 13 #include "SkGrPriv.h"
14 #include "SkImage_Base.h" 14 #include "SkImage_Base.h"
15 #include "SkImageCacherator.h" 15 #include "SkImageCacherator.h"
16 #include "SkPixelRef.h" 16 #include "SkPixelRef.h"
17 17
18 static bool bmp_is_alpha_only(const SkBitmap& bm) { return kAlpha_8_SkColorType == bm.colorType(); } 18 static bool bmp_is_alpha_only(const SkBitmap& bm) { return kAlpha_8_SkColorType == bm.colorType(); }
19 19
20 // SkImage's don't have a way of communicating whether they're alpha-only. So we fallback to 20 // By construction this texture adjuster always represents an entire SkImage, so use the
21 // inspecting the texture. 21 // image's dimensions for the key's rectangle.
22 static bool tex_image_is_alpha_only(const SkImage_Base& img) {
23 return GrPixelConfigIsAlphaOnly(img.peekTexture()->config());
24 }
25
26 GrImageTextureAdjuster::GrImageTextureAdjuster(const SkImage_Base* img) 22 GrImageTextureAdjuster::GrImageTextureAdjuster(const SkImage_Base* img)
27 : INHERITED(img->peekTexture(), SkIRect::MakeWH(img->width(), img->height()) , 23 : GrTextureAdjuster(img->peekTexture(), SkIRect::MakeSize(img->dimensions()) , img->uniqueID(),
28 tex_image_is_alpha_only(*img)) 24 img->onImageInfo().colorSpace())
29 , fImageBase(img) {} 25 {
30 26 SkASSERT(img->peekTexture());
31 void GrImageTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) {
32 // By construction this texture adjuster always represents an entire SkImage , so use the
33 // image's width and height for the key's rectangle.
34 GrUniqueKey baseKey;
35 GrMakeKeyFromImageID(&baseKey, fImageBase->uniqueID(),
36 SkIRect::MakeWH(fImageBase->width(), fImageBase->height ()));
37 MakeCopyKeyFromOrigKey(baseKey, params, copyKey);
38 }
39
40 void GrImageTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) {
41 // We don't currently have a mechanism for notifications on Images!
42 }
43
44 SkColorSpace* GrImageTextureAdjuster::getColorSpace() {
45 return fImageBase->onImageInfo().colorSpace();
46 } 27 }
47 28
48 ////////////////////////////////////////////////////////////////////////////// 29 //////////////////////////////////////////////////////////////////////////////
49 30
50 GrBitmapTextureMaker::GrBitmapTextureMaker(GrContext* context, const SkBitmap& b itmap) 31 GrBitmapTextureMaker::GrBitmapTextureMaker(GrContext* context, const SkBitmap& b itmap)
51 : INHERITED(context, bitmap.width(), bitmap.height(), bmp_is_alpha_only(bitm ap)) 32 : INHERITED(context, bitmap.width(), bitmap.height(), bmp_is_alpha_only(bitm ap))
52 , fBitmap(bitmap) 33 , fBitmap(bitmap)
53 { 34 {
54 if (!bitmap.isVolatile()) { 35 if (!bitmap.isVolatile()) {
55 SkIPoint origin = bitmap.pixelRefOrigin(); 36 SkIPoint origin = bitmap.pixelRefOrigin();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 108
128 void GrImageTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { 109 void GrImageTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) {
129 if (fClient) { 110 if (fClient) {
130 as_IB(fClient)->notifyAddedToCache(); 111 as_IB(fClient)->notifyAddedToCache();
131 } 112 }
132 } 113 }
133 114
134 SkColorSpace* GrImageTextureMaker::getColorSpace() { 115 SkColorSpace* GrImageTextureMaker::getColorSpace() {
135 return fCacher->info().colorSpace(); 116 return fCacher->info().colorSpace();
136 } 117 }
OLDNEW
« no previous file with comments | « src/gpu/GrImageIDTextureAdjuster.h ('k') | src/gpu/GrTextureParamsAdjuster.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698