Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Computer, Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 3 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
| 4 * Copyright (C) 2007-2008 Torch Mobile, Inc. | 4 * Copyright (C) 2007-2008 Torch Mobile, Inc. |
| 5 * Copyright (C) 2013 Google, Inc. All rights reserved. | 5 * Copyright (C) 2013 Google, Inc. All rights reserved. |
| 6 * | 6 * |
| 7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
| 8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
| 9 * are met: | 9 * are met: |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 #include "platform/PlatformExport.h" | 33 #include "platform/PlatformExport.h" |
| 34 #include "platform/graphics/Image.h" | 34 #include "platform/graphics/Image.h" |
| 35 #include "platform/transforms/AffineTransform.h" | 35 #include "platform/transforms/AffineTransform.h" |
| 36 | 36 |
| 37 #include "wtf/PassRefPtr.h" | 37 #include "wtf/PassRefPtr.h" |
| 38 #include "wtf/RefCounted.h" | 38 #include "wtf/RefCounted.h" |
| 39 #include "wtf/RefPtr.h" | 39 #include "wtf/RefPtr.h" |
| 40 | 40 |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 class AffineTransform; | |
| 44 | |
| 45 class PLATFORM_EXPORT Pattern : public RefCounted<Pattern> { | 43 class PLATFORM_EXPORT Pattern : public RefCounted<Pattern> { |
| 46 public: | 44 public: |
| 47 static PassRefPtr<Pattern> create(PassRefPtr<Image> tileImage, bool repeatX, bool repeatY) | 45 static PassRefPtr<Pattern> create(PassRefPtr<Image> tileImage, bool repeatX, bool repeatY); |
| 48 { | |
| 49 return adoptRef(new Pattern(tileImage, repeatX, repeatY)); | |
| 50 } | |
| 51 ~Pattern(); | |
| 52 | 46 |
| 53 SkShader* shader(); | 47 virtual ~Pattern(); |
| 48 | |
| 49 SkShader* shader(SkShader::ShaderLocation preferredLocation = SkShader::kKee p_ShaderLocation); | |
| 54 | 50 |
| 55 void setPatternSpaceTransform(const AffineTransform& patternSpaceTransformat ion); | 51 void setPatternSpaceTransform(const AffineTransform& patternSpaceTransformat ion); |
| 56 const AffineTransform& getPatternSpaceTransform() { return m_patternSpaceTra nsformation; }; | 52 const AffineTransform& getPatternSpaceTransform() { return m_patternSpaceTra nsformation; } |
| 57 | 53 |
| 58 bool repeatX() const { return m_repeatX; } | 54 bool repeatX() const { return m_repeatX; } |
| 59 bool repeatY() const { return m_repeatY; } | 55 bool repeatY() const { return m_repeatY; } |
| 56 protected: | |
| 57 virtual PassRefPtr<SkShader> createShader(SkShader::ShaderLocation preferred Location) = 0; | |
| 60 | 58 |
| 61 private: | 59 Pattern(bool repeatX, bool repeatY, int64_t externalMemoryAllocated = 0) |
| 62 Pattern(PassRefPtr<Image>, bool repeatX, bool repeatY); | 60 : m_repeatX(repeatX) |
| 61 , m_repeatY(repeatY) | |
| 62 , m_externalMemoryAllocated(0) | |
| 63 { | |
| 64 adjustExternalMemoryAllocated(externalMemoryAllocated); | |
| 65 } | |
| 63 | 66 |
| 64 RefPtr<NativeImageSkia> m_tileImage; | |
| 65 bool m_repeatX; | 67 bool m_repeatX; |
| 66 bool m_repeatY; | 68 bool m_repeatY; |
| 67 AffineTransform m_patternSpaceTransformation; | 69 AffineTransform m_patternSpaceTransformation; |
| 70 | |
| 71 void adjustExternalMemoryAllocated(int64_t delta); | |
| 72 | |
| 73 private: | |
| 68 RefPtr<SkShader> m_pattern; | 74 RefPtr<SkShader> m_pattern; |
| 69 int m_externalMemoryAllocated; | 75 int64_t m_externalMemoryAllocated; |
| 70 }; | 76 }; |
| 71 | 77 |
| 72 } //namespace | 78 class BitmapBackedPattern : public Pattern { |
|
Justin Novosad
2014/08/05 17:31:26
This should be in its own header and I think it sh
Rémi Piotaix
2014/08/06 18:09:14
Done.
| |
| 79 public: | |
| 80 BitmapBackedPattern(bool repeatX, bool repeatY, int64_t externalMemoryAlloca ted = 0); | |
| 81 virtual ~BitmapBackedPattern(); | |
| 82 | |
| 83 virtual PassRefPtr<SkShader> createShader(SkShader::ShaderLocation preferred Location) OVERRIDE; | |
| 84 | |
| 85 protected: | |
| 86 virtual SkImageInfo getBitmapInfo() = 0; | |
| 87 virtual void drawBitmapToCanvas(SkCanvas&, SkPaint&) = 0; | |
| 88 }; | |
| 89 | |
| 90 } // namespace | |
| 73 | 91 |
| 74 #endif | 92 #endif |
| OLD | NEW |