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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 bool isOpaque() const override { return fImage->isOpaque(); } | 108 bool isOpaque() const override { return fImage->isOpaque(); } |
109 | 109 |
110 size_t getSize() const override { | 110 size_t getSize() const override { |
111 #if SK_SUPPORT_GPU | 111 #if SK_SUPPORT_GPU |
112 if (GrTexture* texture = as_IB(fImage.get())->peekTexture()) { | 112 if (GrTexture* texture = as_IB(fImage.get())->peekTexture()) { |
113 return texture->gpuMemorySize(); | 113 return texture->gpuMemorySize(); |
114 } else | 114 } else |
115 #endif | 115 #endif |
116 { | 116 { |
117 SkImageInfo info; | 117 SkPixmap pm; |
118 size_t rowBytes; | 118 if (fImage->peekPixels(&pm)) { |
119 | 119 return pm.height() * pm.rowBytes(); |
120 if (fImage->peekPixels(&info, &rowBytes)) { | |
121 return info.height() * rowBytes; | |
122 } | 120 } |
123 } | 121 } |
124 return 0; | 122 return 0; |
125 } | 123 } |
126 | 124 |
127 void onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint)
const override { | 125 void onDraw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint)
const override { |
128 SkRect dst = SkRect::MakeXYWH(x, y, this->subset().width(), this->subset
().height()); | 126 SkRect dst = SkRect::MakeXYWH(x, y, this->subset().width(), this->subset
().height()); |
129 | 127 |
130 canvas->drawImageRect(fImage, this->subset(), | 128 canvas->drawImageRect(fImage, this->subset(), |
131 dst, paint, SkCanvas::kStrict_SrcRectConstraint); | 129 dst, paint, SkCanvas::kStrict_SrcRectConstraint); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 | 365 |
368 SkSpecialImage* SkSpecialImage::NewFromGpu(SkImageFilter::Proxy* proxy, | 366 SkSpecialImage* SkSpecialImage::NewFromGpu(SkImageFilter::Proxy* proxy, |
369 const SkIRect& subset, | 367 const SkIRect& subset, |
370 uint32_t uniqueID, | 368 uint32_t uniqueID, |
371 GrTexture* tex, | 369 GrTexture* tex, |
372 SkAlphaType at) { | 370 SkAlphaType at) { |
373 return nullptr; | 371 return nullptr; |
374 } | 372 } |
375 | 373 |
376 #endif | 374 #endif |
OLD | NEW |