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 "SkSpecialImage.h" | 9 #include "SkSpecialImage.h" |
10 #include "SkSpecialSurface.h" | 10 #include "SkSpecialSurface.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 } | 104 } |
105 | 105 |
106 const SkIRect subset = SkIRect::MakeWH(pr->info().width(), pr->info().height
()); | 106 const SkIRect subset = SkIRect::MakeWH(pr->info().width(), pr->info().height
()); |
107 | 107 |
108 return sk_make_sp<SkSpecialSurface_Raster>(pr.get(), subset, props); | 108 return sk_make_sp<SkSpecialSurface_Raster>(pr.get(), subset, props); |
109 } | 109 } |
110 | 110 |
111 #if SK_SUPPORT_GPU | 111 #if SK_SUPPORT_GPU |
112 /////////////////////////////////////////////////////////////////////////////// | 112 /////////////////////////////////////////////////////////////////////////////// |
113 #include "GrContext.h" | 113 #include "GrContext.h" |
| 114 #include "GrTextureProxy.h" |
114 #include "SkGpuDevice.h" | 115 #include "SkGpuDevice.h" |
115 | 116 |
116 class SkSpecialSurface_Gpu : public SkSpecialSurface_Base { | 117 class SkSpecialSurface_Gpu : public SkSpecialSurface_Base { |
117 public: | 118 public: |
118 SkSpecialSurface_Gpu(sk_sp<GrRenderTargetContext> renderTargetContext, | 119 SkSpecialSurface_Gpu(sk_sp<GrRenderTargetContext> renderTargetContext, |
119 int width, int height, | 120 int width, int height, |
120 const SkIRect& subset) | 121 const SkIRect& subset) |
121 : INHERITED(subset, &renderTargetContext->surfaceProps()) | 122 : INHERITED(subset, &renderTargetContext->surfaceProps()) |
122 , fRenderTargetContext(std::move(renderTargetContext)) { | 123 , fRenderTargetContext(std::move(renderTargetContext)) { |
123 | 124 |
124 sk_sp<SkBaseDevice> device(SkGpuDevice::Make(fRenderTargetContext, width
, height, | 125 sk_sp<SkBaseDevice> device(SkGpuDevice::Make(fRenderTargetContext, width
, height, |
125 SkGpuDevice::kUninit_InitCo
ntents)); | 126 SkGpuDevice::kUninit_InitCo
ntents)); |
126 if (!device) { | 127 if (!device) { |
127 return; | 128 return; |
128 } | 129 } |
129 | 130 |
130 fCanvas.reset(new SkCanvas(device.get())); | 131 fCanvas.reset(new SkCanvas(device.get())); |
131 fCanvas->clipRect(SkRect::Make(subset)); | 132 fCanvas->clipRect(SkRect::Make(subset)); |
132 #ifdef SK_IS_BOT | 133 #ifdef SK_IS_BOT |
133 fCanvas->clear(SK_ColorRED); // catch any imageFilter sloppiness | 134 fCanvas->clear(SK_ColorRED); // catch any imageFilter sloppiness |
134 #endif | 135 #endif |
135 } | 136 } |
136 | 137 |
137 ~SkSpecialSurface_Gpu() override { } | 138 ~SkSpecialSurface_Gpu() override { } |
138 | 139 |
139 sk_sp<SkSpecialImage> onMakeImageSnapshot() override { | 140 sk_sp<SkSpecialImage> onMakeImageSnapshot() override { |
140 sk_sp<SkSpecialImage> tmp(SkSpecialImage::MakeFromGpu( | 141 sk_sp<SkSpecialImage> tmp(SkSpecialImage::MakeDeferredFromGpu( |
141 this->subset(), | 142 this->subset(), |
142 kNeedNewImageUniqueID_Special
Image, | 143 kNeedNewImageUniqueID_Special
Image, |
143 fRenderTargetContext->asTextu
re(), | 144 fRenderTargetContext->asDefer
redTexture(), |
144 sk_ref_sp(fRenderTargetContex
t->getColorSpace()), | 145 sk_ref_sp(fRenderTargetContex
t->getColorSpace()), |
145 &this->props())); | 146 &this->props())); |
146 fRenderTargetContext = nullptr; | 147 fRenderTargetContext = nullptr; |
147 return tmp; | 148 return tmp; |
148 } | 149 } |
149 | 150 |
150 private: | 151 private: |
151 sk_sp<GrRenderTargetContext> fRenderTargetContext; | 152 sk_sp<GrRenderTargetContext> fRenderTargetContext; |
152 | 153 |
153 typedef SkSpecialSurface_Base INHERITED; | 154 typedef SkSpecialSurface_Base INHERITED; |
(...skipping 12 matching lines...) Expand all Loading... |
166 if (!renderTargetContext) { | 167 if (!renderTargetContext) { |
167 return nullptr; | 168 return nullptr; |
168 } | 169 } |
169 | 170 |
170 const SkIRect subset = SkIRect::MakeWH(width, height); | 171 const SkIRect subset = SkIRect::MakeWH(width, height); |
171 | 172 |
172 return sk_make_sp<SkSpecialSurface_Gpu>(std::move(renderTargetContext), widt
h, height, subset); | 173 return sk_make_sp<SkSpecialSurface_Gpu>(std::move(renderTargetContext), widt
h, height, subset); |
173 } | 174 } |
174 | 175 |
175 #endif | 176 #endif |
OLD | NEW |