Chromium Code Reviews| 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 getBitmap(SkBitmap* result) const override { | 140 bool getBitmap(SkBitmap* result) const override { |
| 141 return false; | 141 if (GrTexture* texture = as_IB(fImage.get())->peekTexture()) { |
| 142 const SkImageInfo info = GrMakeInfoFromTexture(texture, | |
| 143 fImage->width(), fIma ge->height(), | |
| 144 fImage->isOpaque()); | |
| 145 if (!result->setInfo(info)) { | |
| 146 return false; | |
| 147 } | |
| 148 | |
| 149 result->setPixelRef(new SkGrPixelRef(info, texture))->unref(); | |
|
Stephen White
2016/03/07 21:47:26
I think this will break the no-GPU build, and prob
robertphillips
2016/03/08 16:45:29
Done.
I'll rename getBitmap in a separate CL thou
| |
| 150 return true; | |
| 151 } | |
| 152 | |
| 153 return as_IB(fImage.get())->asBitmapForImageFilters(result); | |
| 142 } | 154 } |
| 143 | 155 |
| 144 bool testingOnlyOnGetROPixels(SkBitmap* result) const override { | 156 bool testingOnlyOnGetROPixels(SkBitmap* result) const override { |
| 145 return false; | 157 return fImage->asLegacyBitmap(result, SkImage::kRO_LegacyBitmapMode); |
| 146 } | 158 } |
| 147 | 159 |
| 148 SkSpecialSurface* onNewSurface(const SkImageInfo& info) const override { | 160 SkSpecialSurface* onNewSurface(const SkImageInfo& info) const override { |
| 149 #if SK_SUPPORT_GPU | 161 #if SK_SUPPORT_GPU |
| 150 GrTexture* texture = as_IB(fImage.get())->peekTexture(); | 162 GrTexture* texture = as_IB(fImage.get())->peekTexture(); |
| 151 if (texture) { | 163 if (texture) { |
| 152 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info); | 164 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(info); |
| 153 desc.fFlags = kRenderTarget_GrSurfaceFlag; | 165 desc.fFlags = kRenderTarget_GrSurfaceFlag; |
| 154 | 166 |
| 155 return SkSpecialSurface::NewRenderTarget(this->proxy(), texture->get Context(), desc); | 167 return SkSpecialSurface::NewRenderTarget(this->proxy(), texture->get Context(), desc); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 171 return true; | 183 return true; |
| 172 } | 184 } |
| 173 | 185 |
| 174 return rect.fLeft >= 0 && rect.fLeft < width && rect.fLeft < rect.fRight && | 186 return rect.fLeft >= 0 && rect.fLeft < width && rect.fLeft < rect.fRight && |
| 175 rect.fRight >= 0 && rect.fRight <= width && | 187 rect.fRight >= 0 && rect.fRight <= width && |
| 176 rect.fTop >= 0 && rect.fTop < height && rect.fTop < rect.fBottom && | 188 rect.fTop >= 0 && rect.fTop < height && rect.fTop < rect.fBottom && |
| 177 rect.fBottom >= 0 && rect.fBottom <= height; | 189 rect.fBottom >= 0 && rect.fBottom <= height; |
| 178 } | 190 } |
| 179 #endif | 191 #endif |
| 180 | 192 |
| 181 SkSpecialImage* SkSpecialImage::NewFromImage(const SkIRect& subset, const SkImag e* image) { | 193 SkSpecialImage* SkSpecialImage::NewFromImage(SkImageFilter::Proxy* proxy, |
| 194 const SkIRect& subset, | |
| 195 const SkImage* image) { | |
| 182 SkASSERT(rect_fits(subset, image->width(), image->height())); | 196 SkASSERT(rect_fits(subset, image->width(), image->height())); |
| 183 return new SkSpecialImage_Image(nullptr, subset, image); | 197 return new SkSpecialImage_Image(proxy, subset, image); |
| 184 } | 198 } |
| 185 | 199 |
| 186 /////////////////////////////////////////////////////////////////////////////// | 200 /////////////////////////////////////////////////////////////////////////////// |
| 187 #include "SkBitmap.h" | 201 #include "SkBitmap.h" |
| 188 #include "SkImageInfo.h" | 202 #include "SkImageInfo.h" |
| 189 #include "SkPixelRef.h" | 203 #include "SkPixelRef.h" |
| 190 | 204 |
| 191 class SkSpecialImage_Raster : public SkSpecialImage_Base { | 205 class SkSpecialImage_Raster : public SkSpecialImage_Base { |
| 192 public: | 206 public: |
| 193 SkSpecialImage_Raster(SkImageFilter::Proxy* proxy, const SkIRect& subset, co nst SkBitmap& bm) | 207 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 | 365 |
| 352 SkSpecialImage* SkSpecialImage::NewFromGpu(SkImageFilter::Proxy* proxy, | 366 SkSpecialImage* SkSpecialImage::NewFromGpu(SkImageFilter::Proxy* proxy, |
| 353 const SkIRect& subset, | 367 const SkIRect& subset, |
| 354 uint32_t uniqueID, | 368 uint32_t uniqueID, |
| 355 GrTexture* tex, | 369 GrTexture* tex, |
| 356 SkAlphaType at) { | 370 SkAlphaType at) { |
| 357 return nullptr; | 371 return nullptr; |
| 358 } | 372 } |
| 359 | 373 |
| 360 #endif | 374 #endif |
| OLD | NEW |