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

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

Issue 2175873002: remove/deprecate SkBitmap::getTexture, as it now always returns false (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: kill AutoBitmapTexture 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
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 GrBitmapTextureAdjuster::GrBitmapTextureAdjuster(const SkBitmap* bmp)
21 : INHERITED(bmp->getTexture(),
22 SkIRect::MakeWH(bmp->width(), bmp->height()),
23 bmp_is_alpha_only(*bmp))
24 , fBmp(bmp) {}
25
26 void GrBitmapTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) {
27 if (fBmp->isVolatile()) {
28 return;
29 }
30 // The content area must represent the whole bitmap. Texture-backed bitmaps don't support
31 // extractSubset(). Therefore, either the bitmap and the texture are the sam e size or the
32 // content's dimensions are the bitmap's dimensions which is pinned to the u pper left
33 // of the texture.
34 GrUniqueKey baseKey;
35 GrMakeKeyFromImageID(&baseKey, fBmp->getGenerationID(),
36 SkIRect::MakeWH(fBmp->width(), fBmp->height()));
37 MakeCopyKeyFromOrigKey(baseKey, params, copyKey);
38 }
39
40 void GrBitmapTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) {
41 GrInstallBitmapUniqueKeyInvalidator(copyKey, fBmp->pixelRef());
42 }
43
44 SkColorSpace* GrBitmapTextureAdjuster::getColorSpace() {
45 return fBmp->colorSpace();
46 }
47
48 //////////////////////////////////////////////////////////////////////////////
49
50 // SkImage's don't have a way of communicating whether they're alpha-only. So we fallback to 20 // SkImage's don't have a way of communicating whether they're alpha-only. So we fallback to
51 // inspecting the texture. 21 // inspecting the texture.
52 static bool tex_image_is_alpha_only(const SkImage_Base& img) { 22 static bool tex_image_is_alpha_only(const SkImage_Base& img) {
53 return GrPixelConfigIsAlphaOnly(img.peekTexture()->config()); 23 return GrPixelConfigIsAlphaOnly(img.peekTexture()->config());
54 } 24 }
55 25
56 GrImageTextureAdjuster::GrImageTextureAdjuster(const SkImage_Base* img) 26 GrImageTextureAdjuster::GrImageTextureAdjuster(const SkImage_Base* img)
57 : INHERITED(img->peekTexture(), SkIRect::MakeWH(img->width(), img->height()) , 27 : INHERITED(img->peekTexture(), SkIRect::MakeWH(img->width(), img->height()) ,
58 tex_image_is_alpha_only(*img)) 28 tex_image_is_alpha_only(*img))
59 , fImageBase(img) {} 29 , fImageBase(img) {}
(...skipping 12 matching lines...) Expand all
72 } 42 }
73 43
74 SkColorSpace* GrImageTextureAdjuster::getColorSpace() { 44 SkColorSpace* GrImageTextureAdjuster::getColorSpace() {
75 return fImageBase->onImageInfo().colorSpace(); 45 return fImageBase->onImageInfo().colorSpace();
76 } 46 }
77 47
78 ////////////////////////////////////////////////////////////////////////////// 48 //////////////////////////////////////////////////////////////////////////////
79 49
80 GrBitmapTextureMaker::GrBitmapTextureMaker(GrContext* context, const SkBitmap& b itmap) 50 GrBitmapTextureMaker::GrBitmapTextureMaker(GrContext* context, const SkBitmap& b itmap)
81 : INHERITED(context, bitmap.width(), bitmap.height(), bmp_is_alpha_only(bitm ap)) 51 : INHERITED(context, bitmap.width(), bitmap.height(), bmp_is_alpha_only(bitm ap))
82 , fBitmap(bitmap) { 52 , fBitmap(bitmap)
83 SkASSERT(!bitmap.getTexture()); 53 {
84 if (!bitmap.isVolatile()) { 54 if (!bitmap.isVolatile()) {
85 SkIPoint origin = bitmap.pixelRefOrigin(); 55 SkIPoint origin = bitmap.pixelRefOrigin();
86 SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, bitmap.width(), 56 SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, bitmap.width(),
87 bitmap.height()); 57 bitmap.height());
88 GrMakeKeyFromImageID(&fOriginalKey, bitmap.pixelRef()->getGenerationID() , subset); 58 GrMakeKeyFromImageID(&fOriginalKey, bitmap.pixelRef()->getGenerationID() , subset);
89 } 59 }
90 } 60 }
91 61
92 GrTexture* GrBitmapTextureMaker::refOriginalTexture(bool willBeMipped, 62 GrTexture* GrBitmapTextureMaker::refOriginalTexture(bool willBeMipped,
93 SkSourceGammaTreatment gamma Treatment) { 63 SkSourceGammaTreatment gamma Treatment) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 127
158 void GrImageTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { 128 void GrImageTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) {
159 if (fClient) { 129 if (fClient) {
160 as_IB(fClient)->notifyAddedToCache(); 130 as_IB(fClient)->notifyAddedToCache();
161 } 131 }
162 } 132 }
163 133
164 SkColorSpace* GrImageTextureMaker::getColorSpace() { 134 SkColorSpace* GrImageTextureMaker::getColorSpace() {
165 return fCacher->info().colorSpace(); 135 return fCacher->info().colorSpace();
166 } 136 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698