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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 return sk_make_sp<SkSpecialSurface_Raster>(pr, subset, props); | 108 return sk_make_sp<SkSpecialSurface_Raster>(pr, 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 "SkGpuDevice.h" | 114 #include "SkGpuDevice.h" |
115 | 115 |
116 class SkSpecialSurface_Gpu : public SkSpecialSurface_Base { | 116 class SkSpecialSurface_Gpu : public SkSpecialSurface_Base { |
117 public: | 117 public: |
118 SkSpecialSurface_Gpu(sk_sp<GrDrawContext> drawContext, | 118 SkSpecialSurface_Gpu(sk_sp<GrDrawContext> drawContext, const SkIRect& subset
) |
119 int width, int height, | |
120 const SkIRect& subset) | |
121 : INHERITED(subset, &drawContext->surfaceProps()) | 119 : INHERITED(subset, &drawContext->surfaceProps()) |
122 , fDrawContext(std::move(drawContext)) { | 120 , fDrawContext(std::move(drawContext)) { |
123 | 121 |
124 sk_sp<SkBaseDevice> device(SkGpuDevice::Make(fDrawContext, width, height
, | 122 sk_sp<SkBaseDevice> device(SkGpuDevice::Make(fDrawContext, |
125 SkGpuDevice::kUninit_InitCo
ntents)); | 123 SkGpuDevice::kUninit_InitCo
ntents)); |
126 if (!device) { | 124 if (!device) { |
127 return; | 125 return; |
128 } | 126 } |
129 | 127 |
130 fCanvas.reset(new SkCanvas(device.get())); | 128 fCanvas.reset(new SkCanvas(device.get())); |
131 fCanvas->clipRect(SkRect::Make(subset)); | 129 fCanvas->clipRect(SkRect::Make(subset)); |
132 #ifdef SK_IS_BOT | 130 #ifdef SK_IS_BOT |
133 fCanvas->clear(SK_ColorRED); // catch any imageFilter sloppiness | 131 fCanvas->clear(SK_ColorRED); // catch any imageFilter sloppiness |
134 #endif | 132 #endif |
(...skipping 24 matching lines...) Expand all Loading... |
159 } | 157 } |
160 | 158 |
161 sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kAppr
ox, | 159 sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kAppr
ox, |
162 width, height, conf
ig)); | 160 width, height, conf
ig)); |
163 if (!drawContext) { | 161 if (!drawContext) { |
164 return nullptr; | 162 return nullptr; |
165 } | 163 } |
166 | 164 |
167 const SkIRect subset = SkIRect::MakeWH(width, height); | 165 const SkIRect subset = SkIRect::MakeWH(width, height); |
168 | 166 |
169 return sk_make_sp<SkSpecialSurface_Gpu>(std::move(drawContext), width, heigh
t, subset); | 167 return sk_make_sp<SkSpecialSurface_Gpu>(std::move(drawContext), subset); |
170 } | 168 } |
171 | 169 |
172 #endif | 170 #endif |
OLD | NEW |