| OLD | NEW |
| 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 "SkImage_Base.h" | 8 #include "SkImage_Base.h" |
| 9 #include "SkImageGenerator.h" | 9 #include "SkImageGenerator.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 #if SK_SUPPORT_GPU | 132 #if SK_SUPPORT_GPU |
| 133 #include "GrTexture.h" | 133 #include "GrTexture.h" |
| 134 | 134 |
| 135 GrTexture* SkPictureImageGenerator::onGenerateTexture(GrContext* ctx, const SkIR
ect* subset) { | 135 GrTexture* SkPictureImageGenerator::onGenerateTexture(GrContext* ctx, const SkIR
ect* subset) { |
| 136 const SkImageInfo& info = this->getInfo(); | 136 const SkImageInfo& info = this->getInfo(); |
| 137 SkImageInfo surfaceInfo = subset ? info.makeWH(subset->width(), subset->heig
ht()) : info; | 137 SkImageInfo surfaceInfo = subset ? info.makeWH(subset->width(), subset->heig
ht()) : info; |
| 138 | 138 |
| 139 // | 139 // |
| 140 // TODO: respect the usage, by possibly creating a different (pow2) surface | 140 // TODO: respect the usage, by possibly creating a different (pow2) surface |
| 141 // | 141 // |
| 142 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkBudgeted::
kYes, | 142 sk_sp<SkSurface> surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kYes,
surfaceInfo)); |
| 143 surfaceInfo)); | 143 if (!surface) { |
| 144 if (!surface.get()) { | |
| 145 return nullptr; | 144 return nullptr; |
| 146 } | 145 } |
| 147 | 146 |
| 148 SkMatrix matrix = fMatrix; | 147 SkMatrix matrix = fMatrix; |
| 149 if (subset) { | 148 if (subset) { |
| 150 matrix.postTranslate(-subset->x(), -subset->y()); | 149 matrix.postTranslate(-subset->x(), -subset->y()); |
| 151 } | 150 } |
| 152 surface->getCanvas()->clear(0); // does NewRenderTarget promise to do this f
or us? | 151 surface->getCanvas()->clear(0); // does NewRenderTarget promise to do this f
or us? |
| 153 surface->getCanvas()->drawPicture(fPicture, &matrix, fPaint.getMaybeNull()); | 152 surface->getCanvas()->drawPicture(fPicture, &matrix, fPaint.getMaybeNull()); |
| 154 sk_sp<SkImage> image(surface->makeImageSnapshot()); | 153 sk_sp<SkImage> image(surface->makeImageSnapshot()); |
| 155 if (!image) { | 154 if (!image) { |
| 156 return nullptr; | 155 return nullptr; |
| 157 } | 156 } |
| 158 return SkSafeRef(as_IB(image)->peekTexture()); | 157 return SkSafeRef(as_IB(image)->peekTexture()); |
| 159 } | 158 } |
| 160 #endif | 159 #endif |
| OLD | NEW |