OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkImage_Base.h" | 9 #include "SkImage_Base.h" |
10 #include "SkSpecialImage.h" | 10 #include "SkSpecialImage.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 dst, paint, SkCanvas::kStrict_SrcRectConstraint); | 131 dst, paint, SkCanvas::kStrict_SrcRectConstraint); |
132 } | 132 } |
133 | 133 |
134 bool testingOnlyOnPeekPixels(SkPixmap* pixmap) const override { | 134 bool testingOnlyOnPeekPixels(SkPixmap* pixmap) const override { |
135 return fImage->peekPixels(pixmap); | 135 return fImage->peekPixels(pixmap); |
136 } | 136 } |
137 | 137 |
138 GrTexture* onPeekTexture() const override { return as_IB(fImage.get())->peek
Texture(); } | 138 GrTexture* onPeekTexture() const override { return as_IB(fImage.get())->peek
Texture(); } |
139 | 139 |
140 bool getBitmapDeprecated(SkBitmap* result) const override { | 140 bool getBitmapDeprecated(SkBitmap* result) const override { |
141 return false; | 141 #if SK_SUPPORT_GPU |
| 142 if (GrTexture* texture = as_IB(fImage.get())->peekTexture()) { |
| 143 const SkImageInfo info = GrMakeInfoFromTexture(texture, |
| 144 fImage->width(), fIma
ge->height(), |
| 145 fImage->isOpaque()); |
| 146 if (!result->setInfo(info)) { |
| 147 return false; |
| 148 } |
| 149 |
| 150 result->setPixelRef(new SkGrPixelRef(info, texture))->unref(); |
| 151 return true; |
| 152 } |
| 153 #endif |
| 154 |
| 155 return as_IB(fImage.get())->asBitmapForImageFilters(result); |
142 } | 156 } |
143 | 157 |
144 bool testingOnlyOnGetROPixels(SkBitmap* result) const override { | 158 bool testingOnlyOnGetROPixels(SkBitmap* result) const override { |
145 return false; | 159 return fImage->asLegacyBitmap(result, SkImage::kRO_LegacyBitmapMode); |
146 } | 160 } |
147 | 161 |
148 SkSpecialSurface* onNewSurface(const SkImageInfo& info) const override { | 162 SkSpecialSurface* onNewSurface(const SkImageInfo& info) const override { |
149 #if SK_SUPPORT_GPU | 163 #if SK_SUPPORT_GPU |
150 GrTexture* texture = as_IB(fImage.get())->peekTexture(); | 164 GrTexture* texture = as_IB(fImage.get())->peekTexture(); |
151 if (texture) { | 165 if (texture) { |
152 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info); | 166 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info); |
153 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 167 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
154 | 168 |
155 return SkSpecialSurface::NewRenderTarget(this->proxy(), texture->get
Context(), desc); | 169 return SkSpecialSurface::NewRenderTarget(this->proxy(), texture->get
Context(), desc); |
(...skipping 15 matching lines...) Expand all Loading... |
171 return true; | 185 return true; |
172 } | 186 } |
173 | 187 |
174 return rect.fLeft >= 0 && rect.fLeft < width && rect.fLeft < rect.fRight && | 188 return rect.fLeft >= 0 && rect.fLeft < width && rect.fLeft < rect.fRight && |
175 rect.fRight >= 0 && rect.fRight <= width && | 189 rect.fRight >= 0 && rect.fRight <= width && |
176 rect.fTop >= 0 && rect.fTop < height && rect.fTop < rect.fBottom && | 190 rect.fTop >= 0 && rect.fTop < height && rect.fTop < rect.fBottom && |
177 rect.fBottom >= 0 && rect.fBottom <= height; | 191 rect.fBottom >= 0 && rect.fBottom <= height; |
178 } | 192 } |
179 #endif | 193 #endif |
180 | 194 |
181 SkSpecialImage* SkSpecialImage::NewFromImage(const SkIRect& subset, const SkImag
e* image) { | 195 SkSpecialImage* SkSpecialImage::NewFromImage(SkImageFilter::Proxy* proxy, |
| 196 const SkIRect& subset, |
| 197 const SkImage* image) { |
182 SkASSERT(rect_fits(subset, image->width(), image->height())); | 198 SkASSERT(rect_fits(subset, image->width(), image->height())); |
183 return new SkSpecialImage_Image(nullptr, subset, image); | 199 return new SkSpecialImage_Image(proxy, subset, image); |
184 } | 200 } |
185 | 201 |
186 /////////////////////////////////////////////////////////////////////////////// | 202 /////////////////////////////////////////////////////////////////////////////// |
187 #include "SkBitmap.h" | 203 #include "SkBitmap.h" |
188 #include "SkImageInfo.h" | 204 #include "SkImageInfo.h" |
189 #include "SkPixelRef.h" | 205 #include "SkPixelRef.h" |
190 | 206 |
191 class SkSpecialImage_Raster : public SkSpecialImage_Base { | 207 class SkSpecialImage_Raster : public SkSpecialImage_Base { |
192 public: | 208 public: |
193 SkSpecialImage_Raster(SkImageFilter::Proxy* proxy, const SkIRect& subset, co
nst SkBitmap& bm) | 209 SkSpecialImage_Raster(SkImageFilter::Proxy* proxy, const SkIRect& subset, co
nst SkBitmap& bm) |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 367 |
352 SkSpecialImage* SkSpecialImage::NewFromGpu(SkImageFilter::Proxy* proxy, | 368 SkSpecialImage* SkSpecialImage::NewFromGpu(SkImageFilter::Proxy* proxy, |
353 const SkIRect& subset, | 369 const SkIRect& subset, |
354 uint32_t uniqueID, | 370 uint32_t uniqueID, |
355 GrTexture* tex, | 371 GrTexture* tex, |
356 SkAlphaType at) { | 372 SkAlphaType at) { |
357 return nullptr; | 373 return nullptr; |
358 } | 374 } |
359 | 375 |
360 #endif | 376 #endif |
OLD | NEW |