| 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 // This test only works with the GPU backend. | 8 // This test only works with the GPU backend. |
| 9 | 9 |
| 10 #include "gm.h" | 10 #include "gm.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 desc.fOrigin = kTopLeft_GrSurfaceOrigin; | 112 desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
| 113 desc.fTextureHandle = reinterpret_cast<GrBackendObject>(&info); | 113 desc.fTextureHandle = reinterpret_cast<GrBackendObject>(&info); |
| 114 if (sk_sp<SkImage> image = SkImage::MakeFromAdoptedTexture(context, desc
)) { | 114 if (sk_sp<SkImage> image = SkImage::MakeFromAdoptedTexture(context, desc
)) { |
| 115 return image; | 115 return image; |
| 116 } | 116 } |
| 117 GR_GL_CALL(gl, DeleteTextures(1, &id)); | 117 GR_GL_CALL(gl, DeleteTextures(1, &id)); |
| 118 return nullptr; | 118 return nullptr; |
| 119 } | 119 } |
| 120 | 120 |
| 121 void onDraw(SkCanvas* canvas) override { | 121 void onDraw(SkCanvas* canvas) override { |
| 122 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); | 122 GrContext *context = canvas->getGrContext(); |
| 123 GrContext* context; | 123 if (!context) { |
| 124 if (!rt || !(context = rt->getContext())) { | |
| 125 skiagm::GM::DrawGpuOnlyMessage(canvas); | 124 skiagm::GM::DrawGpuOnlyMessage(canvas); |
| 126 return; | 125 return; |
| 127 } | 126 } |
| 128 | 127 |
| 129 static const int kWidth = 50; | 128 static const int kWidth = 50; |
| 130 static const int kHeight = 50; | 129 static const int kHeight = 50; |
| 131 static const SkScalar kPad = 5.f; | 130 static const SkScalar kPad = 5.f; |
| 132 | 131 |
| 133 SkPMColor pixels[kWidth * kHeight]; | 132 SkPMColor pixels[kWidth * kHeight]; |
| 134 this->fillPixels(kWidth, kHeight, pixels); | 133 this->fillPixels(kWidth, kHeight, pixels); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } | 180 } |
| 182 | 181 |
| 183 private: | 182 private: |
| 184 typedef GM INHERITED; | 183 typedef GM INHERITED; |
| 185 }; | 184 }; |
| 186 | 185 |
| 187 DEF_GM(return new RectangleTexture;) | 186 DEF_GM(return new RectangleTexture;) |
| 188 } | 187 } |
| 189 | 188 |
| 190 #endif | 189 #endif |
| OLD | NEW |